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.MolecularSequence;
110 import org.forester.species.BasicSpecies;
111 import org.forester.species.Species;
112 import org.forester.surfacing.TestSurfacing;
113 import org.forester.tools.ConfidenceAssessor;
114 import org.forester.tools.SupportCount;
115 import org.forester.tools.TreeSplitMatrix;
116 import org.forester.util.AsciiHistogram;
117 import org.forester.util.BasicDescriptiveStatistics;
118 import org.forester.util.BasicTable;
119 import org.forester.util.BasicTableParser;
120 import org.forester.util.DescriptiveStatistics;
121 import org.forester.util.ForesterConstants;
122 import org.forester.util.ForesterUtil;
123 import org.forester.util.GeneralTable;
124 import org.forester.util.SequenceAccessionTools;
125 import org.forester.ws.seqdb.SequenceDatabaseEntry;
126 import org.forester.ws.seqdb.SequenceDbWsTools;
127 import org.forester.ws.seqdb.UniProtTaxonomy;
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 = true;
143 private static final boolean PERFORM_WEB_TREE_ACCESS = true;
144 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
145 + ForesterConstants.PHYLO_XML_VERSION + "/"
146 + ForesterConstants.PHYLO_XML_XSD;
147 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
148 + ForesterConstants.PHYLO_XML_VERSION + "/"
149 + ForesterConstants.PHYLO_XML_XSD;
150 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
151 private final static double ZERO_DIFF = 1.0E-9;
153 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( "Basic node methods: " );
185 if ( Test.testBasicNodeMethods() ) {
186 System.out.println( "OK." );
190 System.out.println( "failed." );
193 System.out.print( "Protein id: " );
194 if ( !testProteinId() ) {
195 System.out.println( "failed." );
201 System.out.println( "OK." );
202 System.out.print( "Species: " );
203 if ( !testSpecies() ) {
204 System.out.println( "failed." );
210 System.out.println( "OK." );
211 System.out.print( "Basic domain: " );
212 if ( !testBasicDomain() ) {
213 System.out.println( "failed." );
219 System.out.println( "OK." );
220 System.out.print( "Basic protein: " );
221 if ( !testBasicProtein() ) {
222 System.out.println( "failed." );
228 System.out.println( "OK." );
229 System.out.print( "Sequence writer: " );
230 if ( testSequenceWriter() ) {
231 System.out.println( "OK." );
235 System.out.println( "failed." );
238 System.out.print( "Sequence id parsing: " );
239 if ( testSequenceIdParsing() ) {
240 System.out.println( "OK." );
244 System.out.println( "failed." );
247 System.out.print( "UniProtKB id extraction: " );
248 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
249 System.out.println( "OK." );
253 System.out.println( "failed." );
256 System.out.print( "Sequence DB tools 1: " );
257 if ( testSequenceDbWsTools1() ) {
258 System.out.println( "OK." );
262 System.out.println( "failed." );
265 System.out.print( "Hmmscan output parser: " );
266 if ( testHmmscanOutputParser() ) {
267 System.out.println( "OK." );
271 System.out.println( "failed." );
274 System.out.print( "Overlap removal: " );
275 if ( !org.forester.test.Test.testOverlapRemoval() ) {
276 System.out.println( "failed." );
282 System.out.println( "OK." );
283 System.out.print( "Engulfing overlap removal: " );
284 if ( !Test.testEngulfingOverlapRemoval() ) {
285 System.out.println( "failed." );
291 System.out.println( "OK." );
292 System.out.print( "Taxonomy data extraction: " );
293 if ( Test.testExtractTaxonomyDataFromNodeName() ) {
294 System.out.println( "OK." );
298 System.out.println( "failed." );
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 System.out.print( "MSA entropy: " );
926 if ( Test.testMsaEntropy() ) {
927 System.out.println( "OK." );
931 System.out.println( "failed." );
934 if ( PERFORM_DB_TESTS ) {
935 System.out.print( "Uniprot Entry Retrieval: " );
936 if ( Test.testUniprotEntryRetrieval() ) {
937 System.out.println( "OK." );
941 System.out.println( "failed." );
944 System.out.print( "Ebi Entry Retrieval: " );
945 if ( Test.testEbiEntryRetrieval() ) {
946 System.out.println( "OK." );
950 System.out.println( "failed." );
953 System.out.print( "Sequence DB tools 2: " );
954 if ( testSequenceDbWsTools2() ) {
955 System.out.println( "OK." );
959 System.out.println( "failed." );
963 System.out.print( "Uniprot Taxonomy Search: " );
964 if ( Test.testUniprotTaxonomySearch() ) {
965 System.out.println( "OK." );
969 System.out.println( "failed." );
973 if ( PERFORM_WEB_TREE_ACCESS ) {
974 System.out.print( "NHX parsing from URL: " );
975 if ( Test.testNHXparsingFromURL() ) {
976 System.out.println( "OK." );
980 System.out.println( "failed." );
983 System.out.print( "NHX parsing from URL 2: " );
984 if ( Test.testNHXparsingFromURL2() ) {
985 System.out.println( "OK." );
989 System.out.println( "failed." );
992 System.out.print( "phyloXML parsing from URL: " );
993 if ( Test.testPhyloXMLparsingFromURL() ) {
994 System.out.println( "OK." );
998 System.out.println( "failed." );
1001 System.out.print( "TreeBase acccess: " );
1002 if ( Test.testTreeBaseReading() ) {
1003 System.out.println( "OK." );
1007 System.out.println( "failed." );
1011 System.out.print( "ToL access: " );
1012 if ( Test.testToLReading() ) {
1013 System.out.println( "OK." );
1017 System.out.println( "failed." );
1021 System.out.print( "TreeFam access: " );
1022 if ( Test.testTreeFamReading() ) {
1023 System.out.println( "OK." );
1027 System.out.println( "failed." );
1032 System.out.print( "Pfam tree access: " );
1033 if ( Test.testPfamTreeReading() ) {
1034 System.out.println( "OK." );
1038 System.out.println( "failed." );
1042 System.out.println();
1043 final Runtime rt = java.lang.Runtime.getRuntime();
1044 final long free_memory = rt.freeMemory() / 1000000;
1045 final long total_memory = rt.totalMemory() / 1000000;
1046 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1047 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1048 System.out.println();
1049 System.out.println( "Successful tests: " + succeeded );
1050 System.out.println( "Failed tests: " + failed );
1051 System.out.println();
1053 System.out.println( "OK." );
1056 System.out.println( "Not OK." );
1060 public static boolean testEngulfingOverlapRemoval() {
1062 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1063 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1064 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1065 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1066 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1067 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1068 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1069 final List<Boolean> covered = new ArrayList<Boolean>();
1070 covered.add( true ); // 0
1071 covered.add( false ); // 1
1072 covered.add( true ); // 2
1073 covered.add( false ); // 3
1074 covered.add( true ); // 4
1075 covered.add( true ); // 5
1076 covered.add( false ); // 6
1077 covered.add( true ); // 7
1078 covered.add( true ); // 8
1079 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1082 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1085 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1088 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1091 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1094 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1097 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1100 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1101 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1102 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1103 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1104 abc.addProteinDomain( a );
1105 abc.addProteinDomain( b );
1106 abc.addProteinDomain( c );
1107 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1108 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1109 if ( abc.getNumberOfProteinDomains() != 3 ) {
1112 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1115 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1118 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1121 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1124 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1125 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1126 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1127 final Protein def = new BasicProtein( "def", "nemve", 0 );
1128 def.addProteinDomain( d );
1129 def.addProteinDomain( e );
1130 def.addProteinDomain( f );
1131 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1132 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1133 if ( def.getNumberOfProteinDomains() != 3 ) {
1136 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1139 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1142 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1145 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1148 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1152 catch ( final Exception e ) {
1153 e.printStackTrace( System.out );
1159 public static final boolean testNHXparsingFromURL2() {
1161 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1162 final Phylogeny phys[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1166 TAXONOMY_EXTRACTION.NO,
1168 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1171 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1172 System.out.println( phys[ 0 ].toNewHampshire() );
1175 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1176 System.out.println( phys[ 1 ].toNewHampshire() );
1179 final Phylogeny phys2[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1183 TAXONOMY_EXTRACTION.NO,
1185 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1188 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1189 System.out.println( phys2[ 0 ].toNewHampshire() );
1192 if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1193 System.out.println( phys2[ 1 ].toNewHampshire() );
1196 final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1197 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1198 if ( ( phys3 == null ) || ( phys3.length != 1 ) ) {
1203 .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))))));" ) ) {
1204 System.out.println( phys3[ 0 ].toNewHampshire() );
1207 final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1208 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1209 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1214 .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))))));" ) ) {
1215 System.out.println( phys4[ 0 ].toNewHampshire() );
1219 catch ( final Exception e ) {
1220 e.printStackTrace();
1226 public static final boolean testNHXparsingFromURL() {
1228 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1229 final URL u = new URL( s );
1230 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1231 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1232 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1235 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1236 System.out.println( phys[ 0 ].toNewHampshire() );
1239 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1240 System.out.println( phys[ 1 ].toNewHampshire() );
1243 final URL u2 = new URL( s );
1244 final Phylogeny[] phys2 = factory.create( u2.openStream(), new NHXParser() );
1245 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1248 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1249 System.out.println( phys2[ 0 ].toNewHampshire() );
1252 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1253 final NHXParser p = new NHXParser();
1254 final URL u3 = new URL( s );
1256 if ( !p.hasNext() ) {
1259 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1262 if ( !p.hasNext() ) {
1266 if ( !p.hasNext() ) {
1269 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1272 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1276 if ( !p.hasNext() ) {
1279 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1282 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1286 catch ( final Exception e ) {
1287 System.out.println( e.toString() );
1288 e.printStackTrace();
1294 public static boolean testOverlapRemoval() {
1296 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1297 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1298 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1299 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1300 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1301 final List<Boolean> covered = new ArrayList<Boolean>();
1302 covered.add( true ); // 0
1303 covered.add( false ); // 1
1304 covered.add( true ); // 2
1305 covered.add( false ); // 3
1306 covered.add( true ); // 4
1307 covered.add( true ); // 5
1308 covered.add( false ); // 6
1309 covered.add( true ); // 7
1310 covered.add( true ); // 8
1311 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1314 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1317 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1320 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1323 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1326 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1327 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1328 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1329 ab.addProteinDomain( a );
1330 ab.addProteinDomain( b );
1331 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1332 if ( ab.getNumberOfProteinDomains() != 2 ) {
1335 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1338 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1341 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1342 if ( ab.getNumberOfProteinDomains() != 2 ) {
1345 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1348 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1349 final Domain d = new BasicDomain( "d",
1356 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1357 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1358 cde.addProteinDomain( c );
1359 cde.addProteinDomain( d );
1360 cde.addProteinDomain( e );
1361 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1362 if ( cde.getNumberOfProteinDomains() != 3 ) {
1365 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1368 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1369 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1370 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1371 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1372 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1373 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1374 fghi.addProteinDomain( f );
1375 fghi.addProteinDomain( g );
1376 fghi.addProteinDomain( h );
1377 fghi.addProteinDomain( i );
1378 fghi.addProteinDomain( i );
1379 fghi.addProteinDomain( i );
1380 fghi.addProteinDomain( i2 );
1381 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1382 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1385 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1388 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1391 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1392 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1395 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1398 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1399 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1400 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1401 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1402 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1403 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1404 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1405 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1406 jklm.addProteinDomain( j );
1407 jklm.addProteinDomain( k );
1408 jklm.addProteinDomain( l );
1409 jklm.addProteinDomain( m );
1410 jklm.addProteinDomain( m0 );
1411 jklm.addProteinDomain( m1 );
1412 jklm.addProteinDomain( m2 );
1413 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1414 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1417 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1420 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1423 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1424 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1427 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1430 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1431 final Protein od = new BasicProtein( "od", "varanus", 0 );
1432 od.addProteinDomain( only );
1433 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1434 if ( od.getNumberOfProteinDomains() != 1 ) {
1437 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1441 catch ( final Exception e ) {
1442 e.printStackTrace( System.out );
1448 public static final boolean testPfamTreeReading() {
1450 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1451 final NHXParser parser = new NHXParser();
1452 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1453 parser.setReplaceUnderscores( false );
1454 parser.setGuessRootedness( true );
1455 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1456 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1457 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1460 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1464 catch ( final Exception e ) {
1465 e.printStackTrace();
1470 public static final boolean testPhyloXMLparsingFromURL() {
1472 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1473 final URL u = new URL( s );
1474 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1475 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1476 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1480 catch ( final Exception e ) {
1481 e.printStackTrace();
1486 public static final boolean testToLReading() {
1488 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1489 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1490 final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
1491 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1494 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1497 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1500 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1504 catch ( final Exception e ) {
1505 e.printStackTrace();
1510 public static final boolean testTreeBaseReading() {
1512 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1513 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1514 parser.setReplaceUnderscores( true );
1515 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1516 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1517 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1520 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1521 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1522 parser2.setReplaceUnderscores( true );
1523 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1524 final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
1525 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1529 catch ( final Exception e ) {
1530 e.printStackTrace();
1535 public static final boolean testTreeFamReading() {
1537 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1538 final NHXParser parser = new NHXParser();
1539 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1540 parser.setReplaceUnderscores( false );
1541 parser.setGuessRootedness( true );
1542 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1543 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1544 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1547 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1551 catch ( final Exception e ) {
1552 e.printStackTrace();
1557 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1558 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1562 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1563 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1566 private static boolean testAminoAcidSequence() {
1568 final MolecularSequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1569 if ( aa1.getLength() != 13 ) {
1572 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1575 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1578 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1581 final MolecularSequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1582 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZOXU" ) ) {
1585 final MolecularSequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1586 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1589 final MolecularSequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1590 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1594 catch ( final Exception e ) {
1595 e.printStackTrace();
1601 private static boolean testBasicDomain() {
1603 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1604 if ( !pd.getDomainId().equals( "id" ) ) {
1607 if ( pd.getNumber() != 1 ) {
1610 if ( pd.getTotalCount() != 4 ) {
1613 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1616 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1617 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1618 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1619 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1620 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1621 if ( !a1.equals( a1 ) ) {
1624 if ( !a1.equals( a1_copy ) ) {
1627 if ( !a1.equals( a1_equal ) ) {
1630 if ( !a1.equals( a2 ) ) {
1633 if ( a1.equals( a3 ) ) {
1636 if ( a1.compareTo( a1 ) != 0 ) {
1639 if ( a1.compareTo( a1_copy ) != 0 ) {
1642 if ( a1.compareTo( a1_equal ) != 0 ) {
1645 if ( a1.compareTo( a2 ) != 0 ) {
1648 if ( a1.compareTo( a3 ) == 0 ) {
1652 catch ( final Exception e ) {
1653 e.printStackTrace( System.out );
1659 private static boolean testBasicNodeMethods() {
1661 if ( PhylogenyNode.getNodeCount() != 0 ) {
1664 final PhylogenyNode n1 = new PhylogenyNode();
1665 final PhylogenyNode n2 = PhylogenyNode
1666 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1667 final PhylogenyNode n3 = PhylogenyNode
1668 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1669 final PhylogenyNode n4 = PhylogenyNode
1670 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1671 if ( n1.isHasAssignedEvent() ) {
1674 if ( PhylogenyNode.getNodeCount() != 4 ) {
1677 if ( n3.getIndicator() != 0 ) {
1680 if ( n3.getNumberOfExternalNodes() != 1 ) {
1683 if ( !n3.isExternal() ) {
1686 if ( !n3.isRoot() ) {
1689 if ( !n4.getName().equals( "n4" ) ) {
1693 catch ( final Exception e ) {
1694 e.printStackTrace( System.out );
1700 private static boolean testBasicPhyloXMLparsing() {
1702 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1703 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1704 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1706 if ( xml_parser.getErrorCount() > 0 ) {
1707 System.out.println( xml_parser.getErrorMessages().toString() );
1710 if ( phylogenies_0.length != 4 ) {
1713 final Phylogeny t1 = phylogenies_0[ 0 ];
1714 final Phylogeny t2 = phylogenies_0[ 1 ];
1715 final Phylogeny t3 = phylogenies_0[ 2 ];
1716 final Phylogeny t4 = phylogenies_0[ 3 ];
1717 if ( t1.getNumberOfExternalNodes() != 1 ) {
1720 if ( !t1.isRooted() ) {
1723 if ( t1.isRerootable() ) {
1726 if ( !t1.getType().equals( "gene_tree" ) ) {
1729 if ( t2.getNumberOfExternalNodes() != 2 ) {
1732 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1735 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1738 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1741 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1744 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1747 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1750 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1751 .startsWith( "actgtgggggt" ) ) {
1754 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1755 .startsWith( "ctgtgatgcat" ) ) {
1758 if ( t3.getNumberOfExternalNodes() != 4 ) {
1761 if ( !t1.getName().equals( "t1" ) ) {
1764 if ( !t2.getName().equals( "t2" ) ) {
1767 if ( !t3.getName().equals( "t3" ) ) {
1770 if ( !t4.getName().equals( "t4" ) ) {
1773 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1776 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1779 if ( !t3.getNode( "root node" ).isDuplication() ) {
1782 if ( !t3.getNode( "node a" ).isDuplication() ) {
1785 if ( t3.getNode( "node a" ).isSpeciation() ) {
1788 if ( t3.getNode( "node bc" ).isDuplication() ) {
1791 if ( !t3.getNode( "node bc" ).isSpeciation() ) {
1794 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1797 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1798 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1801 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1804 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1807 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1810 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1811 .equals( "apoptosis" ) ) {
1814 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1815 .equals( "GO:0006915" ) ) {
1818 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1819 .equals( "UniProtKB" ) ) {
1822 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1823 .equals( "experimental" ) ) {
1826 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1827 .equals( "function" ) ) {
1830 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1831 .getValue() != 1 ) {
1834 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1835 .getType().equals( "ml" ) ) {
1838 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1839 .equals( "apoptosis" ) ) {
1842 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1843 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1846 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1847 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1850 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1851 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1854 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1855 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1858 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1859 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1862 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1863 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1866 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1867 .equals( "GO:0005829" ) ) {
1870 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1871 .equals( "intracellular organelle" ) ) {
1874 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1877 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1878 .equals( "UniProt link" ) ) ) {
1881 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1884 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1885 if ( x.size() != 4 ) {
1889 for( final Accession acc : x ) {
1891 if ( !acc.getSource().equals( "KEGG" ) ) {
1894 if ( !acc.getValue().equals( "hsa:596" ) ) {
1901 catch ( final Exception e ) {
1902 e.printStackTrace( System.out );
1908 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1910 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1911 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1912 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1913 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1916 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1918 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1920 if ( xml_parser.getErrorCount() > 0 ) {
1921 System.out.println( xml_parser.getErrorMessages().toString() );
1924 if ( phylogenies_0.length != 4 ) {
1927 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1928 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1929 if ( phylogenies_t1.length != 1 ) {
1932 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1933 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1936 if ( !t1_rt.isRooted() ) {
1939 if ( t1_rt.isRerootable() ) {
1942 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1945 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1946 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1947 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1948 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1951 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1954 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1957 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1960 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1961 .startsWith( "actgtgggggt" ) ) {
1964 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1965 .startsWith( "ctgtgatgcat" ) ) {
1968 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1969 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1970 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1971 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1972 if ( phylogenies_1.length != 1 ) {
1975 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1976 if ( !t3_rt.getName().equals( "t3" ) ) {
1979 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1982 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1985 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1988 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1991 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1992 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1995 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1998 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2001 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2002 .equals( "UniProtKB" ) ) {
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 ) ).getRef()
2010 .equals( "GO:0006915" ) ) {
2013 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2014 .equals( "UniProtKB" ) ) {
2017 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2018 .equals( "experimental" ) ) {
2021 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2022 .equals( "function" ) ) {
2025 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2026 .getValue() != 1 ) {
2029 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2030 .getType().equals( "ml" ) ) {
2033 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2034 .equals( "apoptosis" ) ) {
2037 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2038 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2041 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2042 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
2045 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2046 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
2049 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2050 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
2053 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2054 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
2057 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2058 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
2061 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2062 .equals( "GO:0005829" ) ) {
2065 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2066 .equals( "intracellular organelle" ) ) {
2069 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2072 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2073 .equals( "UniProt link" ) ) ) {
2076 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2079 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
2082 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
2083 .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." ) ) ) {
2086 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
2089 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
2092 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
2095 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
2098 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
2099 .equals( "ncbi" ) ) {
2102 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
2105 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2106 .getName().equals( "B" ) ) {
2109 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2110 .getFrom() != 21 ) {
2113 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
2116 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2117 .getLength() != 24 ) {
2120 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2121 .getConfidence() != 0 ) {
2124 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2125 .equals( "pfam" ) ) {
2128 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2131 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2134 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2137 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2140 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2141 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2144 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2147 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2150 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2153 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2156 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2159 if ( taxbb.getSynonyms().size() != 2 ) {
2162 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2165 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2168 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2171 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2174 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2177 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2178 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2181 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2184 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2187 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2190 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2193 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2196 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2199 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2202 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2205 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2206 .equalsIgnoreCase( "435" ) ) {
2209 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2212 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2213 .equalsIgnoreCase( "443.7" ) ) {
2216 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2219 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2222 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2223 .equalsIgnoreCase( "433" ) ) {
2226 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2227 .getCrossReferences();
2228 if ( x.size() != 4 ) {
2232 for( final Accession acc : x ) {
2234 if ( !acc.getSource().equals( "KEGG" ) ) {
2237 if ( !acc.getValue().equals( "hsa:596" ) ) {
2244 catch ( final Exception e ) {
2245 e.printStackTrace( System.out );
2251 private static boolean testBasicPhyloXMLparsingValidating() {
2253 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2254 PhyloXmlParser xml_parser = null;
2256 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2258 catch ( final Exception e ) {
2259 // Do nothing -- means were not running from jar.
2261 if ( xml_parser == null ) {
2262 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2263 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2264 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2267 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2270 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2272 if ( xml_parser.getErrorCount() > 0 ) {
2273 System.out.println( xml_parser.getErrorMessages().toString() );
2276 if ( phylogenies_0.length != 4 ) {
2279 final Phylogeny t1 = phylogenies_0[ 0 ];
2280 final Phylogeny t2 = phylogenies_0[ 1 ];
2281 final Phylogeny t3 = phylogenies_0[ 2 ];
2282 final Phylogeny t4 = phylogenies_0[ 3 ];
2283 if ( !t1.getName().equals( "t1" ) ) {
2286 if ( !t2.getName().equals( "t2" ) ) {
2289 if ( !t3.getName().equals( "t3" ) ) {
2292 if ( !t4.getName().equals( "t4" ) ) {
2295 if ( t1.getNumberOfExternalNodes() != 1 ) {
2298 if ( t2.getNumberOfExternalNodes() != 2 ) {
2301 if ( t3.getNumberOfExternalNodes() != 4 ) {
2304 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2305 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2306 if ( xml_parser.getErrorCount() > 0 ) {
2307 System.out.println( "errors:" );
2308 System.out.println( xml_parser.getErrorMessages().toString() );
2311 if ( phylogenies_1.length != 4 ) {
2314 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2316 if ( xml_parser.getErrorCount() > 0 ) {
2317 System.out.println( "errors:" );
2318 System.out.println( xml_parser.getErrorMessages().toString() );
2321 if ( phylogenies_2.length != 1 ) {
2324 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2327 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2329 if ( xml_parser.getErrorCount() > 0 ) {
2330 System.out.println( xml_parser.getErrorMessages().toString() );
2333 if ( phylogenies_3.length != 2 ) {
2336 final Phylogeny a = phylogenies_3[ 0 ];
2337 if ( !a.getName().equals( "tree 4" ) ) {
2340 if ( a.getNumberOfExternalNodes() != 3 ) {
2343 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2346 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2349 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2351 if ( xml_parser.getErrorCount() > 0 ) {
2352 System.out.println( xml_parser.getErrorMessages().toString() );
2355 if ( phylogenies_4.length != 1 ) {
2358 final Phylogeny s = phylogenies_4[ 0 ];
2359 if ( s.getNumberOfExternalNodes() != 6 ) {
2362 s.getNode( "first" );
2364 s.getNode( "\"<a'b&c'd\">\"" );
2365 s.getNode( "'''\"" );
2366 s.getNode( "\"\"\"" );
2367 s.getNode( "dick & doof" );
2369 catch ( final Exception e ) {
2370 e.printStackTrace( System.out );
2376 private static boolean testBasicProtein() {
2378 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2379 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2380 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2381 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2382 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2383 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2384 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2385 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2386 p0.addProteinDomain( y );
2387 p0.addProteinDomain( e );
2388 p0.addProteinDomain( b );
2389 p0.addProteinDomain( c );
2390 p0.addProteinDomain( d );
2391 p0.addProteinDomain( a );
2392 p0.addProteinDomain( x );
2393 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2396 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2400 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2401 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2402 aa0.addProteinDomain( a1 );
2403 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2406 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2410 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2411 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2412 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2413 aa1.addProteinDomain( a11 );
2414 aa1.addProteinDomain( a12 );
2415 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2418 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2421 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2422 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2425 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2428 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2431 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2432 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2435 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2438 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2441 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2444 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2445 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2448 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2451 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2454 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2457 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2458 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2461 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2464 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2467 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2471 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2472 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2473 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2474 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2475 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2476 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2477 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2478 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2479 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2480 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2481 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2482 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2483 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2484 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2485 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2486 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2487 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2488 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2489 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2490 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2491 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2492 p00.addProteinDomain( y0 );
2493 p00.addProteinDomain( e0 );
2494 p00.addProteinDomain( b0 );
2495 p00.addProteinDomain( c0 );
2496 p00.addProteinDomain( d0 );
2497 p00.addProteinDomain( a0 );
2498 p00.addProteinDomain( x0 );
2499 p00.addProteinDomain( y1 );
2500 p00.addProteinDomain( y2 );
2501 p00.addProteinDomain( y3 );
2502 p00.addProteinDomain( e1 );
2503 p00.addProteinDomain( e2 );
2504 p00.addProteinDomain( e3 );
2505 p00.addProteinDomain( e4 );
2506 p00.addProteinDomain( e5 );
2507 p00.addProteinDomain( z0 );
2508 p00.addProteinDomain( z1 );
2509 p00.addProteinDomain( z2 );
2510 p00.addProteinDomain( zz0 );
2511 p00.addProteinDomain( zz1 );
2512 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2515 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2518 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2521 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2524 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" ) ) {
2527 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2528 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2529 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2530 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2531 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2532 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2533 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2534 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2535 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2536 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2537 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2538 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2539 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2540 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2541 p.addProteinDomain( B15 );
2542 p.addProteinDomain( C50 );
2543 p.addProteinDomain( A60 );
2544 p.addProteinDomain( A30 );
2545 p.addProteinDomain( C70 );
2546 p.addProteinDomain( B35 );
2547 p.addProteinDomain( B40 );
2548 p.addProteinDomain( A0 );
2549 p.addProteinDomain( A10 );
2550 p.addProteinDomain( A20 );
2551 p.addProteinDomain( B25 );
2552 p.addProteinDomain( D80 );
2553 List<String> domains_ids = new ArrayList<String>();
2554 domains_ids.add( "A" );
2555 domains_ids.add( "B" );
2556 domains_ids.add( "C" );
2557 if ( !p.contains( domains_ids, false ) ) {
2560 if ( !p.contains( domains_ids, true ) ) {
2563 domains_ids.add( "X" );
2564 if ( p.contains( domains_ids, false ) ) {
2567 if ( p.contains( domains_ids, true ) ) {
2570 domains_ids = new ArrayList<String>();
2571 domains_ids.add( "A" );
2572 domains_ids.add( "C" );
2573 domains_ids.add( "D" );
2574 if ( !p.contains( domains_ids, false ) ) {
2577 if ( !p.contains( domains_ids, true ) ) {
2580 domains_ids = new ArrayList<String>();
2581 domains_ids.add( "A" );
2582 domains_ids.add( "D" );
2583 domains_ids.add( "C" );
2584 if ( !p.contains( domains_ids, false ) ) {
2587 if ( p.contains( domains_ids, true ) ) {
2590 domains_ids = new ArrayList<String>();
2591 domains_ids.add( "A" );
2592 domains_ids.add( "A" );
2593 domains_ids.add( "B" );
2594 if ( !p.contains( domains_ids, false ) ) {
2597 if ( !p.contains( domains_ids, true ) ) {
2600 domains_ids = new ArrayList<String>();
2601 domains_ids.add( "A" );
2602 domains_ids.add( "A" );
2603 domains_ids.add( "A" );
2604 domains_ids.add( "B" );
2605 domains_ids.add( "B" );
2606 if ( !p.contains( domains_ids, false ) ) {
2609 if ( !p.contains( domains_ids, true ) ) {
2612 domains_ids = new ArrayList<String>();
2613 domains_ids.add( "A" );
2614 domains_ids.add( "A" );
2615 domains_ids.add( "B" );
2616 domains_ids.add( "A" );
2617 domains_ids.add( "B" );
2618 domains_ids.add( "B" );
2619 domains_ids.add( "A" );
2620 domains_ids.add( "B" );
2621 domains_ids.add( "C" );
2622 domains_ids.add( "A" );
2623 domains_ids.add( "C" );
2624 domains_ids.add( "D" );
2625 if ( !p.contains( domains_ids, false ) ) {
2628 if ( p.contains( domains_ids, true ) ) {
2632 catch ( final Exception e ) {
2633 e.printStackTrace( System.out );
2639 private static boolean testBasicTable() {
2641 final BasicTable<String> t0 = new BasicTable<String>();
2642 if ( t0.getNumberOfColumns() != 0 ) {
2645 if ( t0.getNumberOfRows() != 0 ) {
2648 t0.setValue( 3, 2, "23" );
2649 t0.setValue( 10, 1, "error" );
2650 t0.setValue( 10, 1, "110" );
2651 t0.setValue( 9, 1, "19" );
2652 t0.setValue( 1, 10, "101" );
2653 t0.setValue( 10, 10, "1010" );
2654 t0.setValue( 100, 10, "10100" );
2655 t0.setValue( 0, 0, "00" );
2656 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2659 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2662 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2665 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2668 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2671 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2674 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2677 if ( t0.getNumberOfColumns() != 101 ) {
2680 if ( t0.getNumberOfRows() != 11 ) {
2683 if ( t0.getValueAsString( 49, 4 ) != null ) {
2686 final String l = ForesterUtil.getLineSeparator();
2687 final StringBuffer source = new StringBuffer();
2688 source.append( "" + l );
2689 source.append( "# 1 1 1 1 1 1 1 1" + l );
2690 source.append( " 00 01 02 03" + l );
2691 source.append( " 10 11 12 13 " + l );
2692 source.append( "20 21 22 23 " + l );
2693 source.append( " 30 31 32 33" + l );
2694 source.append( "40 41 42 43" + l );
2695 source.append( " # 1 1 1 1 1 " + l );
2696 source.append( "50 51 52 53 54" + l );
2697 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2698 if ( t1.getNumberOfColumns() != 5 ) {
2701 if ( t1.getNumberOfRows() != 6 ) {
2704 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2707 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2710 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2713 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2716 final StringBuffer source1 = new StringBuffer();
2717 source1.append( "" + l );
2718 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2719 source1.append( " 00; 01 ;02;03" + l );
2720 source1.append( " 10; 11; 12; 13 " + l );
2721 source1.append( "20; 21; 22; 23 " + l );
2722 source1.append( " 30; 31; 32; 33" + l );
2723 source1.append( "40;41;42;43" + l );
2724 source1.append( " # 1 1 1 1 1 " + l );
2725 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2726 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2727 if ( t2.getNumberOfColumns() != 5 ) {
2730 if ( t2.getNumberOfRows() != 6 ) {
2733 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2736 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2739 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2742 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2745 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2748 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2751 final StringBuffer source2 = new StringBuffer();
2752 source2.append( "" + l );
2753 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2754 source2.append( " 00; 01 ;02;03" + l );
2755 source2.append( " 10; 11; 12; 13 " + l );
2756 source2.append( "20; 21; 22; 23 " + l );
2757 source2.append( " " + l );
2758 source2.append( " 30; 31; 32; 33" + l );
2759 source2.append( "40;41;42;43" + l );
2760 source2.append( " comment: 1 1 1 1 1 " + l );
2761 source2.append( ";;;50 ; 52; 53;;54 " + l );
2762 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2768 if ( tl.size() != 2 ) {
2771 final BasicTable<String> t3 = tl.get( 0 );
2772 final BasicTable<String> t4 = tl.get( 1 );
2773 if ( t3.getNumberOfColumns() != 4 ) {
2776 if ( t3.getNumberOfRows() != 3 ) {
2779 if ( t4.getNumberOfColumns() != 4 ) {
2782 if ( t4.getNumberOfRows() != 3 ) {
2785 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2788 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2792 catch ( final Exception e ) {
2793 e.printStackTrace( System.out );
2799 private static boolean testBasicTolXMLparsing() {
2801 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2802 final TolParser parser = new TolParser();
2803 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2804 if ( parser.getErrorCount() > 0 ) {
2805 System.out.println( parser.getErrorMessages().toString() );
2808 if ( phylogenies_0.length != 1 ) {
2811 final Phylogeny t1 = phylogenies_0[ 0 ];
2812 if ( t1.getNumberOfExternalNodes() != 5 ) {
2815 if ( !t1.isRooted() ) {
2818 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2821 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2824 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2827 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2830 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2831 if ( parser.getErrorCount() > 0 ) {
2832 System.out.println( parser.getErrorMessages().toString() );
2835 if ( phylogenies_1.length != 1 ) {
2838 final Phylogeny t2 = phylogenies_1[ 0 ];
2839 if ( t2.getNumberOfExternalNodes() != 664 ) {
2842 if ( !t2.isRooted() ) {
2845 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2848 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2851 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2854 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2857 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2860 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2861 .equals( "Aquifex" ) ) {
2864 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2865 if ( parser.getErrorCount() > 0 ) {
2866 System.out.println( parser.getErrorMessages().toString() );
2869 if ( phylogenies_2.length != 1 ) {
2872 final Phylogeny t3 = phylogenies_2[ 0 ];
2873 if ( t3.getNumberOfExternalNodes() != 184 ) {
2876 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2879 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2882 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2885 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2886 if ( parser.getErrorCount() > 0 ) {
2887 System.out.println( parser.getErrorMessages().toString() );
2890 if ( phylogenies_3.length != 1 ) {
2893 final Phylogeny t4 = phylogenies_3[ 0 ];
2894 if ( t4.getNumberOfExternalNodes() != 1 ) {
2897 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2900 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2903 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2906 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2907 if ( parser.getErrorCount() > 0 ) {
2908 System.out.println( parser.getErrorMessages().toString() );
2911 if ( phylogenies_4.length != 1 ) {
2914 final Phylogeny t5 = phylogenies_4[ 0 ];
2915 if ( t5.getNumberOfExternalNodes() != 13 ) {
2918 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2921 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2924 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2928 catch ( final Exception e ) {
2929 e.printStackTrace( System.out );
2935 private static boolean testBasicTreeMethods() {
2937 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2938 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2939 if ( t2.getNumberOfExternalNodes() != 4 ) {
2942 if ( t2.getHeight() != 8.5 ) {
2945 if ( !t2.isCompletelyBinary() ) {
2948 if ( t2.isEmpty() ) {
2951 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2952 if ( t3.getNumberOfExternalNodes() != 5 ) {
2955 if ( t3.getHeight() != 11 ) {
2958 if ( t3.isCompletelyBinary() ) {
2961 final PhylogenyNode n = t3.getNode( "ABC" );
2962 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 ];
2963 if ( t4.getNumberOfExternalNodes() != 9 ) {
2966 if ( t4.getHeight() != 11 ) {
2969 if ( t4.isCompletelyBinary() ) {
2972 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)" );
2973 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2974 if ( t5.getNumberOfExternalNodes() != 8 ) {
2977 if ( t5.getHeight() != 15 ) {
2980 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)" );
2981 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2982 if ( t6.getHeight() != 15 ) {
2985 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)" );
2986 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2987 if ( t7.getHeight() != 15 ) {
2990 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)" );
2991 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2992 if ( t8.getNumberOfExternalNodes() != 10 ) {
2995 if ( t8.getHeight() != 15 ) {
2998 final char[] a9 = new char[] { 'a' };
2999 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
3000 if ( t9.getHeight() != 0 ) {
3003 final char[] a10 = new char[] { 'a', ':', '6' };
3004 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
3005 if ( t10.getHeight() != 6 ) {
3009 catch ( final Exception e ) {
3010 e.printStackTrace( System.out );
3016 private static boolean testConfidenceAssessor() {
3018 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3019 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3020 final Phylogeny[] ev0 = factory
3021 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
3023 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
3024 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3027 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3030 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3031 final Phylogeny[] ev1 = factory
3032 .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)));",
3034 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
3035 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
3038 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3041 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3042 final Phylogeny[] ev_b = factory
3043 .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",
3045 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
3046 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
3049 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3053 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3054 final Phylogeny[] ev1x = factory
3055 .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)));",
3057 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
3058 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3061 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3064 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3065 final Phylogeny[] ev_bx = factory
3066 .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",
3068 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
3069 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3072 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3075 final Phylogeny[] t2 = factory
3076 .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);",
3078 final Phylogeny[] ev2 = factory
3079 .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);",
3081 for( final Phylogeny target : t2 ) {
3082 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
3084 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
3085 new NHXParser() )[ 0 ];
3086 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
3087 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
3088 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3091 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
3094 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3098 catch ( final Exception e ) {
3099 e.printStackTrace();
3105 private static boolean testCopyOfNodeData() {
3107 final PhylogenyNode n1 = PhylogenyNode
3108 .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]" );
3109 final PhylogenyNode n2 = n1.copyNodeData();
3110 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3114 catch ( final Exception e ) {
3115 e.printStackTrace();
3121 private static boolean testCreateBalancedPhylogeny() {
3123 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3124 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3127 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3130 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3131 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3134 if ( p1.getNumberOfExternalNodes() != 100 ) {
3138 catch ( final Exception e ) {
3139 e.printStackTrace();
3145 private static boolean testCreateUriForSeqWeb() {
3147 final PhylogenyNode n = new PhylogenyNode();
3148 n.setName( "tr|B3RJ64" );
3149 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3152 n.setName( "B0LM41_HUMAN" );
3153 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3156 n.setName( "NP_001025424" );
3157 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3160 n.setName( "_NM_001030253-" );
3161 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3164 n.setName( "XM_002122186" );
3165 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3168 n.setName( "dgh_AAA34956_gdg" );
3169 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3172 n.setName( "AAA34956" );
3173 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3176 n.setName( "GI:394892" );
3177 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3178 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3181 n.setName( "gi_394892" );
3182 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3183 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3186 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3187 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3188 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3191 n.setName( "P12345" );
3192 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3193 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3196 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3197 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3198 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3202 catch ( final Exception e ) {
3203 e.printStackTrace( System.out );
3209 private static boolean testDataObjects() {
3211 final Confidence s0 = new Confidence();
3212 final Confidence s1 = new Confidence();
3213 if ( !s0.isEqual( s1 ) ) {
3216 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3217 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3218 if ( s2.isEqual( s1 ) ) {
3221 if ( !s2.isEqual( s3 ) ) {
3224 final Confidence s4 = ( Confidence ) s3.copy();
3225 if ( !s4.isEqual( s3 ) ) {
3232 final Taxonomy t1 = new Taxonomy();
3233 final Taxonomy t2 = new Taxonomy();
3234 final Taxonomy t3 = new Taxonomy();
3235 final Taxonomy t4 = new Taxonomy();
3236 final Taxonomy t5 = new Taxonomy();
3237 t1.setIdentifier( new Identifier( "ecoli" ) );
3238 t1.setTaxonomyCode( "ECOLI" );
3239 t1.setScientificName( "E. coli" );
3240 t1.setCommonName( "coli" );
3241 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3242 if ( !t1.isEqual( t0 ) ) {
3245 t2.setIdentifier( new Identifier( "ecoli" ) );
3246 t2.setTaxonomyCode( "OTHER" );
3247 t2.setScientificName( "what" );
3248 t2.setCommonName( "something" );
3249 if ( !t1.isEqual( t2 ) ) {
3252 t2.setIdentifier( new Identifier( "nemve" ) );
3253 if ( t1.isEqual( t2 ) ) {
3256 t1.setIdentifier( null );
3257 t3.setTaxonomyCode( "ECOLI" );
3258 t3.setScientificName( "what" );
3259 t3.setCommonName( "something" );
3260 if ( !t1.isEqual( t3 ) ) {
3263 t1.setIdentifier( null );
3264 t1.setTaxonomyCode( "" );
3265 t4.setScientificName( "E. ColI" );
3266 t4.setCommonName( "something" );
3267 if ( !t1.isEqual( t4 ) ) {
3270 t4.setScientificName( "B. subtilis" );
3271 t4.setCommonName( "something" );
3272 if ( t1.isEqual( t4 ) ) {
3275 t1.setIdentifier( null );
3276 t1.setTaxonomyCode( "" );
3277 t1.setScientificName( "" );
3278 t5.setCommonName( "COLI" );
3279 if ( !t1.isEqual( t5 ) ) {
3282 t5.setCommonName( "vibrio" );
3283 if ( t1.isEqual( t5 ) ) {
3288 final Identifier id0 = new Identifier( "123", "pfam" );
3289 final Identifier id1 = ( Identifier ) id0.copy();
3290 if ( !id1.isEqual( id1 ) ) {
3293 if ( !id1.isEqual( id0 ) ) {
3296 if ( !id0.isEqual( id1 ) ) {
3303 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3304 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3305 if ( !pd1.isEqual( pd1 ) ) {
3308 if ( !pd1.isEqual( pd0 ) ) {
3313 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3314 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3315 if ( !pd3.isEqual( pd3 ) ) {
3318 if ( !pd2.isEqual( pd3 ) ) {
3321 if ( !pd0.isEqual( pd3 ) ) {
3326 // DomainArchitecture
3327 // ------------------
3328 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3329 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3330 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3331 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3332 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3333 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3338 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3339 if ( ds0.getNumberOfDomains() != 4 ) {
3342 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3343 if ( !ds0.isEqual( ds0 ) ) {
3346 if ( !ds0.isEqual( ds1 ) ) {
3349 if ( ds1.getNumberOfDomains() != 4 ) {
3352 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3357 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3358 if ( ds0.isEqual( ds2 ) ) {
3364 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3365 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3366 System.out.println( ds3.toNHX() );
3369 if ( ds3.getNumberOfDomains() != 3 ) {
3374 final Event e1 = new Event( Event.EventType.fusion );
3375 if ( e1.isDuplication() ) {
3378 if ( !e1.isFusion() ) {
3381 if ( !e1.asText().toString().equals( "fusion" ) ) {
3384 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3387 final Event e11 = new Event( Event.EventType.fusion );
3388 if ( !e11.isEqual( e1 ) ) {
3391 if ( !e11.toNHX().toString().equals( "" ) ) {
3394 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3395 if ( e2.isDuplication() ) {
3398 if ( !e2.isSpeciationOrDuplication() ) {
3401 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3404 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3407 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3410 if ( e11.isEqual( e2 ) ) {
3413 final Event e2c = ( Event ) e2.copy();
3414 if ( !e2c.isEqual( e2 ) ) {
3417 Event e3 = new Event( 1, 2, 3 );
3418 if ( e3.isDuplication() ) {
3421 if ( e3.isSpeciation() ) {
3424 if ( e3.isGeneLoss() ) {
3427 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3430 final Event e3c = ( Event ) e3.copy();
3431 final Event e3cc = ( Event ) e3c.copy();
3432 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3436 if ( !e3c.isEqual( e3cc ) ) {
3439 Event e4 = new Event( 1, 2, 3 );
3440 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3443 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3446 final Event e4c = ( Event ) e4.copy();
3448 final Event e4cc = ( Event ) e4c.copy();
3449 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3452 if ( !e4c.isEqual( e4cc ) ) {
3455 final Event e5 = new Event();
3456 if ( !e5.isUnassigned() ) {
3459 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3462 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3465 final Event e6 = new Event( 1, 0, 0 );
3466 if ( !e6.asText().toString().equals( "duplication" ) ) {
3469 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3472 final Event e7 = new Event( 0, 1, 0 );
3473 if ( !e7.asText().toString().equals( "speciation" ) ) {
3476 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3479 final Event e8 = new Event( 0, 0, 1 );
3480 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3483 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3487 catch ( final Exception e ) {
3488 e.printStackTrace( System.out );
3494 private static boolean testDeletionOfExternalNodes() {
3496 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3497 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3498 final PhylogenyWriter w = new PhylogenyWriter();
3499 if ( t0.isEmpty() ) {
3502 if ( t0.getNumberOfExternalNodes() != 1 ) {
3505 t0.deleteSubtree( t0.getNode( "A" ), false );
3506 if ( t0.getNumberOfExternalNodes() != 0 ) {
3509 if ( !t0.isEmpty() ) {
3512 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3513 if ( t1.getNumberOfExternalNodes() != 2 ) {
3516 t1.deleteSubtree( t1.getNode( "A" ), false );
3517 if ( t1.getNumberOfExternalNodes() != 1 ) {
3520 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3523 t1.deleteSubtree( t1.getNode( "B" ), false );
3524 if ( t1.getNumberOfExternalNodes() != 1 ) {
3527 t1.deleteSubtree( t1.getNode( "r" ), false );
3528 if ( !t1.isEmpty() ) {
3531 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3532 if ( t2.getNumberOfExternalNodes() != 3 ) {
3535 t2.deleteSubtree( t2.getNode( "B" ), false );
3536 if ( t2.getNumberOfExternalNodes() != 2 ) {
3539 t2.toNewHampshireX();
3540 PhylogenyNode n = t2.getNode( "A" );
3541 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3544 t2.deleteSubtree( t2.getNode( "A" ), false );
3545 if ( t2.getNumberOfExternalNodes() != 2 ) {
3548 t2.deleteSubtree( t2.getNode( "C" ), true );
3549 if ( t2.getNumberOfExternalNodes() != 1 ) {
3552 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3553 if ( t3.getNumberOfExternalNodes() != 4 ) {
3556 t3.deleteSubtree( t3.getNode( "B" ), true );
3557 if ( t3.getNumberOfExternalNodes() != 3 ) {
3560 n = t3.getNode( "A" );
3561 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3564 n = n.getNextExternalNode();
3565 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3568 t3.deleteSubtree( t3.getNode( "A" ), true );
3569 if ( t3.getNumberOfExternalNodes() != 2 ) {
3572 n = t3.getNode( "C" );
3573 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3576 t3.deleteSubtree( t3.getNode( "C" ), true );
3577 if ( t3.getNumberOfExternalNodes() != 1 ) {
3580 t3.deleteSubtree( t3.getNode( "D" ), true );
3581 if ( t3.getNumberOfExternalNodes() != 0 ) {
3584 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3585 if ( t4.getNumberOfExternalNodes() != 6 ) {
3588 t4.deleteSubtree( t4.getNode( "B2" ), true );
3589 if ( t4.getNumberOfExternalNodes() != 5 ) {
3592 String s = w.toNewHampshire( t4, true ).toString();
3593 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3596 t4.deleteSubtree( t4.getNode( "B11" ), true );
3597 if ( t4.getNumberOfExternalNodes() != 4 ) {
3600 t4.deleteSubtree( t4.getNode( "C" ), true );
3601 if ( t4.getNumberOfExternalNodes() != 3 ) {
3604 n = t4.getNode( "A" );
3605 n = n.getNextExternalNode();
3606 if ( !n.getName().equals( "B12" ) ) {
3609 n = n.getNextExternalNode();
3610 if ( !n.getName().equals( "D" ) ) {
3613 s = w.toNewHampshire( t4, true ).toString();
3614 if ( !s.equals( "((A,B12),D);" ) ) {
3617 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3618 t5.deleteSubtree( t5.getNode( "A" ), true );
3619 if ( t5.getNumberOfExternalNodes() != 5 ) {
3622 s = w.toNewHampshire( t5, true ).toString();
3623 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3626 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3627 t6.deleteSubtree( t6.getNode( "B11" ), true );
3628 if ( t6.getNumberOfExternalNodes() != 5 ) {
3631 s = w.toNewHampshire( t6, false ).toString();
3632 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3635 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3636 t7.deleteSubtree( t7.getNode( "B12" ), true );
3637 if ( t7.getNumberOfExternalNodes() != 5 ) {
3640 s = w.toNewHampshire( t7, true ).toString();
3641 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3644 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3645 t8.deleteSubtree( t8.getNode( "B2" ), true );
3646 if ( t8.getNumberOfExternalNodes() != 5 ) {
3649 s = w.toNewHampshire( t8, false ).toString();
3650 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3653 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3654 t9.deleteSubtree( t9.getNode( "C" ), true );
3655 if ( t9.getNumberOfExternalNodes() != 5 ) {
3658 s = w.toNewHampshire( t9, true ).toString();
3659 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3662 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3663 t10.deleteSubtree( t10.getNode( "D" ), true );
3664 if ( t10.getNumberOfExternalNodes() != 5 ) {
3667 s = w.toNewHampshire( t10, true ).toString();
3668 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3671 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3672 t11.deleteSubtree( t11.getNode( "A" ), true );
3673 if ( t11.getNumberOfExternalNodes() != 2 ) {
3676 s = w.toNewHampshire( t11, true ).toString();
3677 if ( !s.equals( "(B,C);" ) ) {
3680 t11.deleteSubtree( t11.getNode( "C" ), true );
3681 if ( t11.getNumberOfExternalNodes() != 1 ) {
3684 s = w.toNewHampshire( t11, false ).toString();
3685 if ( !s.equals( "B;" ) ) {
3688 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3689 t12.deleteSubtree( t12.getNode( "B2" ), true );
3690 if ( t12.getNumberOfExternalNodes() != 8 ) {
3693 s = w.toNewHampshire( t12, true ).toString();
3694 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3697 t12.deleteSubtree( t12.getNode( "B3" ), true );
3698 if ( t12.getNumberOfExternalNodes() != 7 ) {
3701 s = w.toNewHampshire( t12, true ).toString();
3702 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3705 t12.deleteSubtree( t12.getNode( "C3" ), true );
3706 if ( t12.getNumberOfExternalNodes() != 6 ) {
3709 s = w.toNewHampshire( t12, true ).toString();
3710 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3713 t12.deleteSubtree( t12.getNode( "A1" ), true );
3714 if ( t12.getNumberOfExternalNodes() != 5 ) {
3717 s = w.toNewHampshire( t12, true ).toString();
3718 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3721 t12.deleteSubtree( t12.getNode( "B1" ), true );
3722 if ( t12.getNumberOfExternalNodes() != 4 ) {
3725 s = w.toNewHampshire( t12, true ).toString();
3726 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3729 t12.deleteSubtree( t12.getNode( "A3" ), true );
3730 if ( t12.getNumberOfExternalNodes() != 3 ) {
3733 s = w.toNewHampshire( t12, true ).toString();
3734 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3737 t12.deleteSubtree( t12.getNode( "A2" ), true );
3738 if ( t12.getNumberOfExternalNodes() != 2 ) {
3741 s = w.toNewHampshire( t12, true ).toString();
3742 if ( !s.equals( "(C1,C2);" ) ) {
3745 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3746 t13.deleteSubtree( t13.getNode( "D" ), true );
3747 if ( t13.getNumberOfExternalNodes() != 4 ) {
3750 s = w.toNewHampshire( t13, true ).toString();
3751 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3754 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3755 t14.deleteSubtree( t14.getNode( "E" ), true );
3756 if ( t14.getNumberOfExternalNodes() != 5 ) {
3759 s = w.toNewHampshire( t14, true ).toString();
3760 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3763 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3764 t15.deleteSubtree( t15.getNode( "B2" ), true );
3765 if ( t15.getNumberOfExternalNodes() != 11 ) {
3768 t15.deleteSubtree( t15.getNode( "B1" ), true );
3769 if ( t15.getNumberOfExternalNodes() != 10 ) {
3772 t15.deleteSubtree( t15.getNode( "B3" ), true );
3773 if ( t15.getNumberOfExternalNodes() != 9 ) {
3776 t15.deleteSubtree( t15.getNode( "B4" ), true );
3777 if ( t15.getNumberOfExternalNodes() != 8 ) {
3780 t15.deleteSubtree( t15.getNode( "A1" ), true );
3781 if ( t15.getNumberOfExternalNodes() != 7 ) {
3784 t15.deleteSubtree( t15.getNode( "C4" ), true );
3785 if ( t15.getNumberOfExternalNodes() != 6 ) {
3789 catch ( final Exception e ) {
3790 e.printStackTrace( System.out );
3796 private static boolean testDescriptiveStatistics() {
3798 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3799 dss1.addValue( 82 );
3800 dss1.addValue( 78 );
3801 dss1.addValue( 70 );
3802 dss1.addValue( 58 );
3803 dss1.addValue( 42 );
3804 if ( dss1.getN() != 5 ) {
3807 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3810 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3813 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3816 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3819 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3822 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3825 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3828 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3831 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3834 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3837 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3840 dss1.addValue( 123 );
3841 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3844 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3847 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3850 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3851 dss2.addValue( -1.85 );
3852 dss2.addValue( 57.5 );
3853 dss2.addValue( 92.78 );
3854 dss2.addValue( 57.78 );
3855 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3858 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3861 final double[] a = dss2.getDataAsDoubleArray();
3862 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3865 dss2.addValue( -100 );
3866 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3869 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3872 final double[] ds = new double[ 14 ];
3887 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3888 if ( bins.length != 4 ) {
3891 if ( bins[ 0 ] != 2 ) {
3894 if ( bins[ 1 ] != 3 ) {
3897 if ( bins[ 2 ] != 4 ) {
3900 if ( bins[ 3 ] != 5 ) {
3903 final double[] ds1 = new double[ 9 ];
3913 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3914 if ( bins1.length != 4 ) {
3917 if ( bins1[ 0 ] != 2 ) {
3920 if ( bins1[ 1 ] != 3 ) {
3923 if ( bins1[ 2 ] != 0 ) {
3926 if ( bins1[ 3 ] != 4 ) {
3929 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3930 if ( bins1_1.length != 3 ) {
3933 if ( bins1_1[ 0 ] != 3 ) {
3936 if ( bins1_1[ 1 ] != 2 ) {
3939 if ( bins1_1[ 2 ] != 4 ) {
3942 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3943 if ( bins1_2.length != 3 ) {
3946 if ( bins1_2[ 0 ] != 2 ) {
3949 if ( bins1_2[ 1 ] != 2 ) {
3952 if ( bins1_2[ 2 ] != 2 ) {
3955 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3969 dss3.addValue( 10 );
3970 dss3.addValue( 10 );
3971 dss3.addValue( 10 );
3972 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3973 histo.toStringBuffer( 10, '=', 40, 5 );
3974 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3976 catch ( final Exception e ) {
3977 e.printStackTrace( System.out );
3983 private static boolean testDir( final String file ) {
3985 final File f = new File( file );
3986 if ( !f.exists() ) {
3989 if ( !f.isDirectory() ) {
3992 if ( !f.canRead() ) {
3996 catch ( final Exception e ) {
4002 private static boolean testEbiEntryRetrieval() {
4004 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
4005 if ( !entry.getAccession().equals( "AAK41263" ) ) {
4006 System.out.println( entry.getAccession() );
4009 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
4010 System.out.println( entry.getTaxonomyScientificName() );
4013 if ( !entry.getSequenceName()
4014 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
4015 System.out.println( entry.getSequenceName() );
4018 if ( !entry.getGeneName().equals( "treX-like" ) ) {
4019 System.out.println( entry.getGeneName() );
4022 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
4023 System.out.println( entry.getTaxonomyIdentifier() );
4026 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
4027 System.out.println( entry.getAnnotations().first().getRefValue() );
4030 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
4031 System.out.println( entry.getAnnotations().first().getRefSource() );
4034 if ( entry.getCrossReferences().size() != 5 ) {
4037 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
4038 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
4041 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
4042 System.out.println( entry1.getTaxonomyScientificName() );
4045 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
4046 System.out.println( entry1.getSequenceName() );
4049 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
4050 System.out.println( entry1.getTaxonomyIdentifier() );
4053 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
4054 System.out.println( entry1.getGeneName() );
4057 if ( entry1.getCrossReferences().size() != 6 ) {
4060 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
4061 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
4064 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4065 System.out.println( entry2.getTaxonomyScientificName() );
4068 if ( !entry2.getSequenceName()
4069 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
4070 System.out.println( entry2.getSequenceName() );
4073 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
4074 System.out.println( entry2.getTaxonomyIdentifier() );
4077 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
4078 System.out.println( entry2.getGeneName() );
4081 if ( entry2.getCrossReferences().size() != 3 ) {
4085 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
4086 if ( !entry3.getAccession().equals( "HM043801" ) ) {
4089 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
4090 System.out.println( entry3.getTaxonomyScientificName() );
4093 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4094 System.out.println( entry3.getSequenceName() );
4097 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4098 System.out.println( entry3.getTaxonomyIdentifier() );
4101 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4102 System.out.println( entry3.getSequenceSymbol() );
4105 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4108 if ( entry3.getCrossReferences().size() < 7 ) {
4111 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4112 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4115 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4116 System.out.println( entry4.getTaxonomyScientificName() );
4119 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4120 System.out.println( entry4.getSequenceName() );
4123 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4124 System.out.println( entry4.getTaxonomyIdentifier() );
4127 if ( !entry4.getGeneName().equals( "ras" ) ) {
4128 System.out.println( entry4.getGeneName() );
4131 // if ( !entry4.getChromosome().equals( "ras" ) ) {
4132 // System.out.println( entry4.getChromosome() );
4135 // if ( !entry4.getMap().equals( "ras" ) ) {
4136 // System.out.println( entry4.getMap() );
4142 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
4143 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
4146 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4147 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4150 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4151 System.out.println( entry5.getTaxonomyScientificName() );
4154 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4155 System.out.println( entry5.getSequenceName() );
4158 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4159 System.out.println( entry5.getTaxonomyIdentifier() );
4163 catch ( final IOException e ) {
4164 System.out.println();
4165 System.out.println( "the following might be due to absence internet connection:" );
4166 e.printStackTrace( System.out );
4169 catch ( final Exception e ) {
4170 e.printStackTrace();
4176 private static boolean testExternalNodeRelatedMethods() {
4178 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4179 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4180 PhylogenyNode n = t1.getNode( "A" );
4181 n = n.getNextExternalNode();
4182 if ( !n.getName().equals( "B" ) ) {
4185 n = n.getNextExternalNode();
4186 if ( !n.getName().equals( "C" ) ) {
4189 n = n.getNextExternalNode();
4190 if ( !n.getName().equals( "D" ) ) {
4193 n = t1.getNode( "B" );
4194 while ( !n.isLastExternalNode() ) {
4195 n = n.getNextExternalNode();
4197 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4198 n = t2.getNode( "A" );
4199 n = n.getNextExternalNode();
4200 if ( !n.getName().equals( "B" ) ) {
4203 n = n.getNextExternalNode();
4204 if ( !n.getName().equals( "C" ) ) {
4207 n = n.getNextExternalNode();
4208 if ( !n.getName().equals( "D" ) ) {
4211 n = t2.getNode( "B" );
4212 while ( !n.isLastExternalNode() ) {
4213 n = n.getNextExternalNode();
4215 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4216 n = t3.getNode( "A" );
4217 n = n.getNextExternalNode();
4218 if ( !n.getName().equals( "B" ) ) {
4221 n = n.getNextExternalNode();
4222 if ( !n.getName().equals( "C" ) ) {
4225 n = n.getNextExternalNode();
4226 if ( !n.getName().equals( "D" ) ) {
4229 n = n.getNextExternalNode();
4230 if ( !n.getName().equals( "E" ) ) {
4233 n = n.getNextExternalNode();
4234 if ( !n.getName().equals( "F" ) ) {
4237 n = n.getNextExternalNode();
4238 if ( !n.getName().equals( "G" ) ) {
4241 n = n.getNextExternalNode();
4242 if ( !n.getName().equals( "H" ) ) {
4245 n = t3.getNode( "B" );
4246 while ( !n.isLastExternalNode() ) {
4247 n = n.getNextExternalNode();
4249 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4250 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4251 final PhylogenyNode node = iter.next();
4253 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4254 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4255 final PhylogenyNode node = iter.next();
4257 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4258 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4259 if ( !iter.next().getName().equals( "A" ) ) {
4262 if ( !iter.next().getName().equals( "B" ) ) {
4265 if ( !iter.next().getName().equals( "C" ) ) {
4268 if ( !iter.next().getName().equals( "D" ) ) {
4271 if ( !iter.next().getName().equals( "E" ) ) {
4274 if ( !iter.next().getName().equals( "F" ) ) {
4277 if ( iter.hasNext() ) {
4281 catch ( final Exception e ) {
4282 e.printStackTrace( System.out );
4288 private static boolean testExtractSNFromNodeName() {
4290 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4293 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4296 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4299 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4300 .equals( "Mus musculus musculus" ) ) {
4303 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4304 .equals( "Mus musculus musculus" ) ) {
4307 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4308 .equals( "Mus musculus musculus" ) ) {
4311 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4312 .equals( "Mus musculus musculus" ) ) {
4315 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4318 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4319 .equals( "Mus musculus musculus" ) ) {
4322 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4323 .equals( "Mus musculus musculus" ) ) {
4326 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4329 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4332 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4335 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4338 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4339 .equals( "Mus musculus musculus" ) ) {
4342 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4345 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4348 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4351 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4354 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4357 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4360 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4363 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4366 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4367 .equals( "Mus musculus" ) ) {
4370 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4371 .equals( "Mus musculus" ) ) {
4374 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4377 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4378 .equals( "Mus musculus musculus" ) ) {
4381 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4382 .equals( "Mus musculus musculus" ) ) {
4385 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4386 .equals( "Mus musculus musculus" ) ) {
4389 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4392 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4393 .equals( "Pilostyles mexicana" ) ) {
4396 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4397 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4400 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4401 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4404 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4405 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4408 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4409 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4412 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4413 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4416 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4417 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4420 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4421 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4424 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4425 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4428 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4429 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4432 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4433 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4436 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4437 .equals( "Escherichia coli (strain K12)" ) ) {
4440 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4441 .equals( "Escherichia coli (strain K12)" ) ) {
4444 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4445 .equals( "Escherichia coli (str. K12)" ) ) {
4448 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4449 .equals( "Escherichia coli (str. K12)" ) ) {
4452 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4453 .equals( "Escherichia coli (str. K12)" ) ) {
4456 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4457 .equals( "Escherichia coli (var. K12)" ) ) {
4460 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4461 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4464 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4465 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4469 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4470 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4473 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4474 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4478 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4479 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4482 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4483 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4486 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4487 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4490 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4493 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4496 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4499 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4500 .equals( "Macrocera sp." ) ) {
4503 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4506 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4507 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4510 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4511 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4514 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4515 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4518 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4519 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4523 catch ( final Exception e ) {
4524 e.printStackTrace( System.out );
4530 private static boolean testExtractTaxonomyDataFromNodeName() {
4532 PhylogenyNode n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN" );
4533 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4536 n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN~1-2" );
4537 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4540 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN" );
4541 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4544 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN|" );
4545 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4548 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN~12" );
4549 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4552 n = new PhylogenyNode( "HNRPR_HUMAN" );
4553 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4556 n = new PhylogenyNode( "HNRPR_HUMAN_X" );
4557 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4561 catch ( final Exception e ) {
4562 e.printStackTrace( System.out );
4568 private static boolean testExtractTaxonomyCodeFromNodeName() {
4570 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4573 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4574 .equals( "SOYBN" ) ) {
4577 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4578 .equals( "ARATH" ) ) {
4581 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4582 .equals( "ARATH" ) ) {
4585 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4588 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4591 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4594 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4595 .equals( "SOYBN" ) ) {
4598 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4599 .equals( "SOYBN" ) ) {
4602 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4603 .equals( "SOYBN" ) ) {
4606 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4607 .equals( "SOYBN" ) ) {
4610 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4611 .equals( "SOYBN" ) ) {
4614 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4615 .equals( "SOYBN" ) ) {
4618 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4619 .equals( "SOYBN" ) ) {
4622 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4623 .equals( "SOYBN" ) ) {
4626 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4629 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4630 .equals( "SOYBN" ) ) {
4633 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4634 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4637 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4638 .equals( "9YX45" ) ) {
4641 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4642 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4643 .equals( "MOUSE" ) ) {
4646 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4647 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4648 .equals( "MOUSE" ) ) {
4651 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4652 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4653 .equals( "MOUSE" ) ) {
4656 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4657 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4660 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4661 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4664 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4665 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4668 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4669 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4672 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4673 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4676 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4677 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4680 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4681 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4684 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4685 .equals( "RAT" ) ) {
4688 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4689 .equals( "PIG" ) ) {
4693 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4694 .equals( "MOUSE" ) ) {
4697 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4698 .equals( "MOUSE" ) ) {
4701 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4705 catch ( final Exception e ) {
4706 e.printStackTrace( System.out );
4712 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4714 PhylogenyNode n = new PhylogenyNode();
4715 n.setName( "tr|B3RJ64" );
4716 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4719 n.setName( "tr.B3RJ64" );
4720 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4723 n.setName( "tr=B3RJ64" );
4724 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4727 n.setName( "tr-B3RJ64" );
4728 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4731 n.setName( "tr/B3RJ64" );
4732 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4735 n.setName( "tr\\B3RJ64" );
4736 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4739 n.setName( "tr_B3RJ64" );
4740 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4743 n.setName( " tr|B3RJ64 " );
4744 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4747 n.setName( "-tr|B3RJ64-" );
4748 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4751 n.setName( "-tr=B3RJ64-" );
4752 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4755 n.setName( "_tr=B3RJ64_" );
4756 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4759 n.setName( " tr_tr|B3RJ64_sp|123 " );
4760 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4763 n.setName( "B3RJ64" );
4764 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4767 n.setName( "sp|B3RJ64" );
4768 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4771 n.setName( "sp|B3RJ64C" );
4772 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4775 n.setName( "sp B3RJ64" );
4776 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4779 n.setName( "sp|B3RJ6X" );
4780 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4783 n.setName( "sp|B3RJ6" );
4784 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4787 n.setName( "K1PYK7_CRAGI" );
4788 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4791 n.setName( "K1PYK7_PEA" );
4792 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4795 n.setName( "K1PYK7_RAT" );
4796 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4799 n.setName( "K1PYK7_PIG" );
4800 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4803 n.setName( "~K1PYK7_PIG~" );
4804 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4807 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4808 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4811 n.setName( "K1PYKX_CRAGI" );
4812 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4815 n.setName( "XXXXX_CRAGI" );
4816 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4819 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4820 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4823 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4824 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4827 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4828 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4831 n = new PhylogenyNode();
4832 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4833 seq.setSymbol( "K1PYK7_CRAGI" );
4834 n.getNodeData().addSequence( seq );
4835 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4838 seq.setSymbol( "tr|B3RJ64" );
4839 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4842 n = new PhylogenyNode();
4843 seq = new org.forester.phylogeny.data.Sequence();
4844 seq.setName( "K1PYK7_CRAGI" );
4845 n.getNodeData().addSequence( seq );
4846 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4849 seq.setName( "tr|B3RJ64" );
4850 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4853 n = new PhylogenyNode();
4854 seq = new org.forester.phylogeny.data.Sequence();
4855 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4856 n.getNodeData().addSequence( seq );
4857 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4860 n = new PhylogenyNode();
4861 seq = new org.forester.phylogeny.data.Sequence();
4862 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4863 n.getNodeData().addSequence( seq );
4864 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4868 n = new PhylogenyNode();
4869 n.setName( "ACP19736" );
4870 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4873 n = new PhylogenyNode();
4874 n.setName( "|ACP19736|" );
4875 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4879 catch ( final Exception e ) {
4880 e.printStackTrace( System.out );
4886 private static boolean testFastaParser() {
4888 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4891 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4894 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4895 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4898 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4901 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4904 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPROWXERR" ) ) {
4907 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4910 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4914 catch ( final Exception e ) {
4915 e.printStackTrace();
4921 private static boolean testGenbankAccessorParsing() {
4922 //The format for GenBank Accession numbers are:
4923 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4924 //Protein: 3 letters + 5 numerals
4925 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4926 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4929 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4932 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4935 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4938 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4941 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4944 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4947 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4950 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4953 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4956 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4959 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4962 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4965 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4971 private static boolean testGeneralMsaParser() {
4973 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4974 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4975 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4976 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4977 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4978 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4979 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4980 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4981 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4984 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4987 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4990 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4993 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4996 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4999 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5002 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5005 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5008 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5011 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5014 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5017 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
5018 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5021 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5024 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5027 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
5028 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
5031 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
5034 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
5037 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
5038 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5041 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5044 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5048 catch ( final Exception e ) {
5049 e.printStackTrace();
5055 private static boolean testGeneralTable() {
5057 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
5058 t0.setValue( 3, 2, "23" );
5059 t0.setValue( 10, 1, "error" );
5060 t0.setValue( 10, 1, "110" );
5061 t0.setValue( 9, 1, "19" );
5062 t0.setValue( 1, 10, "101" );
5063 t0.setValue( 10, 10, "1010" );
5064 t0.setValue( 100, 10, "10100" );
5065 t0.setValue( 0, 0, "00" );
5066 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
5069 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
5072 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
5075 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
5078 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
5081 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
5084 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
5087 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
5090 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
5093 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
5094 t1.setValue( "3", "2", "23" );
5095 t1.setValue( "10", "1", "error" );
5096 t1.setValue( "10", "1", "110" );
5097 t1.setValue( "9", "1", "19" );
5098 t1.setValue( "1", "10", "101" );
5099 t1.setValue( "10", "10", "1010" );
5100 t1.setValue( "100", "10", "10100" );
5101 t1.setValue( "0", "0", "00" );
5102 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
5103 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
5106 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
5109 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
5112 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
5115 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
5118 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
5121 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
5124 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
5127 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5130 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5134 catch ( final Exception e ) {
5135 e.printStackTrace( System.out );
5141 private static boolean testGetDistance() {
5143 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5144 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",
5145 new NHXParser() )[ 0 ];
5146 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5149 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5152 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5155 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5158 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5161 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5164 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5167 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5170 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5173 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5176 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5179 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5182 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5185 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5188 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5191 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5194 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5197 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5200 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5203 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5206 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5209 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5212 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5215 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5218 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5221 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5224 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5227 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5230 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5233 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5236 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5239 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",
5240 new NHXParser() )[ 0 ];
5241 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5244 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5247 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5250 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5253 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5256 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5259 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5262 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5265 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5268 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5271 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5275 catch ( final Exception e ) {
5276 e.printStackTrace( System.out );
5282 private static boolean testGetLCA() {
5284 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5285 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5286 new NHXParser() )[ 0 ];
5287 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5288 if ( !A.getName().equals( "A" ) ) {
5291 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5292 if ( !gh.getName().equals( "gh" ) ) {
5295 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5296 if ( !ab.getName().equals( "ab" ) ) {
5299 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5300 if ( !ab2.getName().equals( "ab" ) ) {
5303 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5304 if ( !gh2.getName().equals( "gh" ) ) {
5307 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5308 if ( !gh3.getName().equals( "gh" ) ) {
5311 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5312 if ( !abc.getName().equals( "abc" ) ) {
5315 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5316 if ( !abc2.getName().equals( "abc" ) ) {
5319 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5320 if ( !abcd.getName().equals( "abcd" ) ) {
5323 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5324 if ( !abcd2.getName().equals( "abcd" ) ) {
5327 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5328 if ( !abcdef.getName().equals( "abcdef" ) ) {
5331 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5332 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5335 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5336 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5339 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5340 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5343 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5344 if ( !abcde.getName().equals( "abcde" ) ) {
5347 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5348 if ( !abcde2.getName().equals( "abcde" ) ) {
5351 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5352 if ( !r.getName().equals( "abcdefgh" ) ) {
5355 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5356 if ( !r2.getName().equals( "abcdefgh" ) ) {
5359 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5360 if ( !r3.getName().equals( "abcdefgh" ) ) {
5363 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5364 if ( !abcde3.getName().equals( "abcde" ) ) {
5367 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5368 if ( !abcde4.getName().equals( "abcde" ) ) {
5371 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5372 if ( !ab3.getName().equals( "ab" ) ) {
5375 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5376 if ( !ab4.getName().equals( "ab" ) ) {
5379 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5380 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5381 if ( !cd.getName().equals( "cd" ) ) {
5384 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5385 if ( !cd2.getName().equals( "cd" ) ) {
5388 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5389 if ( !cde.getName().equals( "cde" ) ) {
5392 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5393 if ( !cde2.getName().equals( "cde" ) ) {
5396 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5397 if ( !cdef.getName().equals( "cdef" ) ) {
5400 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5401 if ( !cdef2.getName().equals( "cdef" ) ) {
5404 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5405 if ( !cdef3.getName().equals( "cdef" ) ) {
5408 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5409 if ( !rt.getName().equals( "r" ) ) {
5412 final Phylogeny p3 = factory
5413 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5414 new NHXParser() )[ 0 ];
5415 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5416 if ( !bc_3.getName().equals( "bc" ) ) {
5419 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5420 if ( !ac_3.getName().equals( "abc" ) ) {
5423 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5424 if ( !ad_3.getName().equals( "abcde" ) ) {
5427 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5428 if ( !af_3.getName().equals( "abcdef" ) ) {
5431 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5432 if ( !ag_3.getName().equals( "" ) ) {
5435 if ( !ag_3.isRoot() ) {
5438 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5439 if ( !al_3.getName().equals( "" ) ) {
5442 if ( !al_3.isRoot() ) {
5445 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5446 if ( !kl_3.getName().equals( "" ) ) {
5449 if ( !kl_3.isRoot() ) {
5452 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5453 if ( !fl_3.getName().equals( "" ) ) {
5456 if ( !fl_3.isRoot() ) {
5459 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5460 if ( !gk_3.getName().equals( "ghijk" ) ) {
5463 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5464 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5465 if ( !r_4.getName().equals( "r" ) ) {
5468 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5469 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5470 if ( !r_5.getName().equals( "root" ) ) {
5473 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5474 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5475 if ( !r_6.getName().equals( "rot" ) ) {
5478 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5479 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5480 if ( !r_7.getName().equals( "rott" ) ) {
5484 catch ( final Exception e ) {
5485 e.printStackTrace( System.out );
5491 private static boolean testGetLCA2() {
5493 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5494 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5495 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5496 PhylogenyMethods.preOrderReId( p_a );
5497 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5498 p_a.getNode( "a" ) );
5499 if ( !p_a_1.getName().equals( "a" ) ) {
5502 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5503 PhylogenyMethods.preOrderReId( p_b );
5504 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5505 p_b.getNode( "a" ) );
5506 if ( !p_b_1.getName().equals( "b" ) ) {
5509 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5510 p_b.getNode( "b" ) );
5511 if ( !p_b_2.getName().equals( "b" ) ) {
5514 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5515 PhylogenyMethods.preOrderReId( p_c );
5516 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5517 p_c.getNode( "a" ) );
5518 if ( !p_c_1.getName().equals( "b" ) ) {
5521 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5522 p_c.getNode( "c" ) );
5523 if ( !p_c_2.getName().equals( "c" ) ) {
5524 System.out.println( p_c_2.getName() );
5528 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5529 p_c.getNode( "b" ) );
5530 if ( !p_c_3.getName().equals( "b" ) ) {
5533 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5534 p_c.getNode( "a" ) );
5535 if ( !p_c_4.getName().equals( "c" ) ) {
5538 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5539 new NHXParser() )[ 0 ];
5540 PhylogenyMethods.preOrderReId( p1 );
5541 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5542 p1.getNode( "A" ) );
5543 if ( !A.getName().equals( "A" ) ) {
5546 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5547 p1.getNode( "gh" ) );
5548 if ( !gh.getName().equals( "gh" ) ) {
5551 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5552 p1.getNode( "B" ) );
5553 if ( !ab.getName().equals( "ab" ) ) {
5556 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5557 p1.getNode( "A" ) );
5558 if ( !ab2.getName().equals( "ab" ) ) {
5561 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5562 p1.getNode( "G" ) );
5563 if ( !gh2.getName().equals( "gh" ) ) {
5566 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5567 p1.getNode( "H" ) );
5568 if ( !gh3.getName().equals( "gh" ) ) {
5571 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5572 p1.getNode( "A" ) );
5573 if ( !abc.getName().equals( "abc" ) ) {
5576 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5577 p1.getNode( "C" ) );
5578 if ( !abc2.getName().equals( "abc" ) ) {
5581 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5582 p1.getNode( "D" ) );
5583 if ( !abcd.getName().equals( "abcd" ) ) {
5586 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5587 p1.getNode( "A" ) );
5588 if ( !abcd2.getName().equals( "abcd" ) ) {
5591 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5592 p1.getNode( "F" ) );
5593 if ( !abcdef.getName().equals( "abcdef" ) ) {
5596 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5597 p1.getNode( "A" ) );
5598 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5601 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5602 p1.getNode( "F" ) );
5603 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5606 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5607 p1.getNode( "ab" ) );
5608 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5611 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5612 p1.getNode( "E" ) );
5613 if ( !abcde.getName().equals( "abcde" ) ) {
5616 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5617 p1.getNode( "A" ) );
5618 if ( !abcde2.getName().equals( "abcde" ) ) {
5621 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5622 p1.getNode( "abcdefgh" ) );
5623 if ( !r.getName().equals( "abcdefgh" ) ) {
5626 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5627 p1.getNode( "H" ) );
5628 if ( !r2.getName().equals( "abcdefgh" ) ) {
5631 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5632 p1.getNode( "A" ) );
5633 if ( !r3.getName().equals( "abcdefgh" ) ) {
5636 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5637 p1.getNode( "abcde" ) );
5638 if ( !abcde3.getName().equals( "abcde" ) ) {
5641 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5642 p1.getNode( "E" ) );
5643 if ( !abcde4.getName().equals( "abcde" ) ) {
5646 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5647 p1.getNode( "B" ) );
5648 if ( !ab3.getName().equals( "ab" ) ) {
5651 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5652 p1.getNode( "ab" ) );
5653 if ( !ab4.getName().equals( "ab" ) ) {
5656 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5657 PhylogenyMethods.preOrderReId( p2 );
5658 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5659 p2.getNode( "d" ) );
5660 if ( !cd.getName().equals( "cd" ) ) {
5663 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5664 p2.getNode( "c" ) );
5665 if ( !cd2.getName().equals( "cd" ) ) {
5668 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5669 p2.getNode( "e" ) );
5670 if ( !cde.getName().equals( "cde" ) ) {
5673 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5674 p2.getNode( "c" ) );
5675 if ( !cde2.getName().equals( "cde" ) ) {
5678 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5679 p2.getNode( "f" ) );
5680 if ( !cdef.getName().equals( "cdef" ) ) {
5683 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5684 p2.getNode( "f" ) );
5685 if ( !cdef2.getName().equals( "cdef" ) ) {
5688 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5689 p2.getNode( "d" ) );
5690 if ( !cdef3.getName().equals( "cdef" ) ) {
5693 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5694 p2.getNode( "a" ) );
5695 if ( !rt.getName().equals( "r" ) ) {
5698 final Phylogeny p3 = factory
5699 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5700 new NHXParser() )[ 0 ];
5701 PhylogenyMethods.preOrderReId( p3 );
5702 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5703 p3.getNode( "c" ) );
5704 if ( !bc_3.getName().equals( "bc" ) ) {
5707 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5708 p3.getNode( "c" ) );
5709 if ( !ac_3.getName().equals( "abc" ) ) {
5712 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5713 p3.getNode( "d" ) );
5714 if ( !ad_3.getName().equals( "abcde" ) ) {
5717 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5718 p3.getNode( "f" ) );
5719 if ( !af_3.getName().equals( "abcdef" ) ) {
5722 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5723 p3.getNode( "g" ) );
5724 if ( !ag_3.getName().equals( "" ) ) {
5727 if ( !ag_3.isRoot() ) {
5730 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5731 p3.getNode( "l" ) );
5732 if ( !al_3.getName().equals( "" ) ) {
5735 if ( !al_3.isRoot() ) {
5738 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5739 p3.getNode( "l" ) );
5740 if ( !kl_3.getName().equals( "" ) ) {
5743 if ( !kl_3.isRoot() ) {
5746 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5747 p3.getNode( "l" ) );
5748 if ( !fl_3.getName().equals( "" ) ) {
5751 if ( !fl_3.isRoot() ) {
5754 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5755 p3.getNode( "k" ) );
5756 if ( !gk_3.getName().equals( "ghijk" ) ) {
5759 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5760 PhylogenyMethods.preOrderReId( p4 );
5761 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5762 p4.getNode( "c" ) );
5763 if ( !r_4.getName().equals( "r" ) ) {
5766 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5767 PhylogenyMethods.preOrderReId( p5 );
5768 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5769 p5.getNode( "c" ) );
5770 if ( !r_5.getName().equals( "root" ) ) {
5773 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5774 PhylogenyMethods.preOrderReId( p6 );
5775 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5776 p6.getNode( "a" ) );
5777 if ( !r_6.getName().equals( "rot" ) ) {
5780 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5781 PhylogenyMethods.preOrderReId( p7 );
5782 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5783 p7.getNode( "e" ) );
5784 if ( !r_7.getName().equals( "rott" ) ) {
5787 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5788 p7.getNode( "a" ) );
5789 if ( !r_71.getName().equals( "rott" ) ) {
5792 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5793 p7.getNode( "rott" ) );
5794 if ( !r_72.getName().equals( "rott" ) ) {
5797 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5798 p7.getNode( "a" ) );
5799 if ( !r_73.getName().equals( "rott" ) ) {
5802 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5803 p7.getNode( "rott" ) );
5804 if ( !r_74.getName().equals( "rott" ) ) {
5807 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5808 p7.getNode( "e" ) );
5809 if ( !r_75.getName().equals( "e" ) ) {
5813 catch ( final Exception e ) {
5814 e.printStackTrace( System.out );
5820 private static boolean testHmmscanOutputParser() {
5821 final String test_dir = Test.PATH_TO_TEST_DATA;
5823 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5824 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5826 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5827 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5828 final List<Protein> proteins = parser2.parse();
5829 if ( parser2.getProteinsEncountered() != 4 ) {
5832 if ( proteins.size() != 4 ) {
5835 if ( parser2.getDomainsEncountered() != 69 ) {
5838 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5841 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5844 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5847 final Protein p1 = proteins.get( 0 );
5848 if ( p1.getNumberOfProteinDomains() != 15 ) {
5851 if ( p1.getLength() != 850 ) {
5854 final Protein p2 = proteins.get( 1 );
5855 if ( p2.getNumberOfProteinDomains() != 51 ) {
5858 if ( p2.getLength() != 1291 ) {
5861 final Protein p3 = proteins.get( 2 );
5862 if ( p3.getNumberOfProteinDomains() != 2 ) {
5865 final Protein p4 = proteins.get( 3 );
5866 if ( p4.getNumberOfProteinDomains() != 1 ) {
5869 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5872 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5875 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5878 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5881 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5884 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5887 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5891 catch ( final Exception e ) {
5892 e.printStackTrace( System.out );
5898 private static boolean testLastExternalNodeMethods() {
5900 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5901 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5902 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5903 final PhylogenyNode n1 = t0.getNode( "A" );
5904 if ( n1.isLastExternalNode() ) {
5907 final PhylogenyNode n2 = t0.getNode( "B" );
5908 if ( n2.isLastExternalNode() ) {
5911 final PhylogenyNode n3 = t0.getNode( "C" );
5912 if ( n3.isLastExternalNode() ) {
5915 final PhylogenyNode n4 = t0.getNode( "D" );
5916 if ( !n4.isLastExternalNode() ) {
5920 catch ( final Exception e ) {
5921 e.printStackTrace( System.out );
5927 private static boolean testLevelOrderIterator() {
5929 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5930 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5931 PhylogenyNodeIterator it0;
5932 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5935 for( it0.reset(); it0.hasNext(); ) {
5938 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5939 if ( !it.next().getName().equals( "r" ) ) {
5942 if ( !it.next().getName().equals( "ab" ) ) {
5945 if ( !it.next().getName().equals( "cd" ) ) {
5948 if ( !it.next().getName().equals( "A" ) ) {
5951 if ( !it.next().getName().equals( "B" ) ) {
5954 if ( !it.next().getName().equals( "C" ) ) {
5957 if ( !it.next().getName().equals( "D" ) ) {
5960 if ( it.hasNext() ) {
5963 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",
5964 new NHXParser() )[ 0 ];
5965 PhylogenyNodeIterator it2;
5966 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5969 for( it2.reset(); it2.hasNext(); ) {
5972 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5973 if ( !it3.next().getName().equals( "r" ) ) {
5976 if ( !it3.next().getName().equals( "abc" ) ) {
5979 if ( !it3.next().getName().equals( "defg" ) ) {
5982 if ( !it3.next().getName().equals( "A" ) ) {
5985 if ( !it3.next().getName().equals( "B" ) ) {
5988 if ( !it3.next().getName().equals( "C" ) ) {
5991 if ( !it3.next().getName().equals( "D" ) ) {
5994 if ( !it3.next().getName().equals( "E" ) ) {
5997 if ( !it3.next().getName().equals( "F" ) ) {
6000 if ( !it3.next().getName().equals( "G" ) ) {
6003 if ( !it3.next().getName().equals( "1" ) ) {
6006 if ( !it3.next().getName().equals( "2" ) ) {
6009 if ( !it3.next().getName().equals( "3" ) ) {
6012 if ( !it3.next().getName().equals( "4" ) ) {
6015 if ( !it3.next().getName().equals( "5" ) ) {
6018 if ( !it3.next().getName().equals( "6" ) ) {
6021 if ( !it3.next().getName().equals( "f1" ) ) {
6024 if ( !it3.next().getName().equals( "f2" ) ) {
6027 if ( !it3.next().getName().equals( "f3" ) ) {
6030 if ( !it3.next().getName().equals( "a" ) ) {
6033 if ( !it3.next().getName().equals( "b" ) ) {
6036 if ( !it3.next().getName().equals( "f21" ) ) {
6039 if ( !it3.next().getName().equals( "X" ) ) {
6042 if ( !it3.next().getName().equals( "Y" ) ) {
6045 if ( !it3.next().getName().equals( "Z" ) ) {
6048 if ( it3.hasNext() ) {
6051 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
6052 PhylogenyNodeIterator it4;
6053 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
6056 for( it4.reset(); it4.hasNext(); ) {
6059 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
6060 if ( !it5.next().getName().equals( "r" ) ) {
6063 if ( !it5.next().getName().equals( "A" ) ) {
6066 if ( !it5.next().getName().equals( "B" ) ) {
6069 if ( !it5.next().getName().equals( "C" ) ) {
6072 if ( !it5.next().getName().equals( "D" ) ) {
6075 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
6076 PhylogenyNodeIterator it6;
6077 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
6080 for( it6.reset(); it6.hasNext(); ) {
6083 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
6084 if ( !it7.next().getName().equals( "A" ) ) {
6087 if ( it.hasNext() ) {
6091 catch ( final Exception e ) {
6092 e.printStackTrace( System.out );
6098 private static boolean testMafft( final String path ) {
6100 final List<String> opts = new ArrayList<String>();
6101 opts.add( "--maxiterate" );
6103 opts.add( "--localpair" );
6104 opts.add( "--quiet" );
6106 final MsaInferrer mafft = Mafft.createInstance( path );
6107 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
6108 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
6111 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
6115 catch ( final Exception e ) {
6116 e.printStackTrace( System.out );
6122 private static boolean testMidpointrooting() {
6124 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6125 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
6126 PhylogenyMethods.midpointRoot( t0 );
6127 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6130 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6133 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6137 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",
6138 new NHXParser() )[ 0 ];
6139 if ( !t1.isRooted() ) {
6142 PhylogenyMethods.midpointRoot( t1 );
6143 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6146 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6149 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6152 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6155 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6158 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6161 t1.reRoot( t1.getNode( "A" ) );
6162 PhylogenyMethods.midpointRoot( t1 );
6163 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6166 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6169 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6172 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6175 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6179 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6183 catch ( final Exception e ) {
6184 e.printStackTrace( System.out );
6190 private static boolean testMsaQualityMethod() {
6192 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6193 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6194 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6195 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6196 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6201 final Msa msa = BasicMsa.createInstance( l );
6202 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6205 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6208 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6211 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6214 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6217 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6220 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6224 catch ( final Exception e ) {
6225 e.printStackTrace( System.out );
6231 private static boolean testMsaEntropy() {
6233 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6234 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6235 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6236 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6237 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6242 final Msa msa = BasicMsa.createInstance( l );
6243 //TODO need to DO the tests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6245 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6246 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6247 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6248 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6249 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6250 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6251 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6252 // System.out.println();
6253 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6254 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6255 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6256 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6257 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6258 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6259 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6260 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6261 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6262 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6263 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6264 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6265 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6266 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6267 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6268 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6269 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6270 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6271 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6272 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6273 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6274 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6275 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6276 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6277 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6278 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6279 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6280 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6281 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6282 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6283 final Msa msa2 = BasicMsa.createInstance( l2 );
6284 // System.out.println();
6285 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6286 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6287 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6289 catch ( final Exception e ) {
6290 e.printStackTrace( System.out );
6296 private static boolean testDeleteableMsa() {
6298 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6299 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6300 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6301 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6302 final MolecularSequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6303 final MolecularSequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6304 final List<MolecularSequence> l0 = new ArrayList<MolecularSequence>();
6311 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6312 dmsa0.deleteRow( "b", false );
6313 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6316 dmsa0.deleteRow( "e", false );
6317 dmsa0.deleteRow( "a", false );
6318 dmsa0.deleteRow( "f", false );
6319 if ( dmsa0.getLength() != 4 ) {
6322 if ( dmsa0.getNumberOfSequences() != 2 ) {
6325 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6328 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6331 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6334 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6337 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6340 dmsa0.deleteRow( "c", false );
6341 dmsa0.deleteRow( "d", false );
6342 if ( dmsa0.getNumberOfSequences() != 0 ) {
6346 final MolecularSequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6347 final MolecularSequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6348 final MolecularSequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6349 final MolecularSequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6350 final MolecularSequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6351 final MolecularSequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6352 final List<MolecularSequence> l1 = new ArrayList<MolecularSequence>();
6359 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6360 dmsa1.deleteGapOnlyColumns();
6361 dmsa1.deleteRow( "a", false );
6362 dmsa1.deleteRow( "f", false );
6363 dmsa1.deleteRow( "d", false );
6364 dmsa1.deleteGapOnlyColumns();
6365 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6368 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6371 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6374 dmsa1.deleteRow( "c", false );
6375 dmsa1.deleteGapOnlyColumns();
6376 final Writer w0 = new StringWriter();
6377 dmsa1.write( w0, MSA_FORMAT.FASTA );
6378 final Writer w1 = new StringWriter();
6379 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6380 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6383 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6386 final MolecularSequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6387 final MolecularSequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6388 final MolecularSequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6389 final MolecularSequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6390 final MolecularSequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6391 final MolecularSequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6392 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6399 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6400 dmsa2.deleteGapColumns( 0.5 );
6401 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
6404 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
6407 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
6410 dmsa2.deleteGapColumns( 0.2 );
6411 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
6414 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
6417 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
6420 dmsa2.deleteGapColumns( 0 );
6421 dmsa2.deleteRow( "a", false );
6422 dmsa2.deleteRow( "b", false );
6423 dmsa2.deleteRow( "f", false );
6424 dmsa2.deleteRow( "e", false );
6425 dmsa2.setIdentifier( 0, "new_c" );
6426 dmsa2.setIdentifier( 1, "new_d" );
6427 dmsa2.setResidueAt( 0, 0, 'x' );
6428 final MolecularSequence s = dmsa2.deleteRow( "new_d", true );
6429 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
6432 final Writer w = new StringWriter();
6433 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6434 final String phylip = w.toString();
6435 if ( !phylip.equals( "1 1" + ForesterUtil.LINE_SEPARATOR + "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6436 System.out.println( phylip );
6439 final Writer w2 = new StringWriter();
6440 dmsa2.write( w2, MSA_FORMAT.FASTA );
6441 final String fasta = w2.toString();
6442 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6443 System.out.println( fasta );
6447 catch ( final Exception e ) {
6448 e.printStackTrace( System.out );
6454 private static boolean testNextNodeWithCollapsing() {
6456 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6458 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6459 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6460 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6461 t0.getNode( "cd" ).setCollapse( true );
6462 t0.getNode( "cde" ).setCollapse( true );
6463 n = t0.getFirstExternalNode();
6464 while ( n != null ) {
6466 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6468 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6471 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6474 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6477 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6480 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6483 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6487 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6488 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6489 t1.getNode( "ab" ).setCollapse( true );
6490 t1.getNode( "cd" ).setCollapse( true );
6491 t1.getNode( "cde" ).setCollapse( true );
6492 n = t1.getNode( "ab" );
6493 ext = new ArrayList<PhylogenyNode>();
6494 while ( n != null ) {
6496 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6498 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6501 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6504 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6507 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6510 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6514 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6515 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6516 t2.getNode( "ab" ).setCollapse( true );
6517 t2.getNode( "cd" ).setCollapse( true );
6518 t2.getNode( "cde" ).setCollapse( true );
6519 t2.getNode( "c" ).setCollapse( true );
6520 t2.getNode( "d" ).setCollapse( true );
6521 t2.getNode( "e" ).setCollapse( true );
6522 t2.getNode( "gh" ).setCollapse( true );
6523 n = t2.getNode( "ab" );
6524 ext = new ArrayList<PhylogenyNode>();
6525 while ( n != null ) {
6527 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6529 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6532 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6535 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6538 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6542 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6543 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6544 t3.getNode( "ab" ).setCollapse( true );
6545 t3.getNode( "cd" ).setCollapse( true );
6546 t3.getNode( "cde" ).setCollapse( true );
6547 t3.getNode( "c" ).setCollapse( true );
6548 t3.getNode( "d" ).setCollapse( true );
6549 t3.getNode( "e" ).setCollapse( true );
6550 t3.getNode( "gh" ).setCollapse( true );
6551 t3.getNode( "fgh" ).setCollapse( true );
6552 n = t3.getNode( "ab" );
6553 ext = new ArrayList<PhylogenyNode>();
6554 while ( n != null ) {
6556 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6558 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6561 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6564 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6568 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6569 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6570 t4.getNode( "ab" ).setCollapse( true );
6571 t4.getNode( "cd" ).setCollapse( true );
6572 t4.getNode( "cde" ).setCollapse( true );
6573 t4.getNode( "c" ).setCollapse( true );
6574 t4.getNode( "d" ).setCollapse( true );
6575 t4.getNode( "e" ).setCollapse( true );
6576 t4.getNode( "gh" ).setCollapse( true );
6577 t4.getNode( "fgh" ).setCollapse( true );
6578 t4.getNode( "abcdefgh" ).setCollapse( true );
6579 n = t4.getNode( "abcdefgh" );
6580 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6583 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6584 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6586 n = t5.getFirstExternalNode();
6587 while ( n != null ) {
6589 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6591 if ( ext.size() != 8 ) {
6594 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6597 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6600 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6603 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6606 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6609 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6612 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6615 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6618 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6619 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6621 t6.getNode( "ab" ).setCollapse( true );
6622 n = t6.getNode( "ab" );
6623 while ( n != null ) {
6625 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6627 if ( ext.size() != 7 ) {
6630 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6633 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6636 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6639 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6642 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6645 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6648 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6651 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6652 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6654 t7.getNode( "cd" ).setCollapse( true );
6655 n = t7.getNode( "a" );
6656 while ( n != null ) {
6658 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6660 if ( ext.size() != 7 ) {
6663 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6666 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6669 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6672 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6675 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6678 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6681 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6684 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6685 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6687 t8.getNode( "cd" ).setCollapse( true );
6688 t8.getNode( "c" ).setCollapse( true );
6689 t8.getNode( "d" ).setCollapse( true );
6690 n = t8.getNode( "a" );
6691 while ( n != null ) {
6693 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6695 if ( ext.size() != 7 ) {
6698 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6701 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6704 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6705 System.out.println( "2 fail" );
6708 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6711 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6714 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6717 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6720 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6721 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6723 t9.getNode( "gh" ).setCollapse( true );
6724 n = t9.getNode( "a" );
6725 while ( n != null ) {
6727 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6729 if ( ext.size() != 7 ) {
6732 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6735 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6738 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6741 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6744 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6747 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6750 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6753 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6754 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6756 t10.getNode( "gh" ).setCollapse( true );
6757 t10.getNode( "g" ).setCollapse( true );
6758 t10.getNode( "h" ).setCollapse( true );
6759 n = t10.getNode( "a" );
6760 while ( n != null ) {
6762 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6764 if ( ext.size() != 7 ) {
6767 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6770 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6773 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6776 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6779 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6782 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6785 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6788 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6789 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6791 t11.getNode( "gh" ).setCollapse( true );
6792 t11.getNode( "fgh" ).setCollapse( true );
6793 n = t11.getNode( "a" );
6794 while ( n != null ) {
6796 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6798 if ( ext.size() != 6 ) {
6801 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6804 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6807 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6810 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6813 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6816 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6819 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6820 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6822 t12.getNode( "gh" ).setCollapse( true );
6823 t12.getNode( "fgh" ).setCollapse( true );
6824 t12.getNode( "g" ).setCollapse( true );
6825 t12.getNode( "h" ).setCollapse( true );
6826 t12.getNode( "f" ).setCollapse( true );
6827 n = t12.getNode( "a" );
6828 while ( n != null ) {
6830 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6832 if ( ext.size() != 6 ) {
6835 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6838 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6841 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6844 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6847 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6850 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6853 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6854 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6856 t13.getNode( "ab" ).setCollapse( true );
6857 t13.getNode( "b" ).setCollapse( true );
6858 t13.getNode( "fgh" ).setCollapse( true );
6859 t13.getNode( "gh" ).setCollapse( true );
6860 n = t13.getNode( "ab" );
6861 while ( n != null ) {
6863 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6865 if ( ext.size() != 5 ) {
6868 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6871 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6874 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6877 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6880 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6883 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6884 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6886 t14.getNode( "ab" ).setCollapse( true );
6887 t14.getNode( "a" ).setCollapse( true );
6888 t14.getNode( "fgh" ).setCollapse( true );
6889 t14.getNode( "gh" ).setCollapse( true );
6890 n = t14.getNode( "ab" );
6891 while ( n != null ) {
6893 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6895 if ( ext.size() != 5 ) {
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( "fgh" ) ) {
6913 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" );
6914 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6916 t15.getNode( "ab" ).setCollapse( true );
6917 t15.getNode( "a" ).setCollapse( true );
6918 t15.getNode( "fgh" ).setCollapse( true );
6919 t15.getNode( "gh" ).setCollapse( true );
6920 n = t15.getNode( "ab" );
6921 while ( n != null ) {
6923 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6925 if ( ext.size() != 6 ) {
6928 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6931 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6934 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6937 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6940 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6943 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6948 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" );
6949 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6951 t16.getNode( "ab" ).setCollapse( true );
6952 t16.getNode( "a" ).setCollapse( true );
6953 t16.getNode( "fgh" ).setCollapse( true );
6954 t16.getNode( "gh" ).setCollapse( true );
6955 t16.getNode( "cd" ).setCollapse( true );
6956 t16.getNode( "cde" ).setCollapse( true );
6957 t16.getNode( "d" ).setCollapse( true );
6958 t16.getNode( "x" ).setCollapse( true );
6959 n = t16.getNode( "ab" );
6960 while ( n != null ) {
6962 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6964 if ( ext.size() != 4 ) {
6967 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6970 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6973 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6976 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6980 catch ( final Exception e ) {
6981 e.printStackTrace( System.out );
6987 private static boolean testNexusCharactersParsing() {
6989 final NexusCharactersParser parser = new NexusCharactersParser();
6990 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6992 String[] labels = parser.getCharStateLabels();
6993 if ( labels.length != 7 ) {
6996 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6999 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7002 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7005 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7008 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7011 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7014 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7017 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7019 labels = parser.getCharStateLabels();
7020 if ( labels.length != 7 ) {
7023 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7026 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7029 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7032 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7035 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7038 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7041 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7045 catch ( final Exception e ) {
7046 e.printStackTrace( System.out );
7052 private static boolean testNexusMatrixParsing() {
7054 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
7055 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
7057 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
7058 if ( m.getNumberOfCharacters() != 9 ) {
7061 if ( m.getNumberOfIdentifiers() != 5 ) {
7064 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
7067 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
7070 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
7073 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
7076 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
7079 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
7082 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
7085 // if ( labels.length != 7 ) {
7088 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7091 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7094 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7097 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7100 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7103 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7106 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7109 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7111 // labels = parser.getCharStateLabels();
7112 // if ( labels.length != 7 ) {
7115 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7118 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7121 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7124 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7127 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7130 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7133 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7137 catch ( final Exception e ) {
7138 e.printStackTrace( System.out );
7144 private static boolean testNexusTreeParsing() {
7146 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7147 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7148 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7149 if ( phylogenies.length != 1 ) {
7152 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7155 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7159 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7160 if ( phylogenies.length != 1 ) {
7163 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7166 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7170 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7171 if ( phylogenies.length != 1 ) {
7174 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7177 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7180 if ( phylogenies[ 0 ].isRooted() ) {
7184 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7185 if ( phylogenies.length != 18 ) {
7188 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7191 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7194 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7197 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7200 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7203 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7206 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7209 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7212 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7215 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7218 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7221 if ( phylogenies[ 8 ].isRooted() ) {
7224 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7227 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7230 if ( !phylogenies[ 9 ].isRooted() ) {
7233 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7236 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7239 if ( !phylogenies[ 10 ].isRooted() ) {
7242 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7245 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7248 if ( phylogenies[ 11 ].isRooted() ) {
7251 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7254 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7257 if ( !phylogenies[ 12 ].isRooted() ) {
7260 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7263 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7266 if ( !phylogenies[ 13 ].isRooted() ) {
7269 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7272 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7275 if ( !phylogenies[ 14 ].isRooted() ) {
7278 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7281 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7284 if ( phylogenies[ 15 ].isRooted() ) {
7287 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7290 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7293 if ( !phylogenies[ 16 ].isRooted() ) {
7296 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7299 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7302 if ( phylogenies[ 17 ].isRooted() ) {
7305 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7308 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7310 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7311 if ( phylogenies.length != 9 ) {
7314 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7315 .getDistanceToParent() ) ) {
7318 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7319 .getDistanceToParent() ) ) {
7322 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7325 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7328 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7331 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7334 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7338 catch ( final Exception e ) {
7339 e.printStackTrace( System.out );
7345 private static boolean testNexusTreeParsingIterating() {
7347 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7348 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7349 if ( !p.hasNext() ) {
7352 Phylogeny phy = p.next();
7353 if ( phy == null ) {
7356 if ( phy.getNumberOfExternalNodes() != 25 ) {
7359 if ( !phy.getName().equals( "" ) ) {
7362 if ( p.hasNext() ) {
7366 if ( phy != null ) {
7370 if ( !p.hasNext() ) {
7374 if ( phy == null ) {
7377 if ( phy.getNumberOfExternalNodes() != 25 ) {
7380 if ( !phy.getName().equals( "" ) ) {
7383 if ( p.hasNext() ) {
7387 if ( phy != null ) {
7390 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7391 if ( !p.hasNext() ) {
7395 if ( phy == null ) {
7398 if ( phy.getNumberOfExternalNodes() != 10 ) {
7401 if ( !phy.getName().equals( "name" ) ) {
7404 if ( p.hasNext() ) {
7408 if ( phy != null ) {
7412 if ( !p.hasNext() ) {
7416 if ( phy == null ) {
7419 if ( phy.getNumberOfExternalNodes() != 10 ) {
7422 if ( !phy.getName().equals( "name" ) ) {
7425 if ( p.hasNext() ) {
7429 if ( phy != null ) {
7432 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7433 if ( !p.hasNext() ) {
7437 if ( phy == null ) {
7440 if ( phy.getNumberOfExternalNodes() != 3 ) {
7443 if ( !phy.getName().equals( "" ) ) {
7446 if ( phy.isRooted() ) {
7449 if ( p.hasNext() ) {
7453 if ( phy != null ) {
7458 if ( !p.hasNext() ) {
7462 if ( phy == null ) {
7465 if ( phy.getNumberOfExternalNodes() != 3 ) {
7468 if ( !phy.getName().equals( "" ) ) {
7471 if ( p.hasNext() ) {
7475 if ( phy != null ) {
7479 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7480 if ( !p.hasNext() ) {
7485 if ( phy == null ) {
7488 if ( phy.getNumberOfExternalNodes() != 10 ) {
7491 if ( !phy.getName().equals( "tree 0" ) ) {
7495 if ( !p.hasNext() ) {
7499 if ( phy == null ) {
7502 if ( phy.getNumberOfExternalNodes() != 10 ) {
7505 if ( !phy.getName().equals( "tree 1" ) ) {
7509 if ( !p.hasNext() ) {
7513 if ( phy == null ) {
7516 if ( phy.getNumberOfExternalNodes() != 3 ) {
7517 System.out.println( phy.toString() );
7520 if ( !phy.getName().equals( "" ) ) {
7523 if ( phy.isRooted() ) {
7527 if ( !p.hasNext() ) {
7531 if ( phy == null ) {
7534 if ( phy.getNumberOfExternalNodes() != 4 ) {
7537 if ( !phy.getName().equals( "" ) ) {
7540 if ( !phy.isRooted() ) {
7544 if ( !p.hasNext() ) {
7548 if ( phy == null ) {
7551 if ( phy.getNumberOfExternalNodes() != 5 ) {
7552 System.out.println( phy.getNumberOfExternalNodes() );
7555 if ( !phy.getName().equals( "" ) ) {
7558 if ( !phy.isRooted() ) {
7562 if ( !p.hasNext() ) {
7566 if ( phy == null ) {
7569 if ( phy.getNumberOfExternalNodes() != 3 ) {
7572 if ( !phy.getName().equals( "" ) ) {
7575 if ( phy.isRooted() ) {
7579 if ( !p.hasNext() ) {
7583 if ( phy == null ) {
7586 if ( phy.getNumberOfExternalNodes() != 2 ) {
7589 if ( !phy.getName().equals( "" ) ) {
7592 if ( !phy.isRooted() ) {
7596 if ( !p.hasNext() ) {
7600 if ( phy.getNumberOfExternalNodes() != 3 ) {
7603 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7606 if ( !phy.isRooted() ) {
7610 if ( !p.hasNext() ) {
7614 if ( phy.getNumberOfExternalNodes() != 3 ) {
7617 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7620 if ( !phy.getName().equals( "tree 8" ) ) {
7624 if ( !p.hasNext() ) {
7628 if ( phy.getNumberOfExternalNodes() != 3 ) {
7631 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7634 if ( !phy.getName().equals( "tree 9" ) ) {
7638 if ( !p.hasNext() ) {
7642 if ( phy.getNumberOfExternalNodes() != 3 ) {
7645 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7648 if ( !phy.getName().equals( "tree 10" ) ) {
7651 if ( !phy.isRooted() ) {
7655 if ( !p.hasNext() ) {
7659 if ( phy.getNumberOfExternalNodes() != 3 ) {
7662 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7665 if ( !phy.getName().equals( "tree 11" ) ) {
7668 if ( phy.isRooted() ) {
7672 if ( !p.hasNext() ) {
7676 if ( phy.getNumberOfExternalNodes() != 3 ) {
7679 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7682 if ( !phy.getName().equals( "tree 12" ) ) {
7685 if ( !phy.isRooted() ) {
7689 if ( !p.hasNext() ) {
7693 if ( phy.getNumberOfExternalNodes() != 3 ) {
7696 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7699 if ( !phy.getName().equals( "tree 13" ) ) {
7702 if ( !phy.isRooted() ) {
7706 if ( !p.hasNext() ) {
7710 if ( phy.getNumberOfExternalNodes() != 10 ) {
7711 System.out.println( phy.getNumberOfExternalNodes() );
7716 .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;" ) ) {
7717 System.out.println( phy.toNewHampshire() );
7720 if ( !phy.getName().equals( "tree 14" ) ) {
7723 if ( !phy.isRooted() ) {
7727 if ( !p.hasNext() ) {
7731 if ( phy.getNumberOfExternalNodes() != 10 ) {
7732 System.out.println( phy.getNumberOfExternalNodes() );
7737 .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;" ) ) {
7738 System.out.println( phy.toNewHampshire() );
7741 if ( !phy.getName().equals( "tree 15" ) ) {
7744 if ( phy.isRooted() ) {
7748 if ( !p.hasNext() ) {
7752 if ( phy.getNumberOfExternalNodes() != 10 ) {
7753 System.out.println( phy.getNumberOfExternalNodes() );
7758 .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;" ) ) {
7759 System.out.println( phy.toNewHampshire() );
7762 if ( !phy.getName().equals( "tree 16" ) ) {
7765 if ( !phy.isRooted() ) {
7769 if ( !p.hasNext() ) {
7773 if ( phy.getNumberOfExternalNodes() != 10 ) {
7774 System.out.println( phy.getNumberOfExternalNodes() );
7779 .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;" ) ) {
7780 System.out.println( phy.toNewHampshire() );
7783 if ( !phy.getName().equals( "tree 17" ) ) {
7786 if ( phy.isRooted() ) {
7790 if ( p.hasNext() ) {
7794 if ( phy != null ) {
7799 if ( !p.hasNext() ) {
7803 if ( phy == null ) {
7806 if ( phy.getNumberOfExternalNodes() != 10 ) {
7809 if ( !phy.getName().equals( "tree 0" ) ) {
7813 if ( !p.hasNext() ) {
7817 if ( phy == null ) {
7820 if ( phy.getNumberOfExternalNodes() != 10 ) {
7823 if ( !phy.getName().equals( "tree 1" ) ) {
7827 if ( !p.hasNext() ) {
7831 if ( phy == null ) {
7834 if ( phy.getNumberOfExternalNodes() != 3 ) {
7837 if ( !phy.getName().equals( "" ) ) {
7840 if ( phy.isRooted() ) {
7844 if ( !p.hasNext() ) {
7848 if ( phy == null ) {
7851 if ( phy.getNumberOfExternalNodes() != 4 ) {
7854 if ( !phy.getName().equals( "" ) ) {
7857 if ( !phy.isRooted() ) {
7861 if ( !p.hasNext() ) {
7865 if ( phy == null ) {
7868 if ( phy.getNumberOfExternalNodes() != 5 ) {
7869 System.out.println( phy.getNumberOfExternalNodes() );
7872 if ( !phy.getName().equals( "" ) ) {
7875 if ( !phy.isRooted() ) {
7879 if ( !p.hasNext() ) {
7883 if ( phy == null ) {
7886 if ( phy.getNumberOfExternalNodes() != 3 ) {
7889 if ( !phy.getName().equals( "" ) ) {
7892 if ( phy.isRooted() ) {
7896 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7897 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7899 if ( !p2.hasNext() ) {
7903 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7906 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7910 if ( !p2.hasNext() ) {
7915 if ( !p2.hasNext() ) {
7920 if ( !p2.hasNext() ) {
7925 if ( !p2.hasNext() ) {
7930 if ( !p2.hasNext() ) {
7935 if ( !p2.hasNext() ) {
7940 if ( !p2.hasNext() ) {
7945 if ( !p2.hasNext() ) {
7949 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7952 if ( p2.hasNext() ) {
7956 if ( phy != null ) {
7961 if ( !p2.hasNext() ) {
7965 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7968 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7972 catch ( final Exception e ) {
7973 e.printStackTrace( System.out );
7979 private static boolean testNexusTreeParsingTranslating() {
7981 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7982 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7983 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7984 if ( phylogenies.length != 1 ) {
7987 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7990 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7993 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7996 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7999 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8000 .equals( "Aranaeus" ) ) {
8004 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
8005 if ( phylogenies.length != 3 ) {
8008 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8011 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8014 if ( phylogenies[ 0 ].isRooted() ) {
8017 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8020 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8023 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8024 .equals( "Aranaeus" ) ) {
8027 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8030 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8033 if ( phylogenies[ 1 ].isRooted() ) {
8036 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8039 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8042 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8043 .equals( "Aranaeus" ) ) {
8046 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8049 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8052 if ( !phylogenies[ 2 ].isRooted() ) {
8055 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8058 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8061 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8062 .equals( "Aranaeus" ) ) {
8066 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
8067 if ( phylogenies.length != 3 ) {
8070 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8073 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8076 if ( phylogenies[ 0 ].isRooted() ) {
8079 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8082 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8085 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8086 .equals( "Aranaeus" ) ) {
8089 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8092 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8095 if ( phylogenies[ 1 ].isRooted() ) {
8098 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8101 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8104 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8105 .equals( "Aranaeus" ) ) {
8108 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8111 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8114 if ( !phylogenies[ 2 ].isRooted() ) {
8117 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8120 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8123 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8124 .equals( "Aranaeus" ) ) {
8127 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8128 if ( phylogenies.length != 3 ) {
8131 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8136 catch ( final Exception e ) {
8137 e.printStackTrace( System.out );
8143 private static boolean testNHParsing() {
8145 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8146 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8147 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8150 final NHXParser nhxp = new NHXParser();
8151 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8152 nhxp.setReplaceUnderscores( true );
8153 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8154 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8157 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8160 final Phylogeny p1b = factory
8161 .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 ",
8162 new NHXParser() )[ 0 ];
8163 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8166 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8169 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
8170 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8171 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8172 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
8173 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8174 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8175 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8176 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8177 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8178 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8179 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8180 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
8181 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8183 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8186 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8189 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8192 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8195 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8196 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8197 final String p16_S = "((A,B),C)";
8198 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8199 if ( p16.length != 1 ) {
8202 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8205 final String p17_S = "(C,(A,B))";
8206 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8207 if ( p17.length != 1 ) {
8210 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8213 final String p18_S = "((A,B),(C,D))";
8214 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8215 if ( p18.length != 1 ) {
8218 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8221 final String p19_S = "(((A,B),C),D)";
8222 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8223 if ( p19.length != 1 ) {
8226 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8229 final String p20_S = "(A,(B,(C,D)))";
8230 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8231 if ( p20.length != 1 ) {
8234 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8237 final String p21_S = "(A,(B,(C,(D,E))))";
8238 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8239 if ( p21.length != 1 ) {
8242 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8245 final String p22_S = "((((A,B),C),D),E)";
8246 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8247 if ( p22.length != 1 ) {
8250 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8253 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8254 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8255 if ( p23.length != 1 ) {
8256 System.out.println( "xl=" + p23.length );
8260 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8263 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8264 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8265 if ( p24.length != 1 ) {
8268 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8271 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8272 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8273 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8274 if ( p241.length != 2 ) {
8277 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8280 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8283 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8284 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8285 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8286 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8287 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8288 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8289 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8290 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8291 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8292 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8295 final String p26_S = "(A,B)ab";
8296 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8297 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8300 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8301 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8302 if ( p27s.length != 1 ) {
8303 System.out.println( "xxl=" + p27s.length );
8307 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8308 System.out.println( p27s[ 0 ].toNewHampshireX() );
8312 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8314 if ( p27.length != 1 ) {
8315 System.out.println( "yl=" + p27.length );
8319 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8320 System.out.println( p27[ 0 ].toNewHampshireX() );
8324 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8325 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8326 final String p28_S3 = "(A,B)ab";
8327 final String p28_S4 = "((((A,B),C),D),;E;)";
8328 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8330 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8333 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8336 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8339 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8342 if ( p28.length != 4 ) {
8345 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";
8346 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8347 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8350 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";
8351 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8352 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8355 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8356 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8357 if ( ( p32.length != 0 ) ) {
8360 final String p33_S = "A";
8361 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8362 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8365 final String p34_S = "B;";
8366 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8367 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8370 final String p35_S = "B:0.2";
8371 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8372 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8375 final String p36_S = "(A)";
8376 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8377 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8380 final String p37_S = "((A))";
8381 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8382 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8385 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8386 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8387 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8390 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8391 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8392 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8395 final String p40_S = "(A,B,C)";
8396 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8397 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8400 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8401 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8402 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8405 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8406 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8407 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8410 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)";
8411 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8412 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8415 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)))";
8416 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8417 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8420 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8421 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8422 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8425 final String p46_S = "";
8426 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8427 if ( p46.length != 0 ) {
8430 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8431 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8434 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8435 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8438 final Phylogeny p49 = factory
8439 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8440 new NHXParser() )[ 0 ];
8441 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8444 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8445 if ( p50.getNode( "A" ) == null ) {
8448 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8449 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8452 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8455 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8456 .equals( "((A,B)88:2.0,C);" ) ) {
8459 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8460 if ( p51.getNode( "A(A" ) == null ) {
8463 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8464 if ( p52.getNode( "A(A" ) == null ) {
8467 final Phylogeny p53 = factory
8468 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8469 new NHXParser() )[ 0 ];
8470 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8473 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8474 if ( p54.getNode( "A" ) == null ) {
8477 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8480 final Phylogeny p55 = factory
8481 .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);" ),
8482 new NHXParser() )[ 0 ];
8485 .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);" ) ) {
8486 System.out.println( p55.toNewHampshire() );
8489 final Phylogeny p56 = factory
8490 .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);" ),
8491 new NHXParser() )[ 0 ];
8494 .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);" ) ) {
8495 System.out.println( p56.toNewHampshire() );
8498 final Phylogeny p57 = factory
8499 .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);" ),
8500 new NHXParser() )[ 0 ];
8503 .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);" ) ) {
8504 System.out.println( p56.toNewHampshire() );
8507 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8508 final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ];
8509 if ( !p58.toNewHampshire().equals( s58 ) ) {
8510 System.out.println( p58.toNewHampshire() );
8513 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8514 final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ];
8515 if ( !p59.toNewHampshire().equals( s59 ) ) {
8516 System.out.println( p59.toNewHampshire() );
8519 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8520 final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ];
8521 if ( !p60.toNewHampshire().equals( s60 ) ) {
8522 System.out.println( p60.toNewHampshire() );
8525 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8526 final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ];
8527 if ( !p61.toNewHampshire()
8528 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8529 System.out.println( p61.toNewHampshire() );
8533 catch ( final Exception e ) {
8534 e.printStackTrace( System.out );
8540 private static boolean testNHParsingIter() {
8542 final String p0_str = "(A,B);";
8543 final NHXParser p = new NHXParser();
8544 p.setSource( p0_str );
8545 if ( !p.hasNext() ) {
8548 final Phylogeny p0 = p.next();
8549 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8550 System.out.println( p0.toNewHampshire() );
8553 if ( p.hasNext() ) {
8556 if ( p.next() != null ) {
8560 final String p00_str = "(A,B)root;";
8561 p.setSource( p00_str );
8562 final Phylogeny p00 = p.next();
8563 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8564 System.out.println( p00.toNewHampshire() );
8568 final String p000_str = "A;";
8569 p.setSource( p000_str );
8570 final Phylogeny p000 = p.next();
8571 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8572 System.out.println( p000.toNewHampshire() );
8576 final String p0000_str = "A";
8577 p.setSource( p0000_str );
8578 final Phylogeny p0000 = p.next();
8579 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8580 System.out.println( p0000.toNewHampshire() );
8584 p.setSource( "(A)" );
8585 final Phylogeny p00000 = p.next();
8586 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8587 System.out.println( p00000.toNewHampshire() );
8591 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8592 p.setSource( p1_str );
8593 if ( !p.hasNext() ) {
8596 final Phylogeny p1_0 = p.next();
8597 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8598 System.out.println( p1_0.toNewHampshire() );
8601 if ( !p.hasNext() ) {
8604 final Phylogeny p1_1 = p.next();
8605 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8606 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8609 if ( !p.hasNext() ) {
8612 final Phylogeny p1_2 = p.next();
8613 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8614 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8617 if ( !p.hasNext() ) {
8620 final Phylogeny p1_3 = p.next();
8621 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8622 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8625 if ( p.hasNext() ) {
8628 if ( p.next() != null ) {
8632 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8633 p.setSource( p2_str );
8634 if ( !p.hasNext() ) {
8637 Phylogeny p2_0 = p.next();
8638 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8639 System.out.println( p2_0.toNewHampshire() );
8642 if ( !p.hasNext() ) {
8645 Phylogeny p2_1 = p.next();
8646 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8647 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8650 if ( !p.hasNext() ) {
8653 Phylogeny p2_2 = p.next();
8654 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8655 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8658 if ( !p.hasNext() ) {
8661 Phylogeny p2_3 = p.next();
8662 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8663 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8666 if ( !p.hasNext() ) {
8669 Phylogeny p2_4 = p.next();
8670 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8671 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8674 if ( p.hasNext() ) {
8677 if ( p.next() != null ) {
8682 if ( !p.hasNext() ) {
8686 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8687 System.out.println( p2_0.toNewHampshire() );
8690 if ( !p.hasNext() ) {
8694 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8695 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8698 if ( !p.hasNext() ) {
8702 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8703 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8706 if ( !p.hasNext() ) {
8710 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8711 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8714 if ( !p.hasNext() ) {
8718 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8719 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8722 if ( p.hasNext() ) {
8725 if ( p.next() != null ) {
8729 final String p3_str = "((A,B),C)abc";
8730 p.setSource( p3_str );
8731 if ( !p.hasNext() ) {
8734 final Phylogeny p3_0 = p.next();
8735 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8738 if ( p.hasNext() ) {
8741 if ( p.next() != null ) {
8745 final String p4_str = "((A,B)ab,C)abc";
8746 p.setSource( p4_str );
8747 if ( !p.hasNext() ) {
8750 final Phylogeny p4_0 = p.next();
8751 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8754 if ( p.hasNext() ) {
8757 if ( p.next() != null ) {
8761 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8762 p.setSource( p5_str );
8763 if ( !p.hasNext() ) {
8766 final Phylogeny p5_0 = p.next();
8767 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8770 if ( p.hasNext() ) {
8773 if ( p.next() != null ) {
8777 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8778 p.setSource( p6_str );
8779 if ( !p.hasNext() ) {
8782 Phylogeny p6_0 = p.next();
8783 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8786 if ( p.hasNext() ) {
8789 if ( p.next() != null ) {
8793 if ( !p.hasNext() ) {
8797 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8800 if ( p.hasNext() ) {
8803 if ( p.next() != null ) {
8807 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8808 p.setSource( p7_str );
8809 if ( !p.hasNext() ) {
8812 Phylogeny p7_0 = p.next();
8813 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8816 if ( p.hasNext() ) {
8819 if ( p.next() != null ) {
8823 if ( !p.hasNext() ) {
8827 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8830 if ( p.hasNext() ) {
8833 if ( p.next() != null ) {
8837 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8838 p.setSource( p8_str );
8839 if ( !p.hasNext() ) {
8842 Phylogeny p8_0 = p.next();
8843 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8846 if ( !p.hasNext() ) {
8849 if ( !p.hasNext() ) {
8852 Phylogeny p8_1 = p.next();
8853 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8856 if ( p.hasNext() ) {
8859 if ( p.next() != null ) {
8863 if ( !p.hasNext() ) {
8867 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8870 if ( !p.hasNext() ) {
8874 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8877 if ( p.hasNext() ) {
8880 if ( p.next() != null ) {
8886 if ( p.hasNext() ) {
8890 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8891 if ( !p.hasNext() ) {
8894 Phylogeny p_27 = p.next();
8895 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8896 System.out.println( p_27.toNewHampshireX() );
8900 if ( p.hasNext() ) {
8903 if ( p.next() != null ) {
8907 if ( !p.hasNext() ) {
8911 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8912 System.out.println( p_27.toNewHampshireX() );
8916 if ( p.hasNext() ) {
8919 if ( p.next() != null ) {
8923 final String p30_str = "(A,B);(C,D)";
8924 final NHXParser p30 = new NHXParser();
8925 p30.setSource( p30_str );
8926 if ( !p30.hasNext() ) {
8929 Phylogeny phy30 = p30.next();
8930 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8931 System.out.println( phy30.toNewHampshire() );
8934 if ( !p30.hasNext() ) {
8937 Phylogeny phy301 = p30.next();
8938 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8939 System.out.println( phy301.toNewHampshire() );
8942 if ( p30.hasNext() ) {
8945 if ( p30.hasNext() ) {
8948 if ( p30.next() != null ) {
8951 if ( p30.next() != null ) {
8955 if ( !p30.hasNext() ) {
8959 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8960 System.out.println( phy30.toNewHampshire() );
8963 if ( !p30.hasNext() ) {
8966 phy301 = p30.next();
8967 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8968 System.out.println( phy301.toNewHampshire() );
8971 if ( p30.hasNext() ) {
8974 if ( p30.hasNext() ) {
8977 if ( p30.next() != null ) {
8980 if ( p30.next() != null ) {
8984 catch ( final Exception e ) {
8985 e.printStackTrace( System.out );
8991 private static boolean testNHXconversion() {
8993 final PhylogenyNode n1 = new PhylogenyNode();
8994 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8995 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8996 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8997 final PhylogenyNode n5 = PhylogenyNode
8998 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8999 final PhylogenyNode n6 = PhylogenyNode
9000 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
9001 if ( !n1.toNewHampshireX().equals( "" ) ) {
9004 if ( !n2.toNewHampshireX().equals( "" ) ) {
9007 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
9010 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
9013 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
9016 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
9017 System.out.println( n6.toNewHampshireX() );
9020 final PhylogenyNode n7 = new PhylogenyNode();
9021 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
9022 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9023 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
9024 System.out.println( n7
9025 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
9029 catch ( final Exception e ) {
9030 e.printStackTrace( System.out );
9036 private static boolean testNHXNodeParsing() {
9038 final PhylogenyNode n1 = new PhylogenyNode();
9039 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9040 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9041 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9042 final PhylogenyNode n5 = PhylogenyNode
9043 .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]" );
9044 if ( !n3.getName().equals( "n3" ) ) {
9047 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9050 if ( n3.isDuplication() ) {
9053 if ( n3.isHasAssignedEvent() ) {
9056 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
9059 if ( !n4.getName().equals( "n4" ) ) {
9062 if ( n4.getDistanceToParent() != 0.01 ) {
9065 if ( !n5.getName().equals( "n5" ) ) {
9068 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
9071 if ( n5.getDistanceToParent() != 0.1 ) {
9074 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
9077 if ( !n5.isDuplication() ) {
9080 if ( !n5.isHasAssignedEvent() ) {
9083 final PhylogenyNode n8 = PhylogenyNode
9084 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
9085 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9086 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9089 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
9092 final PhylogenyNode n9 = PhylogenyNode
9093 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
9094 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9095 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
9098 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9101 final PhylogenyNode n10 = PhylogenyNode
9102 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9103 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9106 final PhylogenyNode n20 = PhylogenyNode
9107 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9108 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9111 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9114 final PhylogenyNode n20x = PhylogenyNode
9115 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9116 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9119 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9122 final PhylogenyNode n20xx = PhylogenyNode
9123 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9124 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9127 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9130 final PhylogenyNode n20xxx = PhylogenyNode
9131 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9132 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9135 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9138 final PhylogenyNode n20xxxx = PhylogenyNode
9139 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9140 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9143 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9146 final PhylogenyNode n21 = PhylogenyNode
9147 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9148 if ( !n21.getName().equals( "N21_PIG" ) ) {
9151 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9154 final PhylogenyNode n21x = PhylogenyNode
9155 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9156 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9159 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9162 final PhylogenyNode n22 = PhylogenyNode
9163 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9164 if ( !n22.getName().equals( "n22/PIG" ) ) {
9167 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9170 final PhylogenyNode n23 = PhylogenyNode
9171 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9172 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9175 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9178 final PhylogenyNode a = PhylogenyNode
9179 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9180 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9183 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9186 final PhylogenyNode c1 = PhylogenyNode
9187 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9188 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9189 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9192 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9195 final PhylogenyNode c2 = PhylogenyNode
9196 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9197 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9198 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9201 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9204 final PhylogenyNode e3 = PhylogenyNode
9205 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9206 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9209 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9212 final PhylogenyNode n11 = PhylogenyNode
9213 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9214 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9215 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9218 if ( n11.getDistanceToParent() != 0.4 ) {
9221 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9224 final PhylogenyNode n12 = PhylogenyNode
9225 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9226 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9227 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9230 if ( n12.getDistanceToParent() != 0.4 ) {
9233 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9236 final PhylogenyNode o = PhylogenyNode
9237 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9238 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9241 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9244 if ( n1.getName().compareTo( "" ) != 0 ) {
9247 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9250 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9253 if ( n2.getName().compareTo( "" ) != 0 ) {
9256 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9259 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9262 final PhylogenyNode n00 = PhylogenyNode
9263 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9264 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9267 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9270 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9271 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9274 final PhylogenyNode n13 = PhylogenyNode
9275 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9276 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9279 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9282 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9285 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9288 final PhylogenyNode n14 = PhylogenyNode
9289 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9290 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9293 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9296 final PhylogenyNode n15 = PhylogenyNode
9297 .createInstanceFromNhxString( "something_wicked[123]",
9298 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9299 if ( !n15.getName().equals( "something_wicked" ) ) {
9302 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9305 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9308 final PhylogenyNode n16 = PhylogenyNode
9309 .createInstanceFromNhxString( "something_wicked2[9]",
9310 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9311 if ( !n16.getName().equals( "something_wicked2" ) ) {
9314 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9317 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9320 final PhylogenyNode n17 = PhylogenyNode
9321 .createInstanceFromNhxString( "something_wicked3[a]",
9322 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9323 if ( !n17.getName().equals( "something_wicked3" ) ) {
9326 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9329 final PhylogenyNode n18 = PhylogenyNode
9330 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9331 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9334 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9337 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9340 final PhylogenyNode n19 = PhylogenyNode
9341 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9342 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9345 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9348 final PhylogenyNode n30 = PhylogenyNode
9349 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9350 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9351 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9354 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9357 final PhylogenyNode n31 = PhylogenyNode
9358 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9359 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9360 if ( n31.getNodeData().isHasTaxonomy() ) {
9363 final PhylogenyNode n32 = PhylogenyNode
9364 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9365 if ( n32.getNodeData().isHasTaxonomy() ) {
9368 final PhylogenyNode n40 = PhylogenyNode
9369 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9370 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9373 final PhylogenyNode n41 = PhylogenyNode
9374 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9375 if ( n41.getNodeData().isHasTaxonomy() ) {
9378 final PhylogenyNode n42 = PhylogenyNode
9379 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9380 if ( n42.getNodeData().isHasTaxonomy() ) {
9383 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9384 NHXParser.TAXONOMY_EXTRACTION.NO );
9385 if ( n43.getNodeData().isHasTaxonomy() ) {
9388 final PhylogenyNode n44 = PhylogenyNode
9389 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9390 if ( n44.getNodeData().isHasTaxonomy() ) {
9394 catch ( final Exception e ) {
9395 e.printStackTrace( System.out );
9401 private static boolean testNHXParsing() {
9403 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9404 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9405 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9408 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]";
9409 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9410 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9413 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]";
9414 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9415 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9418 final Phylogeny[] p3 = factory
9419 .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]",
9421 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9424 final Phylogeny[] p4 = factory
9425 .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(]",
9427 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9430 final Phylogeny[] p5 = factory
9431 .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(((]",
9433 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9436 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)";
9437 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)";
9438 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9439 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9442 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)))";
9443 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)))";
9444 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9445 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9448 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]) ))[,,, ])))))))";
9449 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9450 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9451 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9454 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9455 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9458 final Phylogeny p10 = factory
9459 .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]",
9460 new NHXParser() )[ 0 ];
9461 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9464 final Phylogeny p11 = factory
9465 .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]",
9466 new NHXParser() )[ 0 ];
9467 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9470 final Phylogeny p12 = factory.create( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]",
9471 new NHXParser() )[ 0 ];
9472 if ( !p12.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9476 catch ( final Exception e ) {
9477 e.printStackTrace( System.out );
9483 private static boolean testNHXParsingMB() {
9485 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9486 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9487 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9488 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9489 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9490 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9491 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9492 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9493 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9494 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9495 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9498 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9501 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9502 0.1100000000000000e+00 ) ) {
9505 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9508 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9511 final Phylogeny p2 = factory
9512 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9513 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9514 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9515 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9516 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9517 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9518 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9519 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9520 + "7.369400000000000e-02}])",
9521 new NHXParser() )[ 0 ];
9522 if ( p2.getNode( "1" ) == null ) {
9525 if ( p2.getNode( "2" ) == null ) {
9529 catch ( final Exception e ) {
9530 e.printStackTrace( System.out );
9537 private static boolean testNHXParsingQuotes() {
9539 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9540 final NHXParser p = new NHXParser();
9541 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9542 if ( phylogenies_0.length != 5 ) {
9545 final Phylogeny phy = phylogenies_0[ 4 ];
9546 if ( phy.getNumberOfExternalNodes() != 7 ) {
9549 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9552 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9555 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9556 .getScientificName().equals( "hsapiens" ) ) {
9559 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9562 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9565 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9568 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9571 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9574 final NHXParser p1p = new NHXParser();
9575 p1p.setIgnoreQuotes( true );
9576 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9577 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9580 final NHXParser p2p = new NHXParser();
9581 p1p.setIgnoreQuotes( false );
9582 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9583 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9586 final NHXParser p3p = new NHXParser();
9587 p3p.setIgnoreQuotes( false );
9588 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9589 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9592 final NHXParser p4p = new NHXParser();
9593 p4p.setIgnoreQuotes( false );
9594 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9595 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9598 final Phylogeny p10 = factory
9599 .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]",
9600 new NHXParser() )[ 0 ];
9601 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]";
9602 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9605 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9606 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9609 final Phylogeny p12 = factory
9610 .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]",
9611 new NHXParser() )[ 0 ];
9612 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]";
9613 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9616 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9617 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9620 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;";
9621 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9624 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9625 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9629 catch ( final Exception e ) {
9630 e.printStackTrace( System.out );
9636 private static boolean testNodeRemoval() {
9638 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9639 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9640 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9641 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9644 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9645 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9646 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9649 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9650 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9651 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9655 catch ( final Exception e ) {
9656 e.printStackTrace( System.out );
9662 private static boolean testPhylogenyBranch() {
9664 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9665 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9666 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9667 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9668 if ( !a1b1.equals( a1b1 ) ) {
9671 if ( !a1b1.equals( b1a1 ) ) {
9674 if ( !b1a1.equals( a1b1 ) ) {
9677 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9678 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9679 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9680 if ( a1_b1.equals( b1_a1 ) ) {
9683 if ( a1_b1.equals( a1_b1_ ) ) {
9686 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9687 if ( !a1_b1.equals( b1_a1_ ) ) {
9690 if ( a1_b1_.equals( b1_a1_ ) ) {
9693 if ( !a1_b1_.equals( b1_a1 ) ) {
9697 catch ( final Exception e ) {
9698 e.printStackTrace( System.out );
9704 private static boolean testPhyloXMLparsingOfDistributionElement() {
9706 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9707 PhyloXmlParser xml_parser = null;
9709 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9711 catch ( final Exception e ) {
9712 // Do nothing -- means were not running from jar.
9714 if ( xml_parser == null ) {
9715 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9716 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9717 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9720 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9723 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9725 if ( xml_parser.getErrorCount() > 0 ) {
9726 System.out.println( xml_parser.getErrorMessages().toString() );
9729 if ( phylogenies_0.length != 1 ) {
9732 final Phylogeny t1 = phylogenies_0[ 0 ];
9733 PhylogenyNode n = null;
9734 Distribution d = null;
9735 n = t1.getNode( "root node" );
9736 if ( !n.getNodeData().isHasDistribution() ) {
9739 if ( n.getNodeData().getDistributions().size() != 1 ) {
9742 d = n.getNodeData().getDistribution();
9743 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9746 if ( d.getPoints().size() != 1 ) {
9749 if ( d.getPolygons() != null ) {
9752 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9755 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9758 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9761 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9764 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9767 n = t1.getNode( "node a" );
9768 if ( !n.getNodeData().isHasDistribution() ) {
9771 if ( n.getNodeData().getDistributions().size() != 2 ) {
9774 d = n.getNodeData().getDistribution( 1 );
9775 if ( !d.getDesc().equals( "San Diego" ) ) {
9778 if ( d.getPoints().size() != 1 ) {
9781 if ( d.getPolygons() != null ) {
9784 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9787 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9790 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9793 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9796 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9799 n = t1.getNode( "node bb" );
9800 if ( !n.getNodeData().isHasDistribution() ) {
9803 if ( n.getNodeData().getDistributions().size() != 1 ) {
9806 d = n.getNodeData().getDistribution( 0 );
9807 if ( d.getPoints().size() != 3 ) {
9810 if ( d.getPolygons().size() != 2 ) {
9813 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9816 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9819 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9822 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9825 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9828 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9831 Polygon p = d.getPolygons().get( 0 );
9832 if ( p.getPoints().size() != 3 ) {
9835 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9838 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9841 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9844 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9847 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9850 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9853 p = d.getPolygons().get( 1 );
9854 if ( p.getPoints().size() != 3 ) {
9857 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9860 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9863 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9867 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9868 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9869 if ( rt.length != 1 ) {
9872 final Phylogeny t1_rt = rt[ 0 ];
9873 n = t1_rt.getNode( "root node" );
9874 if ( !n.getNodeData().isHasDistribution() ) {
9877 if ( n.getNodeData().getDistributions().size() != 1 ) {
9880 d = n.getNodeData().getDistribution();
9881 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9884 if ( d.getPoints().size() != 1 ) {
9887 if ( d.getPolygons() != null ) {
9890 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9893 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9896 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9899 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9902 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9905 n = t1_rt.getNode( "node a" );
9906 if ( !n.getNodeData().isHasDistribution() ) {
9909 if ( n.getNodeData().getDistributions().size() != 2 ) {
9912 d = n.getNodeData().getDistribution( 1 );
9913 if ( !d.getDesc().equals( "San Diego" ) ) {
9916 if ( d.getPoints().size() != 1 ) {
9919 if ( d.getPolygons() != null ) {
9922 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9925 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9928 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9931 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9934 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9937 n = t1_rt.getNode( "node bb" );
9938 if ( !n.getNodeData().isHasDistribution() ) {
9941 if ( n.getNodeData().getDistributions().size() != 1 ) {
9944 d = n.getNodeData().getDistribution( 0 );
9945 if ( d.getPoints().size() != 3 ) {
9948 if ( d.getPolygons().size() != 2 ) {
9951 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9954 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9957 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9960 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9963 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9966 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9969 p = d.getPolygons().get( 0 );
9970 if ( p.getPoints().size() != 3 ) {
9973 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9976 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9979 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9982 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9985 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9988 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9991 p = d.getPolygons().get( 1 );
9992 if ( p.getPoints().size() != 3 ) {
9995 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9998 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10001 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10005 catch ( final Exception e ) {
10006 e.printStackTrace( System.out );
10012 private static boolean testPostOrderIterator() {
10014 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10015 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10016 PhylogenyNodeIterator it0;
10017 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
10020 for( it0.reset(); it0.hasNext(); ) {
10023 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10024 final PhylogenyNodeIterator it = t1.iteratorPostorder();
10025 if ( !it.next().getName().equals( "A" ) ) {
10028 if ( !it.next().getName().equals( "B" ) ) {
10031 if ( !it.next().getName().equals( "ab" ) ) {
10034 if ( !it.next().getName().equals( "C" ) ) {
10037 if ( !it.next().getName().equals( "D" ) ) {
10040 if ( !it.next().getName().equals( "cd" ) ) {
10043 if ( !it.next().getName().equals( "abcd" ) ) {
10046 if ( !it.next().getName().equals( "E" ) ) {
10049 if ( !it.next().getName().equals( "F" ) ) {
10052 if ( !it.next().getName().equals( "ef" ) ) {
10055 if ( !it.next().getName().equals( "G" ) ) {
10058 if ( !it.next().getName().equals( "H" ) ) {
10061 if ( !it.next().getName().equals( "gh" ) ) {
10064 if ( !it.next().getName().equals( "efgh" ) ) {
10067 if ( !it.next().getName().equals( "r" ) ) {
10070 if ( it.hasNext() ) {
10074 catch ( final Exception e ) {
10075 e.printStackTrace( System.out );
10081 private static boolean testPreOrderIterator() {
10083 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10084 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10085 PhylogenyNodeIterator it0;
10086 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
10089 for( it0.reset(); it0.hasNext(); ) {
10092 PhylogenyNodeIterator it = t0.iteratorPreorder();
10093 if ( !it.next().getName().equals( "r" ) ) {
10096 if ( !it.next().getName().equals( "ab" ) ) {
10099 if ( !it.next().getName().equals( "A" ) ) {
10102 if ( !it.next().getName().equals( "B" ) ) {
10105 if ( !it.next().getName().equals( "cd" ) ) {
10108 if ( !it.next().getName().equals( "C" ) ) {
10111 if ( !it.next().getName().equals( "D" ) ) {
10114 if ( it.hasNext() ) {
10117 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10118 it = t1.iteratorPreorder();
10119 if ( !it.next().getName().equals( "r" ) ) {
10122 if ( !it.next().getName().equals( "abcd" ) ) {
10125 if ( !it.next().getName().equals( "ab" ) ) {
10128 if ( !it.next().getName().equals( "A" ) ) {
10131 if ( !it.next().getName().equals( "B" ) ) {
10134 if ( !it.next().getName().equals( "cd" ) ) {
10137 if ( !it.next().getName().equals( "C" ) ) {
10140 if ( !it.next().getName().equals( "D" ) ) {
10143 if ( !it.next().getName().equals( "efgh" ) ) {
10146 if ( !it.next().getName().equals( "ef" ) ) {
10149 if ( !it.next().getName().equals( "E" ) ) {
10152 if ( !it.next().getName().equals( "F" ) ) {
10155 if ( !it.next().getName().equals( "gh" ) ) {
10158 if ( !it.next().getName().equals( "G" ) ) {
10161 if ( !it.next().getName().equals( "H" ) ) {
10164 if ( it.hasNext() ) {
10168 catch ( final Exception e ) {
10169 e.printStackTrace( System.out );
10175 private static boolean testPropertiesMap() {
10177 final PropertiesMap pm = new PropertiesMap();
10178 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10179 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10180 final Property p2 = new Property( "something:else",
10182 "improbable:research",
10185 pm.addProperty( p0 );
10186 pm.addProperty( p1 );
10187 pm.addProperty( p2 );
10188 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
10191 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
10194 if ( pm.getProperties().size() != 3 ) {
10197 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10200 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10203 if ( pm.getProperties().size() != 3 ) {
10206 pm.removeProperty( "dimensions:diameter" );
10207 if ( pm.getProperties().size() != 2 ) {
10210 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
10213 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10217 catch ( final Exception e ) {
10218 e.printStackTrace( System.out );
10224 private static boolean testProteinId() {
10226 final ProteinId id1 = new ProteinId( "a" );
10227 final ProteinId id2 = new ProteinId( "a" );
10228 final ProteinId id3 = new ProteinId( "A" );
10229 final ProteinId id4 = new ProteinId( "b" );
10230 if ( !id1.equals( id1 ) ) {
10233 if ( id1.getId().equals( "x" ) ) {
10236 if ( id1.getId().equals( null ) ) {
10239 if ( !id1.equals( id2 ) ) {
10242 if ( id1.equals( id3 ) ) {
10245 if ( id1.hashCode() != id1.hashCode() ) {
10248 if ( id1.hashCode() != id2.hashCode() ) {
10251 if ( id1.hashCode() == id3.hashCode() ) {
10254 if ( id1.compareTo( id1 ) != 0 ) {
10257 if ( id1.compareTo( id2 ) != 0 ) {
10260 if ( id1.compareTo( id3 ) != 0 ) {
10263 if ( id1.compareTo( id4 ) >= 0 ) {
10266 if ( id4.compareTo( id1 ) <= 0 ) {
10269 if ( !id4.getId().equals( "b" ) ) {
10272 final ProteinId id5 = new ProteinId( " C " );
10273 if ( !id5.getId().equals( "C" ) ) {
10276 if ( id5.equals( id1 ) ) {
10280 catch ( final Exception e ) {
10281 e.printStackTrace( System.out );
10287 private static boolean testReIdMethods() {
10289 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10290 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10291 final long count = PhylogenyNode.getNodeCount();
10292 p.levelOrderReID();
10293 if ( p.getNode( "r" ).getId() != count ) {
10296 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10299 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10302 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10305 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10308 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10311 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10314 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10317 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10320 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10323 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10326 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10329 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10332 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10335 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10339 catch ( final Exception e ) {
10340 e.printStackTrace( System.out );
10346 private static boolean testRerooting() {
10348 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10349 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",
10350 new NHXParser() )[ 0 ];
10351 if ( !t1.isRooted() ) {
10354 t1.reRoot( t1.getNode( "D" ) );
10355 t1.reRoot( t1.getNode( "CD" ) );
10356 t1.reRoot( t1.getNode( "A" ) );
10357 t1.reRoot( t1.getNode( "B" ) );
10358 t1.reRoot( t1.getNode( "AB" ) );
10359 t1.reRoot( t1.getNode( "D" ) );
10360 t1.reRoot( t1.getNode( "C" ) );
10361 t1.reRoot( t1.getNode( "CD" ) );
10362 t1.reRoot( t1.getNode( "A" ) );
10363 t1.reRoot( t1.getNode( "B" ) );
10364 t1.reRoot( t1.getNode( "AB" ) );
10365 t1.reRoot( t1.getNode( "D" ) );
10366 t1.reRoot( t1.getNode( "D" ) );
10367 t1.reRoot( t1.getNode( "C" ) );
10368 t1.reRoot( t1.getNode( "A" ) );
10369 t1.reRoot( t1.getNode( "B" ) );
10370 t1.reRoot( t1.getNode( "AB" ) );
10371 t1.reRoot( t1.getNode( "C" ) );
10372 t1.reRoot( t1.getNode( "D" ) );
10373 t1.reRoot( t1.getNode( "CD" ) );
10374 t1.reRoot( t1.getNode( "D" ) );
10375 t1.reRoot( t1.getNode( "A" ) );
10376 t1.reRoot( t1.getNode( "B" ) );
10377 t1.reRoot( t1.getNode( "AB" ) );
10378 t1.reRoot( t1.getNode( "C" ) );
10379 t1.reRoot( t1.getNode( "D" ) );
10380 t1.reRoot( t1.getNode( "CD" ) );
10381 t1.reRoot( t1.getNode( "D" ) );
10382 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10385 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10388 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10391 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10394 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10397 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10400 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",
10401 new NHXParser() )[ 0 ];
10402 t2.reRoot( t2.getNode( "A" ) );
10403 t2.reRoot( t2.getNode( "D" ) );
10404 t2.reRoot( t2.getNode( "ABC" ) );
10405 t2.reRoot( t2.getNode( "A" ) );
10406 t2.reRoot( t2.getNode( "B" ) );
10407 t2.reRoot( t2.getNode( "D" ) );
10408 t2.reRoot( t2.getNode( "C" ) );
10409 t2.reRoot( t2.getNode( "ABC" ) );
10410 t2.reRoot( t2.getNode( "A" ) );
10411 t2.reRoot( t2.getNode( "B" ) );
10412 t2.reRoot( t2.getNode( "AB" ) );
10413 t2.reRoot( t2.getNode( "AB" ) );
10414 t2.reRoot( t2.getNode( "D" ) );
10415 t2.reRoot( t2.getNode( "C" ) );
10416 t2.reRoot( t2.getNode( "B" ) );
10417 t2.reRoot( t2.getNode( "AB" ) );
10418 t2.reRoot( t2.getNode( "D" ) );
10419 t2.reRoot( t2.getNode( "D" ) );
10420 t2.reRoot( t2.getNode( "ABC" ) );
10421 t2.reRoot( t2.getNode( "A" ) );
10422 t2.reRoot( t2.getNode( "B" ) );
10423 t2.reRoot( t2.getNode( "AB" ) );
10424 t2.reRoot( t2.getNode( "D" ) );
10425 t2.reRoot( t2.getNode( "C" ) );
10426 t2.reRoot( t2.getNode( "ABC" ) );
10427 t2.reRoot( t2.getNode( "A" ) );
10428 t2.reRoot( t2.getNode( "B" ) );
10429 t2.reRoot( t2.getNode( "AB" ) );
10430 t2.reRoot( t2.getNode( "D" ) );
10431 t2.reRoot( t2.getNode( "D" ) );
10432 t2.reRoot( t2.getNode( "C" ) );
10433 t2.reRoot( t2.getNode( "A" ) );
10434 t2.reRoot( t2.getNode( "B" ) );
10435 t2.reRoot( t2.getNode( "AB" ) );
10436 t2.reRoot( t2.getNode( "C" ) );
10437 t2.reRoot( t2.getNode( "D" ) );
10438 t2.reRoot( t2.getNode( "ABC" ) );
10439 t2.reRoot( t2.getNode( "D" ) );
10440 t2.reRoot( t2.getNode( "A" ) );
10441 t2.reRoot( t2.getNode( "B" ) );
10442 t2.reRoot( t2.getNode( "AB" ) );
10443 t2.reRoot( t2.getNode( "C" ) );
10444 t2.reRoot( t2.getNode( "D" ) );
10445 t2.reRoot( t2.getNode( "ABC" ) );
10446 t2.reRoot( t2.getNode( "D" ) );
10447 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10450 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10453 t2.reRoot( t2.getNode( "ABC" ) );
10454 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10457 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10460 t2.reRoot( t2.getNode( "AB" ) );
10461 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10464 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10467 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10470 t2.reRoot( t2.getNode( "AB" ) );
10471 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10474 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10477 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10480 t2.reRoot( t2.getNode( "D" ) );
10481 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10484 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10487 t2.reRoot( t2.getNode( "ABC" ) );
10488 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10491 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10494 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10495 new NHXParser() )[ 0 ];
10496 t3.reRoot( t3.getNode( "B" ) );
10497 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10500 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10503 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10506 t3.reRoot( t3.getNode( "B" ) );
10507 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10510 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10513 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10516 t3.reRoot( t3.getRoot() );
10517 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10520 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10523 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10527 catch ( final Exception e ) {
10528 e.printStackTrace( System.out );
10534 private static boolean testSDIse() {
10536 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10537 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10538 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10539 gene1.setRooted( true );
10540 species1.setRooted( true );
10541 final SDI sdi = new SDI( gene1, species1 );
10542 if ( !gene1.getRoot().isDuplication() ) {
10545 final Phylogeny species2 = factory
10546 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10547 new NHXParser() )[ 0 ];
10548 final Phylogeny gene2 = factory
10549 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10550 new NHXParser() )[ 0 ];
10551 species2.setRooted( true );
10552 gene2.setRooted( true );
10553 final SDI sdi2 = new SDI( gene2, species2 );
10554 if ( sdi2.getDuplicationsSum() != 0 ) {
10557 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10560 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10563 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10566 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10569 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10572 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10575 final Phylogeny species3 = factory
10576 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10577 new NHXParser() )[ 0 ];
10578 final Phylogeny gene3 = factory
10579 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10580 new NHXParser() )[ 0 ];
10581 species3.setRooted( true );
10582 gene3.setRooted( true );
10583 final SDI sdi3 = new SDI( gene3, species3 );
10584 if ( sdi3.getDuplicationsSum() != 1 ) {
10587 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10590 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10593 final Phylogeny species4 = factory
10594 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10595 new NHXParser() )[ 0 ];
10596 final Phylogeny gene4 = factory
10597 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10598 new NHXParser() )[ 0 ];
10599 species4.setRooted( true );
10600 gene4.setRooted( true );
10601 final SDI sdi4 = new SDI( gene4, species4 );
10602 if ( sdi4.getDuplicationsSum() != 1 ) {
10605 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10608 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10611 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10614 if ( species4.getNumberOfExternalNodes() != 6 ) {
10617 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10620 final Phylogeny species5 = factory
10621 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10622 new NHXParser() )[ 0 ];
10623 final Phylogeny gene5 = factory
10624 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10625 new NHXParser() )[ 0 ];
10626 species5.setRooted( true );
10627 gene5.setRooted( true );
10628 final SDI sdi5 = new SDI( gene5, species5 );
10629 if ( sdi5.getDuplicationsSum() != 2 ) {
10632 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10635 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10638 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10641 if ( species5.getNumberOfExternalNodes() != 6 ) {
10644 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10647 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10648 // Conjecture for Comparing Molecular Phylogenies"
10649 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10650 final Phylogeny species6 = factory
10651 .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,"
10652 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10653 new NHXParser() )[ 0 ];
10654 final Phylogeny gene6 = factory
10655 .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,"
10656 + "((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,"
10657 + "(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;",
10658 new NHXParser() )[ 0 ];
10659 species6.setRooted( true );
10660 gene6.setRooted( true );
10661 final SDI sdi6 = new SDI( gene6, species6 );
10662 if ( sdi6.getDuplicationsSum() != 3 ) {
10665 if ( !gene6.getNode( "r" ).isDuplication() ) {
10668 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10671 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10674 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10677 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10680 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10683 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10686 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10689 sdi6.computeMappingCostL();
10690 if ( sdi6.computeMappingCostL() != 17 ) {
10693 if ( species6.getNumberOfExternalNodes() != 9 ) {
10696 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10699 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10700 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10701 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10702 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10703 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10704 species7.setRooted( true );
10705 final Phylogeny gene7_1 = 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]),e1[&&NHX:S=e1]),y[&&NHX:S=y]),z[&&NHX:S=z])" );
10707 gene7_1.setRooted( true );
10708 final SDI sdi7 = new SDI( gene7_1, species7 );
10709 if ( sdi7.getDuplicationsSum() != 0 ) {
10712 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10715 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10718 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10721 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10724 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10727 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10730 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10733 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10736 final Phylogeny gene7_2 = Test
10737 .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])" );
10738 gene7_2.setRooted( true );
10739 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10740 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10743 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10746 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10749 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10752 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10755 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10758 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10761 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10764 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10767 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10771 catch ( final Exception e ) {
10777 private static boolean testSDIunrooted() {
10779 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10780 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10781 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10782 final Iterator<PhylogenyBranch> iter = l.iterator();
10783 PhylogenyBranch br = iter.next();
10784 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10787 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10791 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10794 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10798 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10801 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10805 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10808 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10812 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10815 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10819 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10822 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10826 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10829 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10833 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10836 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10840 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10843 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10847 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10850 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10854 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10857 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10861 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10864 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10868 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10871 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10875 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10878 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10882 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10885 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10888 if ( iter.hasNext() ) {
10891 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10892 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10893 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10895 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10898 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10902 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10905 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10909 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10912 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10915 if ( iter1.hasNext() ) {
10918 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10919 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10920 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10922 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10925 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10929 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10932 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10936 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10939 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10942 if ( iter2.hasNext() ) {
10945 final Phylogeny species0 = factory
10946 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10947 new NHXParser() )[ 0 ];
10948 final Phylogeny gene1 = factory
10949 .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])",
10950 new NHXParser() )[ 0 ];
10951 species0.setRooted( true );
10952 gene1.setRooted( true );
10953 final SDIR sdi_unrooted = new SDIR();
10954 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10955 if ( sdi_unrooted.getCount() != 1 ) {
10958 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10961 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10964 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10967 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10970 final Phylogeny gene2 = factory
10971 .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])",
10972 new NHXParser() )[ 0 ];
10973 gene2.setRooted( true );
10974 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10975 if ( sdi_unrooted.getCount() != 1 ) {
10978 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10981 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10984 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10987 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10990 final Phylogeny species6 = factory
10991 .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,"
10992 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10993 new NHXParser() )[ 0 ];
10994 final Phylogeny gene6 = factory
10995 .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],"
10996 + "(((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],"
10997 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10998 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10999 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11000 new NHXParser() )[ 0 ];
11001 species6.setRooted( true );
11002 gene6.setRooted( true );
11003 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
11004 if ( sdi_unrooted.getCount() != 1 ) {
11007 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11010 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11013 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11016 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11019 if ( !p6[ 0 ].getRoot().isDuplication() ) {
11022 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11025 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11028 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
11031 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11034 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
11037 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
11040 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11044 final Phylogeny species7 = factory
11045 .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,"
11046 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11047 new NHXParser() )[ 0 ];
11048 final Phylogeny gene7 = factory
11049 .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],"
11050 + "(((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],"
11051 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11052 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11053 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11054 new NHXParser() )[ 0 ];
11055 species7.setRooted( true );
11056 gene7.setRooted( true );
11057 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
11058 if ( sdi_unrooted.getCount() != 1 ) {
11061 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11064 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11067 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11070 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
11073 if ( !p7[ 0 ].getRoot().isDuplication() ) {
11076 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11079 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11082 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
11085 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11088 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
11091 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
11094 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11098 final Phylogeny species8 = factory
11099 .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,"
11100 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11101 new NHXParser() )[ 0 ];
11102 final Phylogeny gene8 = factory
11103 .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],"
11104 + "(((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],"
11105 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11106 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11107 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11108 new NHXParser() )[ 0 ];
11109 species8.setRooted( true );
11110 gene8.setRooted( true );
11111 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
11112 if ( sdi_unrooted.getCount() != 1 ) {
11115 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11118 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11121 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11124 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11127 if ( !p8[ 0 ].getRoot().isDuplication() ) {
11130 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11133 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11136 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
11139 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11142 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
11145 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
11148 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11153 catch ( final Exception e ) {
11154 e.printStackTrace( System.out );
11160 private static boolean testSequenceDbWsTools1() {
11162 final PhylogenyNode n = new PhylogenyNode();
11163 n.setName( "NP_001025424" );
11164 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11165 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11166 || !acc.getValue().equals( "NP_001025424" ) ) {
11169 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11170 acc = SequenceDbWsTools.obtainSeqAccession( n );
11171 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11172 || !acc.getValue().equals( "NP_001025424" ) ) {
11175 n.setName( "NP_001025424.1" );
11176 acc = SequenceDbWsTools.obtainSeqAccession( n );
11177 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11178 || !acc.getValue().equals( "NP_001025424" ) ) {
11181 n.setName( "NM_001030253" );
11182 acc = SequenceDbWsTools.obtainSeqAccession( n );
11183 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11184 || !acc.getValue().equals( "NM_001030253" ) ) {
11187 n.setName( "BCL2_HUMAN" );
11188 acc = SequenceDbWsTools.obtainSeqAccession( n );
11189 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11190 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11191 System.out.println( acc.toString() );
11194 n.setName( "P10415" );
11195 acc = SequenceDbWsTools.obtainSeqAccession( n );
11196 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11197 || !acc.getValue().equals( "P10415" ) ) {
11198 System.out.println( acc.toString() );
11201 n.setName( " P10415 " );
11202 acc = SequenceDbWsTools.obtainSeqAccession( n );
11203 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11204 || !acc.getValue().equals( "P10415" ) ) {
11205 System.out.println( acc.toString() );
11208 n.setName( "_P10415|" );
11209 acc = SequenceDbWsTools.obtainSeqAccession( n );
11210 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11211 || !acc.getValue().equals( "P10415" ) ) {
11212 System.out.println( acc.toString() );
11215 n.setName( "AY695820" );
11216 acc = SequenceDbWsTools.obtainSeqAccession( n );
11217 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11218 || !acc.getValue().equals( "AY695820" ) ) {
11219 System.out.println( acc.toString() );
11222 n.setName( "_AY695820_" );
11223 acc = SequenceDbWsTools.obtainSeqAccession( n );
11224 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11225 || !acc.getValue().equals( "AY695820" ) ) {
11226 System.out.println( acc.toString() );
11229 n.setName( "AAA59452" );
11230 acc = SequenceDbWsTools.obtainSeqAccession( n );
11231 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11232 || !acc.getValue().equals( "AAA59452" ) ) {
11233 System.out.println( acc.toString() );
11236 n.setName( "_AAA59452_" );
11237 acc = SequenceDbWsTools.obtainSeqAccession( n );
11238 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11239 || !acc.getValue().equals( "AAA59452" ) ) {
11240 System.out.println( acc.toString() );
11243 n.setName( "AAA59452.1" );
11244 acc = SequenceDbWsTools.obtainSeqAccession( n );
11245 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11246 || !acc.getValue().equals( "AAA59452.1" ) ) {
11247 System.out.println( acc.toString() );
11250 n.setName( "_AAA59452.1_" );
11251 acc = SequenceDbWsTools.obtainSeqAccession( n );
11252 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11253 || !acc.getValue().equals( "AAA59452.1" ) ) {
11254 System.out.println( acc.toString() );
11257 n.setName( "GI:94894583" );
11258 acc = SequenceDbWsTools.obtainSeqAccession( n );
11259 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11260 || !acc.getValue().equals( "94894583" ) ) {
11261 System.out.println( acc.toString() );
11264 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11265 acc = SequenceDbWsTools.obtainSeqAccession( n );
11266 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11267 || !acc.getValue().equals( "71845847" ) ) {
11268 System.out.println( acc.toString() );
11271 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11272 acc = SequenceDbWsTools.obtainSeqAccession( n );
11273 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11274 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11275 System.out.println( acc.toString() );
11279 catch ( final Exception e ) {
11285 private static boolean testSequenceDbWsTools2() {
11287 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11288 SequenceDbWsTools.obtainSeqInformation( n1 );
11289 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11292 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11295 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11298 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11301 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11302 SequenceDbWsTools.obtainSeqInformation( n2 );
11303 if ( !n2.getNodeData().getSequence().getName().equals( "Danio rerio B-cell CLL/lymphoma 2a (bcl2a), mRNA" ) ) {
11306 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11309 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11312 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11315 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11316 SequenceDbWsTools.obtainSeqInformation( n3 );
11317 if ( !n3.getNodeData().getSequence().getName()
11318 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11321 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11324 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11327 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11331 catch ( final IOException e ) {
11332 System.out.println();
11333 System.out.println( "the following might be due to absence internet connection:" );
11334 e.printStackTrace( System.out );
11337 catch ( final Exception e ) {
11338 e.printStackTrace();
11344 private static boolean testSequenceIdParsing() {
11346 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11347 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11348 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11349 if ( id != null ) {
11350 System.out.println( "value =" + id.getValue() );
11351 System.out.println( "provider=" + id.getSource() );
11355 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11356 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11357 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11358 if ( id != null ) {
11359 System.out.println( "value =" + id.getValue() );
11360 System.out.println( "provider=" + id.getSource() );
11364 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11365 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11366 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11367 if ( id != null ) {
11368 System.out.println( "value =" + id.getValue() );
11369 System.out.println( "provider=" + id.getSource() );
11373 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11374 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11375 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11376 if ( id != null ) {
11377 System.out.println( "value =" + id.getValue() );
11378 System.out.println( "provider=" + id.getSource() );
11382 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11383 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11384 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11385 if ( id != null ) {
11386 System.out.println( "value =" + id.getValue() );
11387 System.out.println( "provider=" + id.getSource() );
11391 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11392 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11393 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11394 if ( id != null ) {
11395 System.out.println( "value =" + id.getValue() );
11396 System.out.println( "provider=" + id.getSource() );
11400 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11401 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11402 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11403 if ( id != null ) {
11404 System.out.println( "value =" + id.getValue() );
11405 System.out.println( "provider=" + id.getSource() );
11409 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11410 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11411 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11412 if ( id != null ) {
11413 System.out.println( "value =" + id.getValue() );
11414 System.out.println( "provider=" + id.getSource() );
11418 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11419 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11420 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11421 if ( id != null ) {
11422 System.out.println( "value =" + id.getValue() );
11423 System.out.println( "provider=" + id.getSource() );
11427 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11428 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11429 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11430 if ( id != null ) {
11431 System.out.println( "value =" + id.getValue() );
11432 System.out.println( "provider=" + id.getSource() );
11436 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11437 if ( id != null ) {
11438 System.out.println( "value =" + id.getValue() );
11439 System.out.println( "provider=" + id.getSource() );
11442 id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" );
11443 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11444 || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) {
11445 if ( id != null ) {
11446 System.out.println( "value =" + id.getValue() );
11447 System.out.println( "provider=" + id.getSource() );
11451 id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" );
11452 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11453 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
11454 if ( id != null ) {
11455 System.out.println( "value =" + id.getValue() );
11456 System.out.println( "provider=" + id.getSource() );
11460 id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" );
11461 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11462 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
11463 if ( id != null ) {
11464 System.out.println( "value =" + id.getValue() );
11465 System.out.println( "provider=" + id.getSource() );
11469 id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" );
11470 if ( id != null ) {
11471 System.out.println( "value =" + id.getValue() );
11472 System.out.println( "provider=" + id.getSource() );
11476 catch ( final Exception e ) {
11477 e.printStackTrace( System.out );
11483 private static boolean testSequenceWriter() {
11485 final String n = ForesterUtil.LINE_SEPARATOR;
11486 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11489 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11492 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11495 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11498 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11499 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11502 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11503 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11507 catch ( final Exception e ) {
11508 e.printStackTrace();
11514 private static boolean testSpecies() {
11516 final Species s1 = new BasicSpecies( "a" );
11517 final Species s2 = new BasicSpecies( "a" );
11518 final Species s3 = new BasicSpecies( "A" );
11519 final Species s4 = new BasicSpecies( "b" );
11520 if ( !s1.equals( s1 ) ) {
11523 if ( s1.getSpeciesId().equals( "x" ) ) {
11526 if ( s1.getSpeciesId().equals( null ) ) {
11529 if ( !s1.equals( s2 ) ) {
11532 if ( s1.equals( s3 ) ) {
11535 if ( s1.hashCode() != s1.hashCode() ) {
11538 if ( s1.hashCode() != s2.hashCode() ) {
11541 if ( s1.hashCode() == s3.hashCode() ) {
11544 if ( s1.compareTo( s1 ) != 0 ) {
11547 if ( s1.compareTo( s2 ) != 0 ) {
11550 if ( s1.compareTo( s3 ) != 0 ) {
11553 if ( s1.compareTo( s4 ) >= 0 ) {
11556 if ( s4.compareTo( s1 ) <= 0 ) {
11559 if ( !s4.getSpeciesId().equals( "b" ) ) {
11562 final Species s5 = new BasicSpecies( " C " );
11563 if ( !s5.getSpeciesId().equals( "C" ) ) {
11566 if ( s5.equals( s1 ) ) {
11570 catch ( final Exception e ) {
11571 e.printStackTrace( System.out );
11577 private static boolean testSplit() {
11579 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11580 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11581 //Archaeopteryx.createApplication( p0 );
11582 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11583 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11584 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11585 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11586 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11587 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11588 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11589 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11590 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11591 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11592 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11593 // System.out.println( s0.toString() );
11595 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11596 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11597 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11598 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 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11607 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11608 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11609 if ( !s0.match( query_nodes ) ) {
11613 query_nodes = new HashSet<PhylogenyNode>();
11614 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11615 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11616 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11617 if ( !s0.match( query_nodes ) ) {
11621 query_nodes = new HashSet<PhylogenyNode>();
11622 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11623 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11624 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11625 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11626 if ( !s0.match( query_nodes ) ) {
11630 query_nodes = new HashSet<PhylogenyNode>();
11631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11632 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11633 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11634 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11635 if ( !s0.match( query_nodes ) ) {
11639 query_nodes = new HashSet<PhylogenyNode>();
11640 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11641 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11642 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11643 if ( !s0.match( query_nodes ) ) {
11646 query_nodes = new HashSet<PhylogenyNode>();
11647 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11648 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11649 if ( !s0.match( query_nodes ) ) {
11652 query_nodes = new HashSet<PhylogenyNode>();
11653 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11654 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11655 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11656 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11657 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11658 if ( !s0.match( query_nodes ) ) {
11661 query_nodes = new HashSet<PhylogenyNode>();
11662 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11663 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11664 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11665 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 if ( !s0.match( query_nodes ) ) {
11676 query_nodes = new HashSet<PhylogenyNode>();
11677 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11678 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11679 if ( s0.match( query_nodes ) ) {
11682 query_nodes = new HashSet<PhylogenyNode>();
11683 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11684 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11685 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11686 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11687 if ( s0.match( query_nodes ) ) {
11690 query_nodes = new HashSet<PhylogenyNode>();
11691 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11692 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11693 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11694 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11695 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11696 if ( s0.match( query_nodes ) ) {
11699 query_nodes = new HashSet<PhylogenyNode>();
11700 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11701 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11702 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11703 if ( s0.match( query_nodes ) ) {
11706 query_nodes = new HashSet<PhylogenyNode>();
11707 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11708 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11709 if ( s0.match( query_nodes ) ) {
11712 query_nodes = new HashSet<PhylogenyNode>();
11713 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11714 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11715 if ( s0.match( query_nodes ) ) {
11718 query_nodes = new HashSet<PhylogenyNode>();
11719 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11720 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11721 if ( s0.match( query_nodes ) ) {
11724 query_nodes = new HashSet<PhylogenyNode>();
11725 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11726 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11727 if ( s0.match( query_nodes ) ) {
11730 query_nodes = new HashSet<PhylogenyNode>();
11731 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11732 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11733 if ( s0.match( query_nodes ) ) {
11736 query_nodes = new HashSet<PhylogenyNode>();
11737 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11738 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11739 if ( s0.match( query_nodes ) ) {
11742 query_nodes = new HashSet<PhylogenyNode>();
11743 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11744 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11746 if ( s0.match( query_nodes ) ) {
11749 query_nodes = new HashSet<PhylogenyNode>();
11750 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11751 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11752 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11753 if ( s0.match( query_nodes ) ) {
11756 query_nodes = new HashSet<PhylogenyNode>();
11757 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11758 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11759 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11760 if ( s0.match( query_nodes ) ) {
11763 query_nodes = new HashSet<PhylogenyNode>();
11764 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11765 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11766 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11767 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11768 if ( s0.match( query_nodes ) ) {
11772 // query_nodes = new HashSet<PhylogenyNode>();
11773 // query_nodes.add( new PhylogenyNode( "X" ) );
11774 // query_nodes.add( new PhylogenyNode( "Y" ) );
11775 // query_nodes.add( new PhylogenyNode( "A" ) );
11776 // query_nodes.add( new PhylogenyNode( "B" ) );
11777 // query_nodes.add( new PhylogenyNode( "C" ) );
11778 // query_nodes.add( new PhylogenyNode( "D" ) );
11779 // query_nodes.add( new PhylogenyNode( "E" ) );
11780 // query_nodes.add( new PhylogenyNode( "F" ) );
11781 // query_nodes.add( new PhylogenyNode( "G" ) );
11782 // if ( !s0.match( query_nodes ) ) {
11785 // query_nodes = new HashSet<PhylogenyNode>();
11786 // query_nodes.add( new PhylogenyNode( "X" ) );
11787 // query_nodes.add( new PhylogenyNode( "Y" ) );
11788 // query_nodes.add( new PhylogenyNode( "A" ) );
11789 // query_nodes.add( new PhylogenyNode( "B" ) );
11790 // query_nodes.add( new PhylogenyNode( "C" ) );
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( "D" ) );
11799 // query_nodes.add( new PhylogenyNode( "E" ) );
11800 // query_nodes.add( new PhylogenyNode( "F" ) );
11801 // query_nodes.add( new PhylogenyNode( "G" ) );
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( "A" ) );
11810 // query_nodes.add( new PhylogenyNode( "B" ) );
11811 // query_nodes.add( new PhylogenyNode( "C" ) );
11812 // query_nodes.add( new PhylogenyNode( "D" ) );
11813 // if ( !s0.match( query_nodes ) ) {
11817 // query_nodes = new HashSet<PhylogenyNode>();
11818 // query_nodes.add( new PhylogenyNode( "X" ) );
11819 // query_nodes.add( new PhylogenyNode( "Y" ) );
11820 // query_nodes.add( new PhylogenyNode( "E" ) );
11821 // query_nodes.add( new PhylogenyNode( "F" ) );
11822 // query_nodes.add( new PhylogenyNode( "G" ) );
11823 // if ( !s0.match( query_nodes ) ) {
11827 // query_nodes = new HashSet<PhylogenyNode>();
11828 // query_nodes.add( new PhylogenyNode( "X" ) );
11829 // query_nodes.add( new PhylogenyNode( "Y" ) );
11830 // query_nodes.add( new PhylogenyNode( "F" ) );
11831 // query_nodes.add( new PhylogenyNode( "G" ) );
11832 // if ( !s0.match( query_nodes ) ) {
11836 query_nodes = new HashSet<PhylogenyNode>();
11837 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11838 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11839 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11840 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11841 if ( s0.match( query_nodes ) ) {
11845 query_nodes = new HashSet<PhylogenyNode>();
11846 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11847 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11848 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11849 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11850 if ( s0.match( query_nodes ) ) {
11853 ///////////////////////////
11855 query_nodes = new HashSet<PhylogenyNode>();
11856 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11857 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11858 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11859 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11860 if ( s0.match( query_nodes ) ) {
11864 query_nodes = new HashSet<PhylogenyNode>();
11865 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11866 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11867 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11868 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11869 if ( s0.match( query_nodes ) ) {
11873 query_nodes = new HashSet<PhylogenyNode>();
11874 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11875 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11876 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11877 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11878 if ( s0.match( query_nodes ) ) {
11882 query_nodes = new HashSet<PhylogenyNode>();
11883 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11884 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11885 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11886 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11887 if ( s0.match( query_nodes ) ) {
11891 query_nodes = new HashSet<PhylogenyNode>();
11892 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11893 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11894 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11895 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11896 if ( s0.match( query_nodes ) ) {
11900 query_nodes = new HashSet<PhylogenyNode>();
11901 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11902 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11903 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11904 if ( s0.match( query_nodes ) ) {
11908 query_nodes = new HashSet<PhylogenyNode>();
11909 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11910 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11911 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11912 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11913 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11914 if ( s0.match( query_nodes ) ) {
11918 query_nodes = new HashSet<PhylogenyNode>();
11919 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11920 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11921 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11922 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11923 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11924 if ( s0.match( query_nodes ) ) {
11928 query_nodes = new HashSet<PhylogenyNode>();
11929 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11931 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11932 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11933 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11934 if ( s0.match( query_nodes ) ) {
11938 query_nodes = new HashSet<PhylogenyNode>();
11939 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11940 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11941 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11942 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11943 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11944 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11945 if ( s0.match( query_nodes ) ) {
11949 catch ( final Exception e ) {
11950 e.printStackTrace();
11956 private static boolean testSplitStrict() {
11958 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11959 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11960 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11961 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11962 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11963 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11964 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11965 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11966 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11967 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11968 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11969 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11970 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11971 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11972 if ( s0.match( query_nodes ) ) {
11975 query_nodes = new HashSet<PhylogenyNode>();
11976 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11977 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11978 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11979 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11980 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11981 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11982 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11983 if ( !s0.match( query_nodes ) ) {
11987 query_nodes = new HashSet<PhylogenyNode>();
11988 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11989 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11990 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11991 if ( !s0.match( query_nodes ) ) {
11995 query_nodes = new HashSet<PhylogenyNode>();
11996 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11997 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11998 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11999 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12000 if ( !s0.match( query_nodes ) ) {
12004 query_nodes = new HashSet<PhylogenyNode>();
12005 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12006 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12007 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12008 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12009 if ( !s0.match( query_nodes ) ) {
12013 query_nodes = new HashSet<PhylogenyNode>();
12014 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12015 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12016 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12017 if ( !s0.match( query_nodes ) ) {
12021 query_nodes = new HashSet<PhylogenyNode>();
12022 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12023 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12024 if ( !s0.match( query_nodes ) ) {
12028 query_nodes = new HashSet<PhylogenyNode>();
12029 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12030 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12031 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12032 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12033 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12034 if ( !s0.match( query_nodes ) ) {
12038 query_nodes = new HashSet<PhylogenyNode>();
12039 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12040 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12041 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12042 if ( !s0.match( query_nodes ) ) {
12046 query_nodes = new HashSet<PhylogenyNode>();
12047 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12048 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12049 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12050 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12051 if ( !s0.match( query_nodes ) ) {
12055 query_nodes = new HashSet<PhylogenyNode>();
12056 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12057 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12058 if ( s0.match( query_nodes ) ) {
12062 query_nodes = new HashSet<PhylogenyNode>();
12063 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12064 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12065 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12066 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12067 if ( s0.match( query_nodes ) ) {
12071 query_nodes = new HashSet<PhylogenyNode>();
12072 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12073 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12074 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12075 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12076 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12077 if ( s0.match( query_nodes ) ) {
12081 query_nodes = new HashSet<PhylogenyNode>();
12082 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12083 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12084 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12085 if ( s0.match( query_nodes ) ) {
12089 query_nodes = new HashSet<PhylogenyNode>();
12090 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12091 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12092 if ( s0.match( query_nodes ) ) {
12096 query_nodes = new HashSet<PhylogenyNode>();
12097 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12098 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12099 if ( s0.match( query_nodes ) ) {
12103 query_nodes = new HashSet<PhylogenyNode>();
12104 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12105 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12106 if ( s0.match( query_nodes ) ) {
12110 query_nodes = new HashSet<PhylogenyNode>();
12111 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12112 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12113 if ( s0.match( query_nodes ) ) {
12117 query_nodes = new HashSet<PhylogenyNode>();
12118 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12119 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12120 if ( s0.match( query_nodes ) ) {
12124 query_nodes = new HashSet<PhylogenyNode>();
12125 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12126 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12127 if ( s0.match( query_nodes ) ) {
12131 query_nodes = new HashSet<PhylogenyNode>();
12132 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12133 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12134 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12135 if ( s0.match( query_nodes ) ) {
12139 query_nodes = new HashSet<PhylogenyNode>();
12140 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12141 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12142 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12143 if ( s0.match( query_nodes ) ) {
12147 query_nodes = new HashSet<PhylogenyNode>();
12148 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12149 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12150 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12151 if ( s0.match( query_nodes ) ) {
12155 query_nodes = new HashSet<PhylogenyNode>();
12156 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12157 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12158 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12159 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12160 if ( s0.match( query_nodes ) ) {
12164 catch ( final Exception e ) {
12165 e.printStackTrace();
12171 private static boolean testSubtreeDeletion() {
12173 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12174 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12175 t1.deleteSubtree( t1.getNode( "A" ), false );
12176 if ( t1.getNumberOfExternalNodes() != 5 ) {
12179 t1.toNewHampshireX();
12180 t1.deleteSubtree( t1.getNode( "E" ), false );
12181 if ( t1.getNumberOfExternalNodes() != 4 ) {
12184 t1.toNewHampshireX();
12185 t1.deleteSubtree( t1.getNode( "F" ), false );
12186 if ( t1.getNumberOfExternalNodes() != 3 ) {
12189 t1.toNewHampshireX();
12190 t1.deleteSubtree( t1.getNode( "D" ), false );
12191 t1.toNewHampshireX();
12192 if ( t1.getNumberOfExternalNodes() != 3 ) {
12195 t1.deleteSubtree( t1.getNode( "def" ), false );
12196 t1.toNewHampshireX();
12197 if ( t1.getNumberOfExternalNodes() != 2 ) {
12200 t1.deleteSubtree( t1.getNode( "B" ), false );
12201 t1.toNewHampshireX();
12202 if ( t1.getNumberOfExternalNodes() != 1 ) {
12205 t1.deleteSubtree( t1.getNode( "C" ), false );
12206 t1.toNewHampshireX();
12207 if ( t1.getNumberOfExternalNodes() != 1 ) {
12210 t1.deleteSubtree( t1.getNode( "abc" ), false );
12211 t1.toNewHampshireX();
12212 if ( t1.getNumberOfExternalNodes() != 1 ) {
12215 t1.deleteSubtree( t1.getNode( "r" ), false );
12216 if ( t1.getNumberOfExternalNodes() != 0 ) {
12219 if ( !t1.isEmpty() ) {
12222 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12223 t2.deleteSubtree( t2.getNode( "A" ), false );
12224 t2.toNewHampshireX();
12225 if ( t2.getNumberOfExternalNodes() != 5 ) {
12228 t2.deleteSubtree( t2.getNode( "abc" ), false );
12229 t2.toNewHampshireX();
12230 if ( t2.getNumberOfExternalNodes() != 3 ) {
12233 t2.deleteSubtree( t2.getNode( "def" ), false );
12234 t2.toNewHampshireX();
12235 if ( t2.getNumberOfExternalNodes() != 1 ) {
12239 catch ( final Exception e ) {
12240 e.printStackTrace( System.out );
12246 private static boolean testSupportCount() {
12248 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12249 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
12250 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
12251 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
12252 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
12253 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
12254 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12256 SupportCount.count( t0_1, phylogenies_1, true, false );
12257 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12258 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12259 + "(((((A,B),C),D),E),((F,G),X))"
12260 + "(((((A,Y),B),C),D),((F,G),E))"
12261 + "(((((A,B),C),D),E),(F,G))"
12262 + "(((((A,B),C),D),E),(F,G))"
12263 + "(((((A,B),C),D),E),(F,G))"
12264 + "(((((A,B),C),D),E),(F,G),Z)"
12265 + "(((((A,B),C),D),E),(F,G))"
12266 + "((((((A,B),C),D),E),F),G)"
12267 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12269 SupportCount.count( t0_2, phylogenies_2, true, false );
12270 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12271 while ( it.hasNext() ) {
12272 final PhylogenyNode n = it.next();
12273 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12277 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12278 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12279 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12280 SupportCount.count( t0_3, phylogenies_3, true, false );
12281 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12282 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12285 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12288 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12291 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12294 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12297 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12300 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12303 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12306 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12309 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12312 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12313 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12314 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12315 SupportCount.count( t0_4, phylogenies_4, true, false );
12316 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12317 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12320 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12323 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12326 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12329 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12332 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12335 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12338 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12341 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12344 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12347 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12348 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12349 double d = SupportCount.compare( b1, a, true, true, true );
12350 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12353 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12354 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12355 d = SupportCount.compare( b2, a, true, true, true );
12356 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12359 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12360 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12361 d = SupportCount.compare( b3, a, true, true, true );
12362 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12365 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12366 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12367 d = SupportCount.compare( b4, a, true, true, false );
12368 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12372 catch ( final Exception e ) {
12373 e.printStackTrace( System.out );
12379 private static boolean testSupportTransfer() {
12381 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12382 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)",
12383 new NHXParser() )[ 0 ];
12384 final Phylogeny p2 = factory
12385 .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 ];
12386 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12389 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12392 support_transfer.moveBranchLengthsToBootstrap( p1 );
12393 support_transfer.transferSupportValues( p1, p2 );
12394 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12397 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12400 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12403 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12406 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12409 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12412 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12415 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12419 catch ( final Exception e ) {
12420 e.printStackTrace( System.out );
12426 private static boolean testTaxonomyExtraction() {
12428 final PhylogenyNode n0 = PhylogenyNode
12429 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12430 if ( n0.getNodeData().isHasTaxonomy() ) {
12433 final PhylogenyNode n1 = PhylogenyNode
12434 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12435 if ( n1.getNodeData().isHasTaxonomy() ) {
12436 System.out.println( n1.toString() );
12439 final PhylogenyNode n2x = PhylogenyNode
12440 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12441 if ( n2x.getNodeData().isHasTaxonomy() ) {
12444 final PhylogenyNode n3 = PhylogenyNode
12445 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12446 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12447 System.out.println( n3.toString() );
12450 final PhylogenyNode n4 = PhylogenyNode
12451 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12452 if ( n4.getNodeData().isHasTaxonomy() ) {
12453 System.out.println( n4.toString() );
12456 final PhylogenyNode n5 = PhylogenyNode
12457 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12458 if ( n5.getNodeData().isHasTaxonomy() ) {
12459 System.out.println( n5.toString() );
12462 final PhylogenyNode n6 = PhylogenyNode
12463 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12464 if ( n6.getNodeData().isHasTaxonomy() ) {
12465 System.out.println( n6.toString() );
12468 final PhylogenyNode n7 = PhylogenyNode
12469 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12470 if ( n7.getNodeData().isHasTaxonomy() ) {
12471 System.out.println( n7.toString() );
12474 final PhylogenyNode n8 = PhylogenyNode
12475 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12476 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12477 System.out.println( n8.toString() );
12480 final PhylogenyNode n9 = PhylogenyNode
12481 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12482 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12483 System.out.println( n9.toString() );
12486 final PhylogenyNode n10x = PhylogenyNode
12487 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12488 if ( n10x.getNodeData().isHasTaxonomy() ) {
12489 System.out.println( n10x.toString() );
12492 final PhylogenyNode n10xx = PhylogenyNode
12493 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12494 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12495 System.out.println( n10xx.toString() );
12498 final PhylogenyNode n10 = PhylogenyNode
12499 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12500 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12501 System.out.println( n10.toString() );
12504 final PhylogenyNode n11 = PhylogenyNode
12505 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12506 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12507 System.out.println( n11.toString() );
12510 final PhylogenyNode n12 = PhylogenyNode
12511 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12512 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12513 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12514 System.out.println( n12.toString() );
12517 final PhylogenyNode n13 = PhylogenyNode
12518 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12519 if ( n13.getNodeData().isHasTaxonomy() ) {
12520 System.out.println( n13.toString() );
12523 final PhylogenyNode n14 = PhylogenyNode
12524 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12525 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12526 System.out.println( n14.toString() );
12529 final PhylogenyNode n15 = PhylogenyNode
12530 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12531 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12532 System.out.println( n15.toString() );
12535 final PhylogenyNode n16 = PhylogenyNode
12536 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12537 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12538 System.out.println( n16.toString() );
12541 final PhylogenyNode n17 = PhylogenyNode
12542 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12543 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12544 System.out.println( n17.toString() );
12547 final PhylogenyNode n18 = PhylogenyNode
12548 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12549 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12550 System.out.println( n18.toString() );
12553 final PhylogenyNode n19 = PhylogenyNode
12554 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12555 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12556 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12557 System.out.println( n19.toString() );
12560 final PhylogenyNode n20 = PhylogenyNode
12561 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12562 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12563 System.out.println( n20.toString() );
12566 final PhylogenyNode n21 = PhylogenyNode
12567 .createInstanceFromNhxString( "Mus musculus musculus K392",
12568 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12569 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12570 System.out.println( n21.toString() );
12573 final PhylogenyNode n23 = PhylogenyNode
12574 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
12575 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12576 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12577 System.out.println( n23.toString() );
12580 final PhylogenyNode n24 = PhylogenyNode
12581 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12582 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12583 System.out.println( n24.toString() );
12587 final PhylogenyNode n25 = PhylogenyNode
12588 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
12589 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12590 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12591 System.out.println( n25.toString() );
12594 final PhylogenyNode n26 = PhylogenyNode
12595 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
12596 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12597 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12598 System.out.println( n26.toString() );
12601 final PhylogenyNode n27 = PhylogenyNode
12602 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12603 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12604 System.out.println( n27.toString() );
12608 catch ( final Exception e ) {
12609 e.printStackTrace( System.out );
12615 private static boolean testTreeCopy() {
12617 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12618 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12619 final Phylogeny t1 = t0.copy();
12620 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12623 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12626 t0.deleteSubtree( t0.getNode( "c" ), true );
12627 t0.deleteSubtree( t0.getNode( "a" ), true );
12628 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12629 t0.getNode( "b" ).setName( "Bee" );
12630 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12633 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12636 t0.deleteSubtree( t0.getNode( "e" ), true );
12637 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12638 t0.deleteSubtree( t0.getNode( "d" ), true );
12639 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12643 catch ( final Exception e ) {
12644 e.printStackTrace();
12650 private static boolean testTreeMethods() {
12652 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12653 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12654 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12655 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12656 System.out.println( t0.toNewHampshireX() );
12659 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12660 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12661 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12664 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12667 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12671 catch ( final Exception e ) {
12672 e.printStackTrace( System.out );
12678 private static boolean testUniprotEntryRetrieval() {
12680 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 5000 );
12681 if ( !entry.getAccession().equals( "P12345" ) ) {
12684 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12687 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12690 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12693 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12696 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12699 if ( entry.getMolecularSequence() == null ) {
12703 .getMolecularSequence()
12704 .getMolecularSequenceAsString()
12705 .startsWith( "MALLHSARVLSGVASAFHPGLAAAASARASSWWAHVEMGPPDPILGVTEAYKRDTNSKKMNLGVGAYRDDNGKPYVLPSVRKAEAQIAAKGLDKEYLPIGGLAEFCRASAELALGENSEV" )
12706 || !entry.getMolecularSequence().getMolecularSequenceAsString().endsWith( "LAHAIHQVTK" ) ) {
12707 System.out.println( "got: " + entry.getMolecularSequence().getMolecularSequenceAsString() );
12708 System.out.println( "expected something else." );
12712 catch ( final IOException e ) {
12713 System.out.println();
12714 System.out.println( "the following might be due to absence internet connection:" );
12715 e.printStackTrace( System.out );
12718 catch ( final NullPointerException f ) {
12719 f.printStackTrace( System.out );
12722 catch ( final Exception e ) {
12728 private static boolean testUniprotTaxonomySearch() {
12730 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12732 if ( results.size() != 1 ) {
12735 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12738 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12741 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12744 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12747 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12751 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12752 if ( results.size() != 1 ) {
12755 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12758 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12761 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12764 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12767 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12771 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12772 if ( results.size() != 1 ) {
12775 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12778 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12781 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12784 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12787 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12791 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12792 if ( results.size() != 1 ) {
12795 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12798 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12801 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12804 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12807 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12810 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12813 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12816 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12817 .equals( "Nematostella vectensis" ) ) {
12818 System.out.println( results.get( 0 ).getLineage() );
12823 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12824 if ( results.size() != 1 ) {
12827 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12830 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12833 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12836 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12839 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12842 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12843 .equals( "Xenopus tropicalis" ) ) {
12844 System.out.println( results.get( 0 ).getLineage() );
12849 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12850 if ( results.size() != 1 ) {
12853 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12856 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12859 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12862 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12865 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12868 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12869 .equals( "Xenopus tropicalis" ) ) {
12870 System.out.println( results.get( 0 ).getLineage() );
12875 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12876 if ( results.size() != 1 ) {
12879 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12882 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12885 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12888 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12891 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12894 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12895 .equals( "Xenopus tropicalis" ) ) {
12896 System.out.println( results.get( 0 ).getLineage() );
12900 catch ( final IOException e ) {
12901 System.out.println();
12902 System.out.println( "the following might be due to absence internet connection:" );
12903 e.printStackTrace( System.out );
12906 catch ( final Exception e ) {
12912 private static boolean testWabiTxSearch() {
12914 String result = "";
12915 result = TxSearch.searchSimple( "nematostella" );
12916 result = TxSearch.getTxId( "nematostella" );
12917 if ( !result.equals( "45350" ) ) {
12920 result = TxSearch.getTxName( "45350" );
12921 if ( !result.equals( "Nematostella" ) ) {
12924 result = TxSearch.getTxId( "nematostella vectensis" );
12925 if ( !result.equals( "45351" ) ) {
12928 result = TxSearch.getTxName( "45351" );
12929 if ( !result.equals( "Nematostella vectensis" ) ) {
12932 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12933 if ( !result.equals( "536089" ) ) {
12936 result = TxSearch.getTxName( "536089" );
12937 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12940 final List<String> queries = new ArrayList<String>();
12941 queries.add( "Campylobacter coli" );
12942 queries.add( "Escherichia coli" );
12943 queries.add( "Arabidopsis" );
12944 queries.add( "Trichoplax" );
12945 queries.add( "Samanea saman" );
12946 queries.add( "Kluyveromyces marxianus" );
12947 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12948 queries.add( "Bornavirus parrot/PDD/2008" );
12949 final List<RANKS> ranks = new ArrayList<RANKS>();
12950 ranks.add( RANKS.SUPERKINGDOM );
12951 ranks.add( RANKS.KINGDOM );
12952 ranks.add( RANKS.FAMILY );
12953 ranks.add( RANKS.GENUS );
12954 ranks.add( RANKS.TRIBE );
12955 result = TxSearch.searchLineage( queries, ranks );
12956 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12957 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12959 catch ( final Exception e ) {
12960 System.out.println();
12961 System.out.println( "the following might be due to absence internet connection:" );
12962 e.printStackTrace( System.out );