2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2014 Christian M. Zmasek
6 // Copyright (C) 2014 Sanford-Burnham Medical Research Institute
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.test;
27 import java.io.ByteArrayInputStream;
29 import java.io.FileInputStream;
30 import java.io.IOException;
31 import java.io.StringWriter;
32 import java.io.Writer;
34 import java.util.ArrayList;
35 import java.util.Date;
36 import java.util.HashSet;
37 import java.util.Iterator;
38 import java.util.List;
39 import java.util.Locale;
41 import java.util.SortedSet;
43 import org.forester.application.support_transfer;
44 import org.forester.archaeopteryx.AptxUtil;
45 import org.forester.archaeopteryx.TreePanelUtil;
46 import org.forester.archaeopteryx.webservices.WebserviceUtil;
47 import org.forester.development.DevelopmentTools;
48 import org.forester.evoinference.TestPhylogenyReconstruction;
49 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
50 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
51 import org.forester.go.TestGo;
52 import org.forester.io.parsers.FastaParser;
53 import org.forester.io.parsers.GeneralMsaParser;
54 import org.forester.io.parsers.HmmscanPerDomainTableParser;
55 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
56 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
57 import org.forester.io.parsers.nexus.NexusCharactersParser;
58 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
59 import org.forester.io.parsers.nhx.NHXParser;
60 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
61 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
62 import org.forester.io.parsers.tol.TolParser;
63 import org.forester.io.parsers.util.ParserUtils;
64 import org.forester.io.writers.PhylogenyWriter;
65 import org.forester.io.writers.SequenceWriter;
66 import org.forester.msa.BasicMsa;
67 import org.forester.msa.DeleteableMsa;
68 import org.forester.msa.Mafft;
69 import org.forester.msa.Msa;
70 import org.forester.msa.Msa.MSA_FORMAT;
71 import org.forester.msa.MsaInferrer;
72 import org.forester.msa.MsaMethods;
73 import org.forester.pccx.TestPccx;
74 import org.forester.phylogeny.Phylogeny;
75 import org.forester.phylogeny.PhylogenyBranch;
76 import org.forester.phylogeny.PhylogenyMethods;
77 import org.forester.phylogeny.PhylogenyNode;
78 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
79 import org.forester.phylogeny.data.Accession;
80 import org.forester.phylogeny.data.Accession.Source;
81 import org.forester.phylogeny.data.BinaryCharacters;
82 import org.forester.phylogeny.data.BranchWidth;
83 import org.forester.phylogeny.data.Confidence;
84 import org.forester.phylogeny.data.Distribution;
85 import org.forester.phylogeny.data.DomainArchitecture;
86 import org.forester.phylogeny.data.Event;
87 import org.forester.phylogeny.data.Identifier;
88 import org.forester.phylogeny.data.PhylogenyData;
89 import org.forester.phylogeny.data.PhylogenyDataUtil;
90 import org.forester.phylogeny.data.Polygon;
91 import org.forester.phylogeny.data.PropertiesMap;
92 import org.forester.phylogeny.data.Property;
93 import org.forester.phylogeny.data.Property.AppliesTo;
94 import org.forester.phylogeny.data.ProteinDomain;
95 import org.forester.phylogeny.data.Taxonomy;
96 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
97 import org.forester.phylogeny.factories.PhylogenyFactory;
98 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
99 import org.forester.protein.BasicDomain;
100 import org.forester.protein.BasicProtein;
101 import org.forester.protein.Domain;
102 import org.forester.protein.Protein;
103 import org.forester.protein.ProteinId;
104 import org.forester.rio.TestRIO;
105 import org.forester.sdi.SDI;
106 import org.forester.sdi.SDIR;
107 import org.forester.sdi.TestGSDI;
108 import org.forester.sequence.BasicSequence;
109 import org.forester.sequence.Sequence;
110 import org.forester.species.BasicSpecies;
111 import org.forester.species.Species;
112 import org.forester.surfacing.TestSurfacing;
113 import org.forester.tools.ConfidenceAssessor;
114 import org.forester.tools.SupportCount;
115 import org.forester.tools.TreeSplitMatrix;
116 import org.forester.util.AsciiHistogram;
117 import org.forester.util.BasicDescriptiveStatistics;
118 import org.forester.util.BasicTable;
119 import org.forester.util.BasicTableParser;
120 import org.forester.util.DescriptiveStatistics;
121 import org.forester.util.ForesterConstants;
122 import org.forester.util.ForesterUtil;
123 import org.forester.util.GeneralTable;
124 import org.forester.util.SequenceAccessionTools;
125 import org.forester.ws.seqdb.SequenceDatabaseEntry;
126 import org.forester.ws.seqdb.SequenceDbWsTools;
127 import org.forester.ws.seqdb.UniProtTaxonomy;
128 import org.forester.ws.wabi.TxSearch;
129 import org.forester.ws.wabi.TxSearch.RANKS;
130 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
131 import org.forester.ws.wabi.TxSearch.TAX_RANK;
133 @SuppressWarnings( "unused")
134 public final class Test {
136 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
137 + ForesterUtil.getFileSeparator() + "resources"
138 + ForesterUtil.getFileSeparator();
139 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
140 + ForesterUtil.getFileSeparator() + "test_data"
141 + ForesterUtil.getFileSeparator();
142 private final static boolean PERFORM_DB_TESTS = false;
143 private static final boolean PERFORM_WEB_TREE_ACCESS = true;
144 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
145 + ForesterConstants.PHYLO_XML_VERSION + "/"
146 + ForesterConstants.PHYLO_XML_XSD;
147 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
148 + ForesterConstants.PHYLO_XML_VERSION + "/"
149 + ForesterConstants.PHYLO_XML_XSD;
150 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
151 private final static double ZERO_DIFF = 1.0E-9;
153 public static boolean isEqual( final double a, final double b ) {
154 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
157 public static void main( final String[] args ) {
158 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
159 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
161 Locale.setDefault( Locale.US );
162 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
165 System.out.print( "[Test if directory with files for testing exists/is readable: " );
166 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
167 System.out.println( "OK.]" );
170 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
171 System.out.println( "Testing aborted." );
174 System.out.print( "[Test if resources directory exists/is readable: " );
175 if ( testDir( PATH_TO_RESOURCES ) ) {
176 System.out.println( "OK.]" );
179 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
180 System.out.println( "Testing aborted." );
183 final long start_time = new Date().getTime();
184 System.out.print( "MSA entropy: " );
185 if ( Test.testMsaEntropy() ) {
186 System.out.println( "OK." );
190 System.out.println( "failed." );
193 System.out.print( "Basic node methods: " );
194 if ( Test.testBasicNodeMethods() ) {
195 System.out.println( "OK." );
199 System.out.println( "failed." );
202 System.out.print( "Protein id: " );
203 if ( !testProteinId() ) {
204 System.out.println( "failed." );
210 System.out.println( "OK." );
211 System.out.print( "Species: " );
212 if ( !testSpecies() ) {
213 System.out.println( "failed." );
219 System.out.println( "OK." );
220 System.out.print( "Basic domain: " );
221 if ( !testBasicDomain() ) {
222 System.out.println( "failed." );
228 System.out.println( "OK." );
229 System.out.print( "Basic protein: " );
230 if ( !testBasicProtein() ) {
231 System.out.println( "failed." );
237 System.out.println( "OK." );
238 System.out.print( "Sequence writer: " );
239 if ( testSequenceWriter() ) {
240 System.out.println( "OK." );
244 System.out.println( "failed." );
247 System.out.print( "Sequence id parsing: " );
248 if ( testSequenceIdParsing() ) {
249 System.out.println( "OK." );
253 System.out.println( "failed." );
256 System.out.print( "UniProtKB id extraction: " );
257 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
258 System.out.println( "OK." );
262 System.out.println( "failed." );
265 System.out.print( "Sequence DB tools 1: " );
266 if ( testSequenceDbWsTools1() ) {
267 System.out.println( "OK." );
271 System.out.println( "failed." );
274 System.out.print( "Hmmscan output parser: " );
275 if ( testHmmscanOutputParser() ) {
276 System.out.println( "OK." );
280 System.out.println( "failed." );
283 System.out.print( "Overlap removal: " );
284 if ( !org.forester.test.Test.testOverlapRemoval() ) {
285 System.out.println( "failed." );
291 System.out.println( "OK." );
292 System.out.print( "Engulfing overlap removal: " );
293 if ( !Test.testEngulfingOverlapRemoval() ) {
294 System.out.println( "failed." );
300 System.out.println( "OK." );
301 System.out.print( "Taxonomy code extraction: " );
302 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
303 System.out.println( "OK." );
307 System.out.println( "failed." );
310 System.out.print( "SN extraction: " );
311 if ( Test.testExtractSNFromNodeName() ) {
312 System.out.println( "OK." );
316 System.out.println( "failed." );
319 System.out.print( "Taxonomy extraction (general): " );
320 if ( Test.testTaxonomyExtraction() ) {
321 System.out.println( "OK." );
325 System.out.println( "failed." );
328 System.out.print( "Uri for Aptx web sequence accession: " );
329 if ( Test.testCreateUriForSeqWeb() ) {
330 System.out.println( "OK." );
334 System.out.println( "failed." );
337 System.out.print( "Basic node construction and parsing of NHX (node level): " );
338 if ( Test.testNHXNodeParsing() ) {
339 System.out.println( "OK." );
343 System.out.println( "failed." );
346 System.out.print( "NHX parsing iterating: " );
347 if ( Test.testNHParsingIter() ) {
348 System.out.println( "OK." );
352 System.out.println( "failed." );
355 System.out.print( "NH parsing: " );
356 if ( Test.testNHParsing() ) {
357 System.out.println( "OK." );
361 System.out.println( "failed." );
364 System.out.print( "Conversion to NHX (node level): " );
365 if ( Test.testNHXconversion() ) {
366 System.out.println( "OK." );
370 System.out.println( "failed." );
373 System.out.print( "NHX parsing: " );
374 if ( Test.testNHXParsing() ) {
375 System.out.println( "OK." );
379 System.out.println( "failed." );
382 System.out.print( "NHX parsing with quotes: " );
383 if ( Test.testNHXParsingQuotes() ) {
384 System.out.println( "OK." );
388 System.out.println( "failed." );
391 System.out.print( "NHX parsing (MrBayes): " );
392 if ( Test.testNHXParsingMB() ) {
393 System.out.println( "OK." );
397 System.out.println( "failed." );
400 System.out.print( "Nexus characters parsing: " );
401 if ( Test.testNexusCharactersParsing() ) {
402 System.out.println( "OK." );
406 System.out.println( "failed." );
409 System.out.print( "Nexus tree parsing iterating: " );
410 if ( Test.testNexusTreeParsingIterating() ) {
411 System.out.println( "OK." );
415 System.out.println( "failed." );
418 System.out.print( "Nexus tree parsing: " );
419 if ( Test.testNexusTreeParsing() ) {
420 System.out.println( "OK." );
424 System.out.println( "failed." );
427 System.out.print( "Nexus tree parsing (translating): " );
428 if ( Test.testNexusTreeParsingTranslating() ) {
429 System.out.println( "OK." );
433 System.out.println( "failed." );
436 System.out.print( "Nexus matrix parsing: " );
437 if ( Test.testNexusMatrixParsing() ) {
438 System.out.println( "OK." );
442 System.out.println( "failed." );
445 System.out.print( "Basic phyloXML parsing: " );
446 if ( Test.testBasicPhyloXMLparsing() ) {
447 System.out.println( "OK." );
451 System.out.println( "failed." );
454 System.out.print( "Basic phyloXML parsing (validating against schema): " );
455 if ( testBasicPhyloXMLparsingValidating() ) {
456 System.out.println( "OK." );
460 System.out.println( "failed." );
463 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
464 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
465 System.out.println( "OK." );
469 System.out.println( "failed." );
472 System.out.print( "phyloXML Distribution Element: " );
473 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
474 System.out.println( "OK." );
478 System.out.println( "failed." );
481 System.out.print( "Tol XML parsing: " );
482 if ( Test.testBasicTolXMLparsing() ) {
483 System.out.println( "OK." );
487 System.out.println( "failed." );
490 System.out.print( "Copying of node data: " );
491 if ( Test.testCopyOfNodeData() ) {
492 System.out.println( "OK." );
496 System.out.println( "failed." );
499 System.out.print( "Tree copy: " );
500 if ( Test.testTreeCopy() ) {
501 System.out.println( "OK." );
505 System.out.println( "failed." );
508 System.out.print( "Basic tree methods: " );
509 if ( Test.testBasicTreeMethods() ) {
510 System.out.println( "OK." );
514 System.out.println( "failed." );
517 System.out.print( "Tree methods: " );
518 if ( Test.testTreeMethods() ) {
519 System.out.println( "OK." );
523 System.out.println( "failed." );
526 System.out.print( "Postorder Iterator: " );
527 if ( Test.testPostOrderIterator() ) {
528 System.out.println( "OK." );
532 System.out.println( "failed." );
535 System.out.print( "Preorder Iterator: " );
536 if ( Test.testPreOrderIterator() ) {
537 System.out.println( "OK." );
541 System.out.println( "failed." );
544 System.out.print( "Levelorder Iterator: " );
545 if ( Test.testLevelOrderIterator() ) {
546 System.out.println( "OK." );
550 System.out.println( "failed." );
553 System.out.print( "Re-id methods: " );
554 if ( Test.testReIdMethods() ) {
555 System.out.println( "OK." );
559 System.out.println( "failed." );
562 System.out.print( "Methods on last external nodes: " );
563 if ( Test.testLastExternalNodeMethods() ) {
564 System.out.println( "OK." );
568 System.out.println( "failed." );
571 System.out.print( "Methods on external nodes: " );
572 if ( Test.testExternalNodeRelatedMethods() ) {
573 System.out.println( "OK." );
577 System.out.println( "failed." );
580 System.out.print( "Deletion of external nodes: " );
581 if ( Test.testDeletionOfExternalNodes() ) {
582 System.out.println( "OK." );
586 System.out.println( "failed." );
589 System.out.print( "Subtree deletion: " );
590 if ( Test.testSubtreeDeletion() ) {
591 System.out.println( "OK." );
595 System.out.println( "failed." );
598 System.out.print( "Phylogeny branch: " );
599 if ( Test.testPhylogenyBranch() ) {
600 System.out.println( "OK." );
604 System.out.println( "failed." );
607 System.out.print( "Rerooting: " );
608 if ( Test.testRerooting() ) {
609 System.out.println( "OK." );
613 System.out.println( "failed." );
616 System.out.print( "Mipoint rooting: " );
617 if ( Test.testMidpointrooting() ) {
618 System.out.println( "OK." );
622 System.out.println( "failed." );
625 System.out.print( "Node removal: " );
626 if ( Test.testNodeRemoval() ) {
627 System.out.println( "OK." );
631 System.out.println( "failed." );
634 System.out.print( "Support count: " );
635 if ( Test.testSupportCount() ) {
636 System.out.println( "OK." );
640 System.out.println( "failed." );
643 System.out.print( "Support transfer: " );
644 if ( Test.testSupportTransfer() ) {
645 System.out.println( "OK." );
649 System.out.println( "failed." );
652 System.out.print( "Finding of LCA: " );
653 if ( Test.testGetLCA() ) {
654 System.out.println( "OK." );
658 System.out.println( "failed." );
661 System.out.print( "Finding of LCA 2: " );
662 if ( Test.testGetLCA2() ) {
663 System.out.println( "OK." );
667 System.out.println( "failed." );
670 System.out.print( "Calculation of distance between nodes: " );
671 if ( Test.testGetDistance() ) {
672 System.out.println( "OK." );
676 System.out.println( "failed." );
679 System.out.print( "Descriptive statistics: " );
680 if ( Test.testDescriptiveStatistics() ) {
681 System.out.println( "OK." );
685 System.out.println( "failed." );
688 System.out.print( "Data objects and methods: " );
689 if ( Test.testDataObjects() ) {
690 System.out.println( "OK." );
694 System.out.println( "failed." );
697 System.out.print( "Properties map: " );
698 if ( Test.testPropertiesMap() ) {
699 System.out.println( "OK." );
703 System.out.println( "failed." );
706 System.out.print( "SDIse: " );
707 if ( Test.testSDIse() ) {
708 System.out.println( "OK." );
712 System.out.println( "failed." );
715 System.out.print( "SDIunrooted: " );
716 if ( Test.testSDIunrooted() ) {
717 System.out.println( "OK." );
721 System.out.println( "failed." );
724 System.out.print( "GSDI: " );
725 if ( TestGSDI.test() ) {
726 System.out.println( "OK." );
730 System.out.println( "failed." );
733 System.out.print( "RIO: " );
734 if ( TestRIO.test() ) {
735 System.out.println( "OK." );
739 System.out.println( "failed." );
742 System.out.print( "Phylogeny reconstruction:" );
743 System.out.println();
744 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
745 System.out.println( "OK." );
749 System.out.println( "failed." );
752 System.out.print( "Analysis of domain architectures: " );
753 System.out.println();
754 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
755 System.out.println( "OK." );
759 System.out.println( "failed." );
762 System.out.print( "GO: " );
763 System.out.println();
764 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
765 System.out.println( "OK." );
769 System.out.println( "failed." );
772 System.out.print( "Modeling tools: " );
773 if ( TestPccx.test() ) {
774 System.out.println( "OK." );
778 System.out.println( "failed." );
781 System.out.print( "Split Matrix strict: " );
782 if ( Test.testSplitStrict() ) {
783 System.out.println( "OK." );
787 System.out.println( "failed." );
790 System.out.print( "Split Matrix: " );
791 if ( Test.testSplit() ) {
792 System.out.println( "OK." );
796 System.out.println( "failed." );
799 System.out.print( "Confidence Assessor: " );
800 if ( Test.testConfidenceAssessor() ) {
801 System.out.println( "OK." );
805 System.out.println( "failed." );
808 System.out.print( "Basic table: " );
809 if ( Test.testBasicTable() ) {
810 System.out.println( "OK." );
814 System.out.println( "failed." );
817 System.out.print( "General table: " );
818 if ( Test.testGeneralTable() ) {
819 System.out.println( "OK." );
823 System.out.println( "failed." );
826 System.out.print( "Amino acid sequence: " );
827 if ( Test.testAminoAcidSequence() ) {
828 System.out.println( "OK." );
832 System.out.println( "failed." );
835 System.out.print( "General MSA parser: " );
836 if ( Test.testGeneralMsaParser() ) {
837 System.out.println( "OK." );
841 System.out.println( "failed." );
844 System.out.print( "Fasta parser for msa: " );
845 if ( Test.testFastaParser() ) {
846 System.out.println( "OK." );
850 System.out.println( "failed." );
853 System.out.print( "Creation of balanced phylogeny: " );
854 if ( Test.testCreateBalancedPhylogeny() ) {
855 System.out.println( "OK." );
859 System.out.println( "failed." );
862 System.out.print( "Genbank accessor parsing: " );
863 if ( Test.testGenbankAccessorParsing() ) {
864 System.out.println( "OK." );
868 System.out.println( "failed." );
872 final String os = ForesterUtil.OS_NAME.toLowerCase();
873 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
874 path = "/usr/local/bin/mafft";
876 else if ( os.indexOf( "win" ) >= 0 ) {
877 path = "C:\\Program Files\\mafft-win\\mafft.bat";
881 if ( !MsaInferrer.isInstalled( path ) ) {
882 path = "/usr/bin/mafft";
884 if ( !MsaInferrer.isInstalled( path ) ) {
885 path = "/usr/local/bin/mafft";
888 if ( MsaInferrer.isInstalled( path ) ) {
889 System.out.print( "MAFFT (external program): " );
890 if ( Test.testMafft( path ) ) {
891 System.out.println( "OK." );
895 System.out.println( "failed [will not count towards failed tests]" );
898 System.out.print( "Next nodes with collapsed: " );
899 if ( Test.testNextNodeWithCollapsing() ) {
900 System.out.println( "OK." );
904 System.out.println( "failed." );
907 System.out.print( "Simple MSA quality: " );
908 if ( Test.testMsaQualityMethod() ) {
909 System.out.println( "OK." );
913 System.out.println( "failed." );
916 System.out.print( "Deleteable MSA: " );
917 if ( Test.testDeleteableMsa() ) {
918 System.out.println( "OK." );
922 System.out.println( "failed." );
925 if ( PERFORM_DB_TESTS ) {
926 System.out.print( "Uniprot Entry Retrieval: " );
927 if ( Test.testUniprotEntryRetrieval() ) {
928 System.out.println( "OK." );
932 System.out.println( "failed." );
935 System.out.print( "Ebi Entry Retrieval: " );
936 if ( Test.testEbiEntryRetrieval() ) {
937 System.out.println( "OK." );
941 System.out.println( "failed." );
944 System.out.print( "Sequence DB tools 2: " );
945 if ( testSequenceDbWsTools2() ) {
946 System.out.println( "OK." );
950 System.out.println( "failed." );
954 System.out.print( "Uniprot Taxonomy Search: " );
955 if ( Test.testUniprotTaxonomySearch() ) {
956 System.out.println( "OK." );
960 System.out.println( "failed." );
964 if ( PERFORM_WEB_TREE_ACCESS ) {
965 System.out.print( "NHX parsing from URL: " );
966 if ( Test.testNHXparsingFromURL() ) {
967 System.out.println( "OK." );
971 System.out.println( "failed." );
974 System.out.print( "NHX parsing from URL 2: " );
975 if ( Test.testNHXparsingFromURL2() ) {
976 System.out.println( "OK." );
980 System.out.println( "failed." );
983 System.out.print( "phyloXML parsing from URL: " );
984 if ( Test.testPhyloXMLparsingFromURL() ) {
985 System.out.println( "OK." );
989 System.out.println( "failed." );
992 System.out.print( "TreeBase acccess: " );
993 if ( Test.testTreeBaseReading() ) {
994 System.out.println( "OK." );
998 System.out.println( "failed." );
1002 System.out.print( "ToL access: " );
1003 if ( Test.testToLReading() ) {
1004 System.out.println( "OK." );
1008 System.out.println( "failed." );
1012 System.out.print( "TreeFam access: " );
1013 if ( Test.testTreeFamReading() ) {
1014 System.out.println( "OK." );
1018 System.out.println( "failed." );
1023 System.out.print( "Pfam tree access: " );
1024 if ( Test.testPfamTreeReading() ) {
1025 System.out.println( "OK." );
1029 System.out.println( "failed." );
1033 System.out.println();
1034 final Runtime rt = java.lang.Runtime.getRuntime();
1035 final long free_memory = rt.freeMemory() / 1000000;
1036 final long total_memory = rt.totalMemory() / 1000000;
1037 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1038 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1039 System.out.println();
1040 System.out.println( "Successful tests: " + succeeded );
1041 System.out.println( "Failed tests: " + failed );
1042 System.out.println();
1044 System.out.println( "OK." );
1047 System.out.println( "Not OK." );
1051 public static boolean testEngulfingOverlapRemoval() {
1053 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1054 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1055 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1056 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1057 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1058 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1059 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1060 final List<Boolean> covered = new ArrayList<Boolean>();
1061 covered.add( true ); // 0
1062 covered.add( false ); // 1
1063 covered.add( true ); // 2
1064 covered.add( false ); // 3
1065 covered.add( true ); // 4
1066 covered.add( true ); // 5
1067 covered.add( false ); // 6
1068 covered.add( true ); // 7
1069 covered.add( true ); // 8
1070 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1073 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1076 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1079 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1082 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1085 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1088 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1091 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1092 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1093 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1094 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1095 abc.addProteinDomain( a );
1096 abc.addProteinDomain( b );
1097 abc.addProteinDomain( c );
1098 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1099 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1100 if ( abc.getNumberOfProteinDomains() != 3 ) {
1103 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1106 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1109 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1112 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1115 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1116 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1117 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1118 final Protein def = new BasicProtein( "def", "nemve", 0 );
1119 def.addProteinDomain( d );
1120 def.addProteinDomain( e );
1121 def.addProteinDomain( f );
1122 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1123 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1124 if ( def.getNumberOfProteinDomains() != 3 ) {
1127 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1130 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1133 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1136 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1139 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1143 catch ( final Exception e ) {
1144 e.printStackTrace( System.out );
1150 public static final boolean testNHXparsingFromURL2() {
1152 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1153 final Phylogeny phys[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1157 TAXONOMY_EXTRACTION.NO,
1159 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1162 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1163 System.out.println( phys[ 0 ].toNewHampshire() );
1166 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1167 System.out.println( phys[ 1 ].toNewHampshire() );
1170 final Phylogeny phys2[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1174 TAXONOMY_EXTRACTION.NO,
1176 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1179 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1180 System.out.println( phys2[ 0 ].toNewHampshire() );
1183 if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1184 System.out.println( phys2[ 1 ].toNewHampshire() );
1187 final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1188 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1189 if ( ( phys3 == null ) || ( phys3.length != 1 ) ) {
1194 .equals( "((((POP23a_CIOIN_ENSCING00000016202,POP23b_CIOIN_ENSCING00000016169),POP23_CIOSA_ENSCSAVG00000000248),((POP23a_BRAFL_C3ZMF1,POP23b_BRAFL_121417),(((POP3_ORYLA_ENSORLG00000019669,POP3_GASAC_ENSGACG00000014023,POP3_DANRE_Q6JWW1),(POP3_XENTR_B1H1F6,(POP3_CHICK_Q9DG25,(POP3_ORNAN_ENSOANG00000004179,POP3_MONDO_ENSMODG00000018033,((POP3_MOUSE_Q9ES81,POP3_RAT_Q3BCU3),POP3_RABIT_ENSOCUG00000025973,POP3_MACMU_ENSMMUG00000014473,POP3_HUMAN_Q9HBV1))))),(((POP2_GASAC_ENSGACG00000001420,POP2_ORYLA_ENSORLG00000008627,POP2_TAKRU_ENSTRUG00000015933),POP2_DANRE_ENSDARG00000069922),POP2_XENTR_ENSXETG00000018064,(((POP2_TAEGU_ENSTGUG00000013383,POP2_CHICK_Q6T9Z5),POP2_ANOCA_ENSACAG00000003557),((POP2_MACEU_ENSMEUG00000015825,POP2_MONDO_ENSMODG00000018205),((POP2_RABIT_ENSOCUG00000009515,(POP2_RAT_Q6P722,POP2_MOUSE_Q9ES82)),(POP2_MACMU_ENSMMUG00000000905,POP2_HUMAN_Q9HBU9)))))))),((POP1_CIOSA_ENSCSAVG00000000247,POP1_CIOIN_ENSCING00000000496),((POP1_DANRE_Q5PQZ7,(POP1_ORYLA_ENSORLG00000019663,POP1_GASAC_ENSGACG00000014015,POP1_TAKRU_ENSORLG00000019663)),(POP1_XENTR_B1H1G2,(POP1_ANOCA_ENSACAG00000003910,(POP1_TAEGU_ENSTGUG00000012218,POP1_CHICK_Q9DG23)),POP1_ORNAN_ENSOANG00000004180,POP1_MONDO_ENSMODG00000018034,(POP1_RABIT_ENSOCUG00000016944,(POP1_RAT_Q3BCU4,POP1_MOUSE_Q9ES83),(POP1_HUMAN_Q8NE79,POP1_MACMU_ENSMMUG00000014471))))));" ) ) {
1195 System.out.println( phys3[ 0 ].toNewHampshire() );
1198 final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1199 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1200 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1205 .equals( "((((POP23a_CIOIN_ENSCING00000016202,POP23b_CIOIN_ENSCING00000016169),POP23_CIOSA_ENSCSAVG00000000248),((POP23a_BRAFL_C3ZMF1,POP23b_BRAFL_121417),(((POP3_ORYLA_ENSORLG00000019669,POP3_GASAC_ENSGACG00000014023,POP3_DANRE_Q6JWW1),(POP3_XENTR_B1H1F6,(POP3_CHICK_Q9DG25,(POP3_ORNAN_ENSOANG00000004179,POP3_MONDO_ENSMODG00000018033,((POP3_MOUSE_Q9ES81,POP3_RAT_Q3BCU3),POP3_RABIT_ENSOCUG00000025973,POP3_MACMU_ENSMMUG00000014473,POP3_HUMAN_Q9HBV1))))),(((POP2_GASAC_ENSGACG00000001420,POP2_ORYLA_ENSORLG00000008627,POP2_TAKRU_ENSTRUG00000015933),POP2_DANRE_ENSDARG00000069922),POP2_XENTR_ENSXETG00000018064,(((POP2_TAEGU_ENSTGUG00000013383,POP2_CHICK_Q6T9Z5),POP2_ANOCA_ENSACAG00000003557),((POP2_MACEU_ENSMEUG00000015825,POP2_MONDO_ENSMODG00000018205),((POP2_RABIT_ENSOCUG00000009515,(POP2_RAT_Q6P722,POP2_MOUSE_Q9ES82)),(POP2_MACMU_ENSMMUG00000000905,POP2_HUMAN_Q9HBU9)))))))),((POP1_CIOSA_ENSCSAVG00000000247,POP1_CIOIN_ENSCING00000000496),((POP1_DANRE_Q5PQZ7,(POP1_ORYLA_ENSORLG00000019663,POP1_GASAC_ENSGACG00000014015,POP1_TAKRU_ENSORLG00000019663)),(POP1_XENTR_B1H1G2,(POP1_ANOCA_ENSACAG00000003910,(POP1_TAEGU_ENSTGUG00000012218,POP1_CHICK_Q9DG23)),POP1_ORNAN_ENSOANG00000004180,POP1_MONDO_ENSMODG00000018034,(POP1_RABIT_ENSOCUG00000016944,(POP1_RAT_Q3BCU4,POP1_MOUSE_Q9ES83),(POP1_HUMAN_Q8NE79,POP1_MACMU_ENSMMUG00000014471))))));" ) ) {
1206 System.out.println( phys4[ 0 ].toNewHampshire() );
1210 catch ( final Exception e ) {
1211 e.printStackTrace();
1216 public static final boolean testNHXparsingFromURL() {
1218 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1219 final URL u = new URL( s );
1220 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1221 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1222 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1225 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1226 System.out.println( phys[ 0 ].toNewHampshire() );
1229 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1230 System.out.println( phys[ 1 ].toNewHampshire() );
1233 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1234 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1237 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1238 System.out.println( phys2[ 0 ].toNewHampshire() );
1241 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1242 final NHXParser p = new NHXParser();
1243 final URL u2 = new URL( s );
1245 if ( !p.hasNext() ) {
1248 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1251 if ( !p.hasNext() ) {
1255 if ( !p.hasNext() ) {
1258 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1261 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1265 if ( !p.hasNext() ) {
1268 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1271 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1275 catch ( final Exception e ) {
1276 e.printStackTrace();
1281 public static boolean testOverlapRemoval() {
1283 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1284 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1285 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1286 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1287 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1288 final List<Boolean> covered = new ArrayList<Boolean>();
1289 covered.add( true ); // 0
1290 covered.add( false ); // 1
1291 covered.add( true ); // 2
1292 covered.add( false ); // 3
1293 covered.add( true ); // 4
1294 covered.add( true ); // 5
1295 covered.add( false ); // 6
1296 covered.add( true ); // 7
1297 covered.add( true ); // 8
1298 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1301 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1304 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1307 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1310 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1313 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1314 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1315 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1316 ab.addProteinDomain( a );
1317 ab.addProteinDomain( b );
1318 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1319 if ( ab.getNumberOfProteinDomains() != 2 ) {
1322 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1325 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1328 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1329 if ( ab.getNumberOfProteinDomains() != 2 ) {
1332 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1335 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1336 final Domain d = new BasicDomain( "d",
1343 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1344 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1345 cde.addProteinDomain( c );
1346 cde.addProteinDomain( d );
1347 cde.addProteinDomain( e );
1348 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1349 if ( cde.getNumberOfProteinDomains() != 3 ) {
1352 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1355 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1356 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1357 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1358 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1359 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1360 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1361 fghi.addProteinDomain( f );
1362 fghi.addProteinDomain( g );
1363 fghi.addProteinDomain( h );
1364 fghi.addProteinDomain( i );
1365 fghi.addProteinDomain( i );
1366 fghi.addProteinDomain( i );
1367 fghi.addProteinDomain( i2 );
1368 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1369 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1372 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1375 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1378 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1379 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1382 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1385 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1386 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1387 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1388 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1389 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1390 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1391 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1392 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1393 jklm.addProteinDomain( j );
1394 jklm.addProteinDomain( k );
1395 jklm.addProteinDomain( l );
1396 jklm.addProteinDomain( m );
1397 jklm.addProteinDomain( m0 );
1398 jklm.addProteinDomain( m1 );
1399 jklm.addProteinDomain( m2 );
1400 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1401 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1404 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1407 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1410 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1411 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1414 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1417 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1418 final Protein od = new BasicProtein( "od", "varanus", 0 );
1419 od.addProteinDomain( only );
1420 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1421 if ( od.getNumberOfProteinDomains() != 1 ) {
1424 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1428 catch ( final Exception e ) {
1429 e.printStackTrace( System.out );
1435 public static final boolean testPfamTreeReading() {
1437 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1438 final NHXParser parser = new NHXParser();
1439 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1440 parser.setReplaceUnderscores( false );
1441 parser.setGuessRootedness( true );
1442 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1443 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1444 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1447 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1451 catch ( final Exception e ) {
1452 e.printStackTrace();
1457 public static final boolean testPhyloXMLparsingFromURL() {
1459 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1460 final URL u = new URL( s );
1461 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1462 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1463 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1467 catch ( final Exception e ) {
1468 e.printStackTrace();
1473 public static final boolean testToLReading() {
1475 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1476 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1477 final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
1478 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1481 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1484 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1487 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1491 catch ( final Exception e ) {
1492 e.printStackTrace();
1497 public static final boolean testTreeBaseReading() {
1499 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1500 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1501 parser.setReplaceUnderscores( true );
1502 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1503 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1504 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1507 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1508 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1509 parser2.setReplaceUnderscores( true );
1510 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1511 final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
1512 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1516 catch ( final Exception e ) {
1517 e.printStackTrace();
1522 public static final boolean testTreeFamReading() {
1524 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1525 final NHXParser parser = new NHXParser();
1526 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1527 parser.setReplaceUnderscores( false );
1528 parser.setGuessRootedness( true );
1529 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1530 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1531 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1534 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1538 catch ( final Exception e ) {
1539 e.printStackTrace();
1544 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1545 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1549 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1550 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1553 private static boolean testAminoAcidSequence() {
1555 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1556 if ( aa1.getLength() != 13 ) {
1559 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1562 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1565 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1568 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1569 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1572 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1573 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1576 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1577 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1581 catch ( final Exception e ) {
1582 e.printStackTrace();
1588 private static boolean testBasicDomain() {
1590 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1591 if ( !pd.getDomainId().equals( "id" ) ) {
1594 if ( pd.getNumber() != 1 ) {
1597 if ( pd.getTotalCount() != 4 ) {
1600 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1603 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1604 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1605 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1606 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1607 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1608 if ( !a1.equals( a1 ) ) {
1611 if ( !a1.equals( a1_copy ) ) {
1614 if ( !a1.equals( a1_equal ) ) {
1617 if ( !a1.equals( a2 ) ) {
1620 if ( a1.equals( a3 ) ) {
1623 if ( a1.compareTo( a1 ) != 0 ) {
1626 if ( a1.compareTo( a1_copy ) != 0 ) {
1629 if ( a1.compareTo( a1_equal ) != 0 ) {
1632 if ( a1.compareTo( a2 ) != 0 ) {
1635 if ( a1.compareTo( a3 ) == 0 ) {
1639 catch ( final Exception e ) {
1640 e.printStackTrace( System.out );
1646 private static boolean testBasicNodeMethods() {
1648 if ( PhylogenyNode.getNodeCount() != 0 ) {
1651 final PhylogenyNode n1 = new PhylogenyNode();
1652 final PhylogenyNode n2 = PhylogenyNode
1653 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1654 final PhylogenyNode n3 = PhylogenyNode
1655 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1656 final PhylogenyNode n4 = PhylogenyNode
1657 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1658 if ( n1.isHasAssignedEvent() ) {
1661 if ( PhylogenyNode.getNodeCount() != 4 ) {
1664 if ( n3.getIndicator() != 0 ) {
1667 if ( n3.getNumberOfExternalNodes() != 1 ) {
1670 if ( !n3.isExternal() ) {
1673 if ( !n3.isRoot() ) {
1676 if ( !n4.getName().equals( "n4" ) ) {
1680 catch ( final Exception e ) {
1681 e.printStackTrace( System.out );
1687 private static boolean testBasicPhyloXMLparsing() {
1689 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1690 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1691 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1693 if ( xml_parser.getErrorCount() > 0 ) {
1694 System.out.println( xml_parser.getErrorMessages().toString() );
1697 if ( phylogenies_0.length != 4 ) {
1700 final Phylogeny t1 = phylogenies_0[ 0 ];
1701 final Phylogeny t2 = phylogenies_0[ 1 ];
1702 final Phylogeny t3 = phylogenies_0[ 2 ];
1703 final Phylogeny t4 = phylogenies_0[ 3 ];
1704 if ( t1.getNumberOfExternalNodes() != 1 ) {
1707 if ( !t1.isRooted() ) {
1710 if ( t1.isRerootable() ) {
1713 if ( !t1.getType().equals( "gene_tree" ) ) {
1716 if ( t2.getNumberOfExternalNodes() != 2 ) {
1719 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1722 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1725 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1728 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1731 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1734 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1737 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1738 .startsWith( "actgtgggggt" ) ) {
1741 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1742 .startsWith( "ctgtgatgcat" ) ) {
1745 if ( t3.getNumberOfExternalNodes() != 4 ) {
1748 if ( !t1.getName().equals( "t1" ) ) {
1751 if ( !t2.getName().equals( "t2" ) ) {
1754 if ( !t3.getName().equals( "t3" ) ) {
1757 if ( !t4.getName().equals( "t4" ) ) {
1760 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1763 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1766 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1769 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1770 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1773 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1776 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1779 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1782 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1783 .equals( "apoptosis" ) ) {
1786 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1787 .equals( "GO:0006915" ) ) {
1790 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1791 .equals( "UniProtKB" ) ) {
1794 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1795 .equals( "experimental" ) ) {
1798 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1799 .equals( "function" ) ) {
1802 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1803 .getValue() != 1 ) {
1806 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1807 .getType().equals( "ml" ) ) {
1810 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1811 .equals( "apoptosis" ) ) {
1814 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1815 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1818 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1819 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1822 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1823 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1826 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1827 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1830 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1831 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1834 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1835 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1838 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1839 .equals( "GO:0005829" ) ) {
1842 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1843 .equals( "intracellular organelle" ) ) {
1846 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1849 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1850 .equals( "UniProt link" ) ) ) {
1853 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1856 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1857 if ( x.size() != 4 ) {
1861 for( final Accession acc : x ) {
1863 if ( !acc.getSource().equals( "KEGG" ) ) {
1866 if ( !acc.getValue().equals( "hsa:596" ) ) {
1873 catch ( final Exception e ) {
1874 e.printStackTrace( System.out );
1880 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1882 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1883 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1884 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1885 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1888 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1890 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1892 if ( xml_parser.getErrorCount() > 0 ) {
1893 System.out.println( xml_parser.getErrorMessages().toString() );
1896 if ( phylogenies_0.length != 4 ) {
1899 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1900 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1901 if ( phylogenies_t1.length != 1 ) {
1904 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1905 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1908 if ( !t1_rt.isRooted() ) {
1911 if ( t1_rt.isRerootable() ) {
1914 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1917 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1918 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1919 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1920 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1923 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1926 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1929 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1932 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1933 .startsWith( "actgtgggggt" ) ) {
1936 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1937 .startsWith( "ctgtgatgcat" ) ) {
1940 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1941 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1942 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1943 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1944 if ( phylogenies_1.length != 1 ) {
1947 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1948 if ( !t3_rt.getName().equals( "t3" ) ) {
1951 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1954 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1957 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1960 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1963 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1964 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1967 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1970 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1973 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1974 .equals( "UniProtKB" ) ) {
1977 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1978 .equals( "apoptosis" ) ) {
1981 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1982 .equals( "GO:0006915" ) ) {
1985 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1986 .equals( "UniProtKB" ) ) {
1989 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1990 .equals( "experimental" ) ) {
1993 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1994 .equals( "function" ) ) {
1997 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1998 .getValue() != 1 ) {
2001 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2002 .getType().equals( "ml" ) ) {
2005 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2006 .equals( "apoptosis" ) ) {
2009 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2010 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2013 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2014 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
2017 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2018 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
2021 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2022 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
2025 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2026 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
2029 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2030 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
2033 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2034 .equals( "GO:0005829" ) ) {
2037 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2038 .equals( "intracellular organelle" ) ) {
2041 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2044 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2045 .equals( "UniProt link" ) ) ) {
2048 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2051 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
2054 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
2055 .equals( "Aguinaldo, A. M. A.; J. M. Turbeville, L. S. Linford, M. C. Rivera, J. R. Garey, R. A. Raff, & J. A. Lake (1997). \"Evidence for a clade of nematodes, arthropods and other moulting animals\". Nature 387 (6632): 489–493." ) ) ) {
2058 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
2061 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
2064 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
2067 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
2070 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
2071 .equals( "ncbi" ) ) {
2074 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
2077 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2078 .getName().equals( "B" ) ) {
2081 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2082 .getFrom() != 21 ) {
2085 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
2088 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2089 .getLength() != 24 ) {
2092 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2093 .getConfidence() != 2144 ) {
2096 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2097 .equals( "pfam" ) ) {
2100 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2103 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2106 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2109 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2112 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2113 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2116 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2119 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2122 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2125 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2128 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2131 if ( taxbb.getSynonyms().size() != 2 ) {
2134 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2137 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2140 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2143 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2146 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2149 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2150 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2153 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2156 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2159 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2162 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2165 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2168 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2171 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2175 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2178 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2179 .equalsIgnoreCase( "435" ) ) {
2182 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2185 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2186 .equalsIgnoreCase( "443.7" ) ) {
2189 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2192 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2195 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2196 .equalsIgnoreCase( "433" ) ) {
2199 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2200 .getCrossReferences();
2201 if ( x.size() != 4 ) {
2205 for( final Accession acc : x ) {
2207 if ( !acc.getSource().equals( "KEGG" ) ) {
2210 if ( !acc.getValue().equals( "hsa:596" ) ) {
2217 catch ( final Exception e ) {
2218 e.printStackTrace( System.out );
2224 private static boolean testBasicPhyloXMLparsingValidating() {
2226 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2227 PhyloXmlParser xml_parser = null;
2229 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2231 catch ( final Exception e ) {
2232 // Do nothing -- means were not running from jar.
2234 if ( xml_parser == null ) {
2235 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2236 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2237 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2240 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2243 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2245 if ( xml_parser.getErrorCount() > 0 ) {
2246 System.out.println( xml_parser.getErrorMessages().toString() );
2249 if ( phylogenies_0.length != 4 ) {
2252 final Phylogeny t1 = phylogenies_0[ 0 ];
2253 final Phylogeny t2 = phylogenies_0[ 1 ];
2254 final Phylogeny t3 = phylogenies_0[ 2 ];
2255 final Phylogeny t4 = phylogenies_0[ 3 ];
2256 if ( !t1.getName().equals( "t1" ) ) {
2259 if ( !t2.getName().equals( "t2" ) ) {
2262 if ( !t3.getName().equals( "t3" ) ) {
2265 if ( !t4.getName().equals( "t4" ) ) {
2268 if ( t1.getNumberOfExternalNodes() != 1 ) {
2271 if ( t2.getNumberOfExternalNodes() != 2 ) {
2274 if ( t3.getNumberOfExternalNodes() != 4 ) {
2277 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2278 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2279 if ( xml_parser.getErrorCount() > 0 ) {
2280 System.out.println( "errors:" );
2281 System.out.println( xml_parser.getErrorMessages().toString() );
2284 if ( phylogenies_1.length != 4 ) {
2287 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2289 if ( xml_parser.getErrorCount() > 0 ) {
2290 System.out.println( "errors:" );
2291 System.out.println( xml_parser.getErrorMessages().toString() );
2294 if ( phylogenies_2.length != 1 ) {
2297 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2300 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2302 if ( xml_parser.getErrorCount() > 0 ) {
2303 System.out.println( xml_parser.getErrorMessages().toString() );
2306 if ( phylogenies_3.length != 2 ) {
2309 final Phylogeny a = phylogenies_3[ 0 ];
2310 if ( !a.getName().equals( "tree 4" ) ) {
2313 if ( a.getNumberOfExternalNodes() != 3 ) {
2316 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2319 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2322 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2324 if ( xml_parser.getErrorCount() > 0 ) {
2325 System.out.println( xml_parser.getErrorMessages().toString() );
2328 if ( phylogenies_4.length != 1 ) {
2331 final Phylogeny s = phylogenies_4[ 0 ];
2332 if ( s.getNumberOfExternalNodes() != 6 ) {
2335 s.getNode( "first" );
2337 s.getNode( "\"<a'b&c'd\">\"" );
2338 s.getNode( "'''\"" );
2339 s.getNode( "\"\"\"" );
2340 s.getNode( "dick & doof" );
2342 catch ( final Exception e ) {
2343 e.printStackTrace( System.out );
2349 private static boolean testBasicProtein() {
2351 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2352 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2353 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2354 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2355 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2356 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2357 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2358 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2359 p0.addProteinDomain( y );
2360 p0.addProteinDomain( e );
2361 p0.addProteinDomain( b );
2362 p0.addProteinDomain( c );
2363 p0.addProteinDomain( d );
2364 p0.addProteinDomain( a );
2365 p0.addProteinDomain( x );
2366 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2369 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2373 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2374 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2375 aa0.addProteinDomain( a1 );
2376 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2379 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2383 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2384 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2385 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2386 aa1.addProteinDomain( a11 );
2387 aa1.addProteinDomain( a12 );
2388 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2391 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2394 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2395 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2398 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2401 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2404 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2405 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2408 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2411 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2414 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2417 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2418 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2421 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2424 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2427 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2430 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2431 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2434 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2437 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2440 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2444 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2445 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2446 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2447 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2448 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2449 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2450 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2451 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2452 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2453 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2454 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2455 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2456 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2457 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2458 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2459 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2460 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2461 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2462 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2463 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2464 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2465 p00.addProteinDomain( y0 );
2466 p00.addProteinDomain( e0 );
2467 p00.addProteinDomain( b0 );
2468 p00.addProteinDomain( c0 );
2469 p00.addProteinDomain( d0 );
2470 p00.addProteinDomain( a0 );
2471 p00.addProteinDomain( x0 );
2472 p00.addProteinDomain( y1 );
2473 p00.addProteinDomain( y2 );
2474 p00.addProteinDomain( y3 );
2475 p00.addProteinDomain( e1 );
2476 p00.addProteinDomain( e2 );
2477 p00.addProteinDomain( e3 );
2478 p00.addProteinDomain( e4 );
2479 p00.addProteinDomain( e5 );
2480 p00.addProteinDomain( z0 );
2481 p00.addProteinDomain( z1 );
2482 p00.addProteinDomain( z2 );
2483 p00.addProteinDomain( zz0 );
2484 p00.addProteinDomain( zz1 );
2485 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2488 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2491 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2494 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2497 if ( !p00.toDomainArchitectureString( "~", 7, "" ).equals( "a~b~c~d~e~e~e~e~e~e~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2500 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2501 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2502 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2503 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2504 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2505 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2506 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2507 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2508 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2509 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2510 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2511 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2512 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2513 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2514 p.addProteinDomain( B15 );
2515 p.addProteinDomain( C50 );
2516 p.addProteinDomain( A60 );
2517 p.addProteinDomain( A30 );
2518 p.addProteinDomain( C70 );
2519 p.addProteinDomain( B35 );
2520 p.addProteinDomain( B40 );
2521 p.addProteinDomain( A0 );
2522 p.addProteinDomain( A10 );
2523 p.addProteinDomain( A20 );
2524 p.addProteinDomain( B25 );
2525 p.addProteinDomain( D80 );
2526 List<String> domains_ids = new ArrayList<String>();
2527 domains_ids.add( "A" );
2528 domains_ids.add( "B" );
2529 domains_ids.add( "C" );
2530 if ( !p.contains( domains_ids, false ) ) {
2533 if ( !p.contains( domains_ids, true ) ) {
2536 domains_ids.add( "X" );
2537 if ( p.contains( domains_ids, false ) ) {
2540 if ( p.contains( domains_ids, true ) ) {
2543 domains_ids = new ArrayList<String>();
2544 domains_ids.add( "A" );
2545 domains_ids.add( "C" );
2546 domains_ids.add( "D" );
2547 if ( !p.contains( domains_ids, false ) ) {
2550 if ( !p.contains( domains_ids, true ) ) {
2553 domains_ids = new ArrayList<String>();
2554 domains_ids.add( "A" );
2555 domains_ids.add( "D" );
2556 domains_ids.add( "C" );
2557 if ( !p.contains( domains_ids, false ) ) {
2560 if ( p.contains( domains_ids, true ) ) {
2563 domains_ids = new ArrayList<String>();
2564 domains_ids.add( "A" );
2565 domains_ids.add( "A" );
2566 domains_ids.add( "B" );
2567 if ( !p.contains( domains_ids, false ) ) {
2570 if ( !p.contains( domains_ids, true ) ) {
2573 domains_ids = new ArrayList<String>();
2574 domains_ids.add( "A" );
2575 domains_ids.add( "A" );
2576 domains_ids.add( "A" );
2577 domains_ids.add( "B" );
2578 domains_ids.add( "B" );
2579 if ( !p.contains( domains_ids, false ) ) {
2582 if ( !p.contains( domains_ids, true ) ) {
2585 domains_ids = new ArrayList<String>();
2586 domains_ids.add( "A" );
2587 domains_ids.add( "A" );
2588 domains_ids.add( "B" );
2589 domains_ids.add( "A" );
2590 domains_ids.add( "B" );
2591 domains_ids.add( "B" );
2592 domains_ids.add( "A" );
2593 domains_ids.add( "B" );
2594 domains_ids.add( "C" );
2595 domains_ids.add( "A" );
2596 domains_ids.add( "C" );
2597 domains_ids.add( "D" );
2598 if ( !p.contains( domains_ids, false ) ) {
2601 if ( p.contains( domains_ids, true ) ) {
2605 catch ( final Exception e ) {
2606 e.printStackTrace( System.out );
2612 private static boolean testBasicTable() {
2614 final BasicTable<String> t0 = new BasicTable<String>();
2615 if ( t0.getNumberOfColumns() != 0 ) {
2618 if ( t0.getNumberOfRows() != 0 ) {
2621 t0.setValue( 3, 2, "23" );
2622 t0.setValue( 10, 1, "error" );
2623 t0.setValue( 10, 1, "110" );
2624 t0.setValue( 9, 1, "19" );
2625 t0.setValue( 1, 10, "101" );
2626 t0.setValue( 10, 10, "1010" );
2627 t0.setValue( 100, 10, "10100" );
2628 t0.setValue( 0, 0, "00" );
2629 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2632 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2635 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2638 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2641 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2644 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2647 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2650 if ( t0.getNumberOfColumns() != 101 ) {
2653 if ( t0.getNumberOfRows() != 11 ) {
2656 if ( t0.getValueAsString( 49, 4 ) != null ) {
2659 final String l = ForesterUtil.getLineSeparator();
2660 final StringBuffer source = new StringBuffer();
2661 source.append( "" + l );
2662 source.append( "# 1 1 1 1 1 1 1 1" + l );
2663 source.append( " 00 01 02 03" + l );
2664 source.append( " 10 11 12 13 " + l );
2665 source.append( "20 21 22 23 " + l );
2666 source.append( " 30 31 32 33" + l );
2667 source.append( "40 41 42 43" + l );
2668 source.append( " # 1 1 1 1 1 " + l );
2669 source.append( "50 51 52 53 54" + l );
2670 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2671 if ( t1.getNumberOfColumns() != 5 ) {
2674 if ( t1.getNumberOfRows() != 6 ) {
2677 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2680 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2683 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2686 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2689 final StringBuffer source1 = new StringBuffer();
2690 source1.append( "" + l );
2691 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2692 source1.append( " 00; 01 ;02;03" + l );
2693 source1.append( " 10; 11; 12; 13 " + l );
2694 source1.append( "20; 21; 22; 23 " + l );
2695 source1.append( " 30; 31; 32; 33" + l );
2696 source1.append( "40;41;42;43" + l );
2697 source1.append( " # 1 1 1 1 1 " + l );
2698 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2699 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2700 if ( t2.getNumberOfColumns() != 5 ) {
2703 if ( t2.getNumberOfRows() != 6 ) {
2706 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2709 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2712 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2715 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2718 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2721 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2724 final StringBuffer source2 = new StringBuffer();
2725 source2.append( "" + l );
2726 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2727 source2.append( " 00; 01 ;02;03" + l );
2728 source2.append( " 10; 11; 12; 13 " + l );
2729 source2.append( "20; 21; 22; 23 " + l );
2730 source2.append( " " + l );
2731 source2.append( " 30; 31; 32; 33" + l );
2732 source2.append( "40;41;42;43" + l );
2733 source2.append( " comment: 1 1 1 1 1 " + l );
2734 source2.append( ";;;50 ; 52; 53;;54 " + l );
2735 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2741 if ( tl.size() != 2 ) {
2744 final BasicTable<String> t3 = tl.get( 0 );
2745 final BasicTable<String> t4 = tl.get( 1 );
2746 if ( t3.getNumberOfColumns() != 4 ) {
2749 if ( t3.getNumberOfRows() != 3 ) {
2752 if ( t4.getNumberOfColumns() != 4 ) {
2755 if ( t4.getNumberOfRows() != 3 ) {
2758 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2761 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2765 catch ( final Exception e ) {
2766 e.printStackTrace( System.out );
2772 private static boolean testBasicTolXMLparsing() {
2774 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2775 final TolParser parser = new TolParser();
2776 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2777 if ( parser.getErrorCount() > 0 ) {
2778 System.out.println( parser.getErrorMessages().toString() );
2781 if ( phylogenies_0.length != 1 ) {
2784 final Phylogeny t1 = phylogenies_0[ 0 ];
2785 if ( t1.getNumberOfExternalNodes() != 5 ) {
2788 if ( !t1.isRooted() ) {
2791 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2794 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2797 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2800 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2803 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2804 if ( parser.getErrorCount() > 0 ) {
2805 System.out.println( parser.getErrorMessages().toString() );
2808 if ( phylogenies_1.length != 1 ) {
2811 final Phylogeny t2 = phylogenies_1[ 0 ];
2812 if ( t2.getNumberOfExternalNodes() != 664 ) {
2815 if ( !t2.isRooted() ) {
2818 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2821 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2824 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2827 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2830 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2833 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2834 .equals( "Aquifex" ) ) {
2837 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2838 if ( parser.getErrorCount() > 0 ) {
2839 System.out.println( parser.getErrorMessages().toString() );
2842 if ( phylogenies_2.length != 1 ) {
2845 final Phylogeny t3 = phylogenies_2[ 0 ];
2846 if ( t3.getNumberOfExternalNodes() != 184 ) {
2849 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2852 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2855 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2858 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2859 if ( parser.getErrorCount() > 0 ) {
2860 System.out.println( parser.getErrorMessages().toString() );
2863 if ( phylogenies_3.length != 1 ) {
2866 final Phylogeny t4 = phylogenies_3[ 0 ];
2867 if ( t4.getNumberOfExternalNodes() != 1 ) {
2870 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2873 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2876 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2879 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2880 if ( parser.getErrorCount() > 0 ) {
2881 System.out.println( parser.getErrorMessages().toString() );
2884 if ( phylogenies_4.length != 1 ) {
2887 final Phylogeny t5 = phylogenies_4[ 0 ];
2888 if ( t5.getNumberOfExternalNodes() != 13 ) {
2891 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2894 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2897 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2901 catch ( final Exception e ) {
2902 e.printStackTrace( System.out );
2908 private static boolean testBasicTreeMethods() {
2910 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2911 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2912 if ( t2.getNumberOfExternalNodes() != 4 ) {
2915 if ( t2.getHeight() != 8.5 ) {
2918 if ( !t2.isCompletelyBinary() ) {
2921 if ( t2.isEmpty() ) {
2924 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2925 if ( t3.getNumberOfExternalNodes() != 5 ) {
2928 if ( t3.getHeight() != 11 ) {
2931 if ( t3.isCompletelyBinary() ) {
2934 final PhylogenyNode n = t3.getNode( "ABC" );
2935 final Phylogeny t4 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3,(F,G,H,I))", new NHXParser() )[ 0 ];
2936 if ( t4.getNumberOfExternalNodes() != 9 ) {
2939 if ( t4.getHeight() != 11 ) {
2942 if ( t4.isCompletelyBinary() ) {
2945 final StringBuffer sb5 = new StringBuffer( "(((A11:2)A1:2,(A21:1,A22:2,A23)A2:11,A3:2)A:2,B:10,C:3,D:8)" );
2946 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2947 if ( t5.getNumberOfExternalNodes() != 8 ) {
2950 if ( t5.getHeight() != 15 ) {
2953 final StringBuffer sb6 = new StringBuffer( "(X,Y,Z,(((A111)A11:2)A1:2,(X,Y,Z,A21:1,A22:2,A23)A2:11,A3:2)A:2,B:10,C:3,D:8)" );
2954 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2955 if ( t6.getHeight() != 15 ) {
2958 final StringBuffer sb7 = new StringBuffer( "(((A11:2)A1:2,(A21:1,A22:2,A23)A2:11,A3:2)A:2,B:10,C:15,D:8)" );
2959 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2960 if ( t7.getHeight() != 15 ) {
2963 final StringBuffer sb8 = new StringBuffer( "(((A11:11)A1:2,(A21:2,A22:2,A23,A24,AA:)A2:11,A3:2)A:2,B:15,C:15,D:15)" );
2964 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2965 if ( t8.getNumberOfExternalNodes() != 10 ) {
2968 if ( t8.getHeight() != 15 ) {
2971 final char[] a9 = new char[] { 'a' };
2972 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2973 if ( t9.getHeight() != 0 ) {
2976 final char[] a10 = new char[] { 'a', ':', '6' };
2977 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2978 if ( t10.getHeight() != 6 ) {
2982 catch ( final Exception e ) {
2983 e.printStackTrace( System.out );
2989 private static boolean testConfidenceAssessor() {
2991 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2992 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2993 final Phylogeny[] ev0 = factory
2994 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2996 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2997 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3000 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3003 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3004 final Phylogeny[] ev1 = factory
3005 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
3007 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
3008 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
3011 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3014 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3015 final Phylogeny[] ev_b = factory
3016 .create( "((A,C),X);((A,X),C);(A,C);((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
3018 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
3019 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
3022 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3026 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3027 final Phylogeny[] ev1x = factory
3028 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
3030 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
3031 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3034 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3037 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3038 final Phylogeny[] ev_bx = factory
3039 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
3041 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
3042 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3045 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3049 final Phylogeny[] t2 = factory
3050 .create( "((((a,b),c),d),e);(((a,b),c),(d,e));(((((a,b),c),d),e),f);((((a,b),c),(d,e)),f);(((a,b),c),d,e);((a,b,c),d,e);",
3052 final Phylogeny[] ev2 = factory
3053 .create( "((((a,b),c),d),e);((((a,b),c),d),e);((((a,b),e),d),c);((((a,b),e),d),c);(((a,b),(c,d)),e);((a,b),x);((a,b),(x,y));(a,b);(a,e);(a,b,c);",
3055 for( final Phylogeny target : t2 ) {
3056 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
3059 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
3060 new NHXParser() )[ 0 ];
3061 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
3062 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
3063 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3066 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
3069 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3073 catch ( final Exception e ) {
3074 e.printStackTrace();
3080 private static boolean testCopyOfNodeData() {
3082 final PhylogenyNode n1 = PhylogenyNode
3083 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1:O=22:SO=33:SN=44:W=2:C=10.20.30:XN=S=tag1=value1=unit1]" );
3084 final PhylogenyNode n2 = n1.copyNodeData();
3085 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3089 catch ( final Exception e ) {
3090 e.printStackTrace();
3096 private static boolean testCreateBalancedPhylogeny() {
3098 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3099 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3102 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3105 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3106 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3109 if ( p1.getNumberOfExternalNodes() != 100 ) {
3113 catch ( final Exception e ) {
3114 e.printStackTrace();
3120 private static boolean testCreateUriForSeqWeb() {
3122 final PhylogenyNode n = new PhylogenyNode();
3123 n.setName( "tr|B3RJ64" );
3124 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3127 n.setName( "B0LM41_HUMAN" );
3128 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3131 n.setName( "NP_001025424" );
3132 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3135 n.setName( "_NM_001030253-" );
3136 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3139 n.setName( "XM_002122186" );
3140 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3143 n.setName( "dgh_AAA34956_gdg" );
3144 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3147 n.setName( "AAA34956" );
3148 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3151 n.setName( "GI:394892" );
3152 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3153 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3156 n.setName( "gi_394892" );
3157 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3158 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3161 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3162 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3163 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3166 n.setName( "P12345" );
3167 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3168 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3171 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3172 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3173 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3177 catch ( final Exception e ) {
3178 e.printStackTrace( System.out );
3184 private static boolean testDataObjects() {
3186 final Confidence s0 = new Confidence();
3187 final Confidence s1 = new Confidence();
3188 if ( !s0.isEqual( s1 ) ) {
3191 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3192 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3193 if ( s2.isEqual( s1 ) ) {
3196 if ( !s2.isEqual( s3 ) ) {
3199 final Confidence s4 = ( Confidence ) s3.copy();
3200 if ( !s4.isEqual( s3 ) ) {
3207 final Taxonomy t1 = new Taxonomy();
3208 final Taxonomy t2 = new Taxonomy();
3209 final Taxonomy t3 = new Taxonomy();
3210 final Taxonomy t4 = new Taxonomy();
3211 final Taxonomy t5 = new Taxonomy();
3212 t1.setIdentifier( new Identifier( "ecoli" ) );
3213 t1.setTaxonomyCode( "ECOLI" );
3214 t1.setScientificName( "E. coli" );
3215 t1.setCommonName( "coli" );
3216 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3217 if ( !t1.isEqual( t0 ) ) {
3220 t2.setIdentifier( new Identifier( "ecoli" ) );
3221 t2.setTaxonomyCode( "OTHER" );
3222 t2.setScientificName( "what" );
3223 t2.setCommonName( "something" );
3224 if ( !t1.isEqual( t2 ) ) {
3227 t2.setIdentifier( new Identifier( "nemve" ) );
3228 if ( t1.isEqual( t2 ) ) {
3231 t1.setIdentifier( null );
3232 t3.setTaxonomyCode( "ECOLI" );
3233 t3.setScientificName( "what" );
3234 t3.setCommonName( "something" );
3235 if ( !t1.isEqual( t3 ) ) {
3238 t1.setIdentifier( null );
3239 t1.setTaxonomyCode( "" );
3240 t4.setScientificName( "E. ColI" );
3241 t4.setCommonName( "something" );
3242 if ( !t1.isEqual( t4 ) ) {
3245 t4.setScientificName( "B. subtilis" );
3246 t4.setCommonName( "something" );
3247 if ( t1.isEqual( t4 ) ) {
3250 t1.setIdentifier( null );
3251 t1.setTaxonomyCode( "" );
3252 t1.setScientificName( "" );
3253 t5.setCommonName( "COLI" );
3254 if ( !t1.isEqual( t5 ) ) {
3257 t5.setCommonName( "vibrio" );
3258 if ( t1.isEqual( t5 ) ) {
3263 final Identifier id0 = new Identifier( "123", "pfam" );
3264 final Identifier id1 = ( Identifier ) id0.copy();
3265 if ( !id1.isEqual( id1 ) ) {
3268 if ( !id1.isEqual( id0 ) ) {
3271 if ( !id0.isEqual( id1 ) ) {
3278 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3279 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3280 if ( !pd1.isEqual( pd1 ) ) {
3283 if ( !pd1.isEqual( pd0 ) ) {
3288 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3289 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3290 if ( !pd3.isEqual( pd3 ) ) {
3293 if ( !pd2.isEqual( pd3 ) ) {
3296 if ( !pd0.isEqual( pd3 ) ) {
3301 // DomainArchitecture
3302 // ------------------
3303 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3304 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3305 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3306 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3307 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3308 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3313 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3314 if ( ds0.getNumberOfDomains() != 4 ) {
3317 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3318 if ( !ds0.isEqual( ds0 ) ) {
3321 if ( !ds0.isEqual( ds1 ) ) {
3324 if ( ds1.getNumberOfDomains() != 4 ) {
3327 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3332 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3333 if ( ds0.isEqual( ds2 ) ) {
3339 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3340 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3341 System.out.println( ds3.toNHX() );
3344 if ( ds3.getNumberOfDomains() != 3 ) {
3349 final Event e1 = new Event( Event.EventType.fusion );
3350 if ( e1.isDuplication() ) {
3353 if ( !e1.isFusion() ) {
3356 if ( !e1.asText().toString().equals( "fusion" ) ) {
3359 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3362 final Event e11 = new Event( Event.EventType.fusion );
3363 if ( !e11.isEqual( e1 ) ) {
3366 if ( !e11.toNHX().toString().equals( "" ) ) {
3369 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3370 if ( e2.isDuplication() ) {
3373 if ( !e2.isSpeciationOrDuplication() ) {
3376 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3379 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3382 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3385 if ( e11.isEqual( e2 ) ) {
3388 final Event e2c = ( Event ) e2.copy();
3389 if ( !e2c.isEqual( e2 ) ) {
3392 Event e3 = new Event( 1, 2, 3 );
3393 if ( e3.isDuplication() ) {
3396 if ( e3.isSpeciation() ) {
3399 if ( e3.isGeneLoss() ) {
3402 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3405 final Event e3c = ( Event ) e3.copy();
3406 final Event e3cc = ( Event ) e3c.copy();
3407 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3411 if ( !e3c.isEqual( e3cc ) ) {
3414 Event e4 = new Event( 1, 2, 3 );
3415 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3418 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3421 final Event e4c = ( Event ) e4.copy();
3423 final Event e4cc = ( Event ) e4c.copy();
3424 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3427 if ( !e4c.isEqual( e4cc ) ) {
3430 final Event e5 = new Event();
3431 if ( !e5.isUnassigned() ) {
3434 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3437 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3440 final Event e6 = new Event( 1, 0, 0 );
3441 if ( !e6.asText().toString().equals( "duplication" ) ) {
3444 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3447 final Event e7 = new Event( 0, 1, 0 );
3448 if ( !e7.asText().toString().equals( "speciation" ) ) {
3451 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3454 final Event e8 = new Event( 0, 0, 1 );
3455 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3458 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3462 catch ( final Exception e ) {
3463 e.printStackTrace( System.out );
3469 private static boolean testDeletionOfExternalNodes() {
3471 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3472 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3473 final PhylogenyWriter w = new PhylogenyWriter();
3474 if ( t0.isEmpty() ) {
3477 if ( t0.getNumberOfExternalNodes() != 1 ) {
3480 t0.deleteSubtree( t0.getNode( "A" ), false );
3481 if ( t0.getNumberOfExternalNodes() != 0 ) {
3484 if ( !t0.isEmpty() ) {
3487 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3488 if ( t1.getNumberOfExternalNodes() != 2 ) {
3491 t1.deleteSubtree( t1.getNode( "A" ), false );
3492 if ( t1.getNumberOfExternalNodes() != 1 ) {
3495 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3498 t1.deleteSubtree( t1.getNode( "B" ), false );
3499 if ( t1.getNumberOfExternalNodes() != 1 ) {
3502 t1.deleteSubtree( t1.getNode( "r" ), false );
3503 if ( !t1.isEmpty() ) {
3506 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3507 if ( t2.getNumberOfExternalNodes() != 3 ) {
3510 t2.deleteSubtree( t2.getNode( "B" ), false );
3511 if ( t2.getNumberOfExternalNodes() != 2 ) {
3514 t2.toNewHampshireX();
3515 PhylogenyNode n = t2.getNode( "A" );
3516 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3519 t2.deleteSubtree( t2.getNode( "A" ), false );
3520 if ( t2.getNumberOfExternalNodes() != 2 ) {
3523 t2.deleteSubtree( t2.getNode( "C" ), true );
3524 if ( t2.getNumberOfExternalNodes() != 1 ) {
3527 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3528 if ( t3.getNumberOfExternalNodes() != 4 ) {
3531 t3.deleteSubtree( t3.getNode( "B" ), true );
3532 if ( t3.getNumberOfExternalNodes() != 3 ) {
3535 n = t3.getNode( "A" );
3536 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3539 n = n.getNextExternalNode();
3540 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3543 t3.deleteSubtree( t3.getNode( "A" ), true );
3544 if ( t3.getNumberOfExternalNodes() != 2 ) {
3547 n = t3.getNode( "C" );
3548 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3551 t3.deleteSubtree( t3.getNode( "C" ), true );
3552 if ( t3.getNumberOfExternalNodes() != 1 ) {
3555 t3.deleteSubtree( t3.getNode( "D" ), true );
3556 if ( t3.getNumberOfExternalNodes() != 0 ) {
3559 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3560 if ( t4.getNumberOfExternalNodes() != 6 ) {
3563 t4.deleteSubtree( t4.getNode( "B2" ), true );
3564 if ( t4.getNumberOfExternalNodes() != 5 ) {
3567 String s = w.toNewHampshire( t4, true ).toString();
3568 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3571 t4.deleteSubtree( t4.getNode( "B11" ), true );
3572 if ( t4.getNumberOfExternalNodes() != 4 ) {
3575 t4.deleteSubtree( t4.getNode( "C" ), true );
3576 if ( t4.getNumberOfExternalNodes() != 3 ) {
3579 n = t4.getNode( "A" );
3580 n = n.getNextExternalNode();
3581 if ( !n.getName().equals( "B12" ) ) {
3584 n = n.getNextExternalNode();
3585 if ( !n.getName().equals( "D" ) ) {
3588 s = w.toNewHampshire( t4, true ).toString();
3589 if ( !s.equals( "((A,B12),D);" ) ) {
3592 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3593 t5.deleteSubtree( t5.getNode( "A" ), true );
3594 if ( t5.getNumberOfExternalNodes() != 5 ) {
3597 s = w.toNewHampshire( t5, true ).toString();
3598 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3601 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3602 t6.deleteSubtree( t6.getNode( "B11" ), true );
3603 if ( t6.getNumberOfExternalNodes() != 5 ) {
3606 s = w.toNewHampshire( t6, false ).toString();
3607 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3610 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3611 t7.deleteSubtree( t7.getNode( "B12" ), true );
3612 if ( t7.getNumberOfExternalNodes() != 5 ) {
3615 s = w.toNewHampshire( t7, true ).toString();
3616 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3619 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3620 t8.deleteSubtree( t8.getNode( "B2" ), true );
3621 if ( t8.getNumberOfExternalNodes() != 5 ) {
3624 s = w.toNewHampshire( t8, false ).toString();
3625 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3628 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3629 t9.deleteSubtree( t9.getNode( "C" ), true );
3630 if ( t9.getNumberOfExternalNodes() != 5 ) {
3633 s = w.toNewHampshire( t9, true ).toString();
3634 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3637 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3638 t10.deleteSubtree( t10.getNode( "D" ), true );
3639 if ( t10.getNumberOfExternalNodes() != 5 ) {
3642 s = w.toNewHampshire( t10, true ).toString();
3643 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3646 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3647 t11.deleteSubtree( t11.getNode( "A" ), true );
3648 if ( t11.getNumberOfExternalNodes() != 2 ) {
3651 s = w.toNewHampshire( t11, true ).toString();
3652 if ( !s.equals( "(B,C);" ) ) {
3655 t11.deleteSubtree( t11.getNode( "C" ), true );
3656 if ( t11.getNumberOfExternalNodes() != 1 ) {
3659 s = w.toNewHampshire( t11, false ).toString();
3660 if ( !s.equals( "B;" ) ) {
3663 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3664 t12.deleteSubtree( t12.getNode( "B2" ), true );
3665 if ( t12.getNumberOfExternalNodes() != 8 ) {
3668 s = w.toNewHampshire( t12, true ).toString();
3669 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3672 t12.deleteSubtree( t12.getNode( "B3" ), true );
3673 if ( t12.getNumberOfExternalNodes() != 7 ) {
3676 s = w.toNewHampshire( t12, true ).toString();
3677 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3680 t12.deleteSubtree( t12.getNode( "C3" ), true );
3681 if ( t12.getNumberOfExternalNodes() != 6 ) {
3684 s = w.toNewHampshire( t12, true ).toString();
3685 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3688 t12.deleteSubtree( t12.getNode( "A1" ), true );
3689 if ( t12.getNumberOfExternalNodes() != 5 ) {
3692 s = w.toNewHampshire( t12, true ).toString();
3693 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3696 t12.deleteSubtree( t12.getNode( "B1" ), true );
3697 if ( t12.getNumberOfExternalNodes() != 4 ) {
3700 s = w.toNewHampshire( t12, true ).toString();
3701 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3704 t12.deleteSubtree( t12.getNode( "A3" ), true );
3705 if ( t12.getNumberOfExternalNodes() != 3 ) {
3708 s = w.toNewHampshire( t12, true ).toString();
3709 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3712 t12.deleteSubtree( t12.getNode( "A2" ), true );
3713 if ( t12.getNumberOfExternalNodes() != 2 ) {
3716 s = w.toNewHampshire( t12, true ).toString();
3717 if ( !s.equals( "(C1,C2);" ) ) {
3720 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3721 t13.deleteSubtree( t13.getNode( "D" ), true );
3722 if ( t13.getNumberOfExternalNodes() != 4 ) {
3725 s = w.toNewHampshire( t13, true ).toString();
3726 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3729 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3730 t14.deleteSubtree( t14.getNode( "E" ), true );
3731 if ( t14.getNumberOfExternalNodes() != 5 ) {
3734 s = w.toNewHampshire( t14, true ).toString();
3735 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3738 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3739 t15.deleteSubtree( t15.getNode( "B2" ), true );
3740 if ( t15.getNumberOfExternalNodes() != 11 ) {
3743 t15.deleteSubtree( t15.getNode( "B1" ), true );
3744 if ( t15.getNumberOfExternalNodes() != 10 ) {
3747 t15.deleteSubtree( t15.getNode( "B3" ), true );
3748 if ( t15.getNumberOfExternalNodes() != 9 ) {
3751 t15.deleteSubtree( t15.getNode( "B4" ), true );
3752 if ( t15.getNumberOfExternalNodes() != 8 ) {
3755 t15.deleteSubtree( t15.getNode( "A1" ), true );
3756 if ( t15.getNumberOfExternalNodes() != 7 ) {
3759 t15.deleteSubtree( t15.getNode( "C4" ), true );
3760 if ( t15.getNumberOfExternalNodes() != 6 ) {
3764 catch ( final Exception e ) {
3765 e.printStackTrace( System.out );
3771 private static boolean testDescriptiveStatistics() {
3773 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3774 dss1.addValue( 82 );
3775 dss1.addValue( 78 );
3776 dss1.addValue( 70 );
3777 dss1.addValue( 58 );
3778 dss1.addValue( 42 );
3779 if ( dss1.getN() != 5 ) {
3782 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3785 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3788 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3791 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3794 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3797 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3800 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3803 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3806 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3809 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3812 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3815 dss1.addValue( 123 );
3816 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3819 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3822 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3825 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3826 dss2.addValue( -1.85 );
3827 dss2.addValue( 57.5 );
3828 dss2.addValue( 92.78 );
3829 dss2.addValue( 57.78 );
3830 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3833 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3836 final double[] a = dss2.getDataAsDoubleArray();
3837 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3840 dss2.addValue( -100 );
3841 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3844 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3847 final double[] ds = new double[ 14 ];
3862 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3863 if ( bins.length != 4 ) {
3866 if ( bins[ 0 ] != 2 ) {
3869 if ( bins[ 1 ] != 3 ) {
3872 if ( bins[ 2 ] != 4 ) {
3875 if ( bins[ 3 ] != 5 ) {
3878 final double[] ds1 = new double[ 9 ];
3888 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3889 if ( bins1.length != 4 ) {
3892 if ( bins1[ 0 ] != 2 ) {
3895 if ( bins1[ 1 ] != 3 ) {
3898 if ( bins1[ 2 ] != 0 ) {
3901 if ( bins1[ 3 ] != 4 ) {
3904 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3905 if ( bins1_1.length != 3 ) {
3908 if ( bins1_1[ 0 ] != 3 ) {
3911 if ( bins1_1[ 1 ] != 2 ) {
3914 if ( bins1_1[ 2 ] != 4 ) {
3917 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3918 if ( bins1_2.length != 3 ) {
3921 if ( bins1_2[ 0 ] != 2 ) {
3924 if ( bins1_2[ 1 ] != 2 ) {
3927 if ( bins1_2[ 2 ] != 2 ) {
3930 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3944 dss3.addValue( 10 );
3945 dss3.addValue( 10 );
3946 dss3.addValue( 10 );
3947 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3948 histo.toStringBuffer( 10, '=', 40, 5 );
3949 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3951 catch ( final Exception e ) {
3952 e.printStackTrace( System.out );
3958 private static boolean testDir( final String file ) {
3960 final File f = new File( file );
3961 if ( !f.exists() ) {
3964 if ( !f.isDirectory() ) {
3967 if ( !f.canRead() ) {
3971 catch ( final Exception e ) {
3977 private static boolean testEbiEntryRetrieval() {
3979 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3980 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3981 System.out.println( entry.getAccession() );
3984 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3985 System.out.println( entry.getTaxonomyScientificName() );
3988 if ( !entry.getSequenceName()
3989 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3990 System.out.println( entry.getSequenceName() );
3993 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3994 // System.out.println( entry.getSequenceSymbol() );
3997 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3998 System.out.println( entry.getGeneName() );
4001 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
4002 System.out.println( entry.getTaxonomyIdentifier() );
4005 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
4006 System.out.println( entry.getAnnotations().first().getRefValue() );
4009 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
4010 System.out.println( entry.getAnnotations().first().getRefSource() );
4013 if ( entry.getCrossReferences().size() != 5 ) {
4017 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
4018 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
4021 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
4022 System.out.println( entry1.getTaxonomyScientificName() );
4025 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
4026 System.out.println( entry1.getSequenceName() );
4029 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
4030 System.out.println( entry1.getTaxonomyIdentifier() );
4033 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
4034 System.out.println( entry1.getGeneName() );
4037 if ( entry1.getCrossReferences().size() != 6 ) {
4041 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
4042 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
4045 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4046 System.out.println( entry2.getTaxonomyScientificName() );
4049 if ( !entry2.getSequenceName()
4050 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
4051 System.out.println( entry2.getSequenceName() );
4054 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
4055 System.out.println( entry2.getTaxonomyIdentifier() );
4058 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
4059 System.out.println( entry2.getGeneName() );
4062 if ( entry2.getCrossReferences().size() != 3 ) {
4066 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
4067 if ( !entry3.getAccession().equals( "HM043801" ) ) {
4070 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
4071 System.out.println( entry3.getTaxonomyScientificName() );
4074 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4075 System.out.println( entry3.getSequenceName() );
4078 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4079 System.out.println( entry3.getTaxonomyIdentifier() );
4082 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4083 System.out.println( entry3.getSequenceSymbol() );
4086 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4089 if ( entry3.getCrossReferences().size() != 8 ) {
4094 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4095 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4098 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4099 System.out.println( entry4.getTaxonomyScientificName() );
4102 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4103 System.out.println( entry4.getSequenceName() );
4106 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4107 System.out.println( entry4.getTaxonomyIdentifier() );
4110 if ( !entry4.getGeneName().equals( "ras" ) ) {
4111 System.out.println( entry4.getGeneName() );
4114 // if ( !entry4.getChromosome().equals( "ras" ) ) {
4115 // System.out.println( entry4.getChromosome() );
4118 // if ( !entry4.getMap().equals( "ras" ) ) {
4119 // System.out.println( entry4.getMap() );
4125 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
4126 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
4129 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4130 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4133 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4134 System.out.println( entry5.getTaxonomyScientificName() );
4137 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4138 System.out.println( entry5.getSequenceName() );
4141 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4142 System.out.println( entry5.getTaxonomyIdentifier() );
4146 catch ( final IOException e ) {
4147 System.out.println();
4148 System.out.println( "the following might be due to absence internet connection:" );
4149 e.printStackTrace( System.out );
4152 catch ( final Exception e ) {
4153 e.printStackTrace();
4159 private static boolean testExternalNodeRelatedMethods() {
4161 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4162 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4163 PhylogenyNode n = t1.getNode( "A" );
4164 n = n.getNextExternalNode();
4165 if ( !n.getName().equals( "B" ) ) {
4168 n = n.getNextExternalNode();
4169 if ( !n.getName().equals( "C" ) ) {
4172 n = n.getNextExternalNode();
4173 if ( !n.getName().equals( "D" ) ) {
4176 n = t1.getNode( "B" );
4177 while ( !n.isLastExternalNode() ) {
4178 n = n.getNextExternalNode();
4180 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4181 n = t2.getNode( "A" );
4182 n = n.getNextExternalNode();
4183 if ( !n.getName().equals( "B" ) ) {
4186 n = n.getNextExternalNode();
4187 if ( !n.getName().equals( "C" ) ) {
4190 n = n.getNextExternalNode();
4191 if ( !n.getName().equals( "D" ) ) {
4194 n = t2.getNode( "B" );
4195 while ( !n.isLastExternalNode() ) {
4196 n = n.getNextExternalNode();
4198 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4199 n = t3.getNode( "A" );
4200 n = n.getNextExternalNode();
4201 if ( !n.getName().equals( "B" ) ) {
4204 n = n.getNextExternalNode();
4205 if ( !n.getName().equals( "C" ) ) {
4208 n = n.getNextExternalNode();
4209 if ( !n.getName().equals( "D" ) ) {
4212 n = n.getNextExternalNode();
4213 if ( !n.getName().equals( "E" ) ) {
4216 n = n.getNextExternalNode();
4217 if ( !n.getName().equals( "F" ) ) {
4220 n = n.getNextExternalNode();
4221 if ( !n.getName().equals( "G" ) ) {
4224 n = n.getNextExternalNode();
4225 if ( !n.getName().equals( "H" ) ) {
4228 n = t3.getNode( "B" );
4229 while ( !n.isLastExternalNode() ) {
4230 n = n.getNextExternalNode();
4232 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4233 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4234 final PhylogenyNode node = iter.next();
4236 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4237 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4238 final PhylogenyNode node = iter.next();
4240 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4241 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4242 if ( !iter.next().getName().equals( "A" ) ) {
4245 if ( !iter.next().getName().equals( "B" ) ) {
4248 if ( !iter.next().getName().equals( "C" ) ) {
4251 if ( !iter.next().getName().equals( "D" ) ) {
4254 if ( !iter.next().getName().equals( "E" ) ) {
4257 if ( !iter.next().getName().equals( "F" ) ) {
4260 if ( iter.hasNext() ) {
4264 catch ( final Exception e ) {
4265 e.printStackTrace( System.out );
4271 private static boolean testExtractSNFromNodeName() {
4273 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4276 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4279 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4282 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4283 .equals( "Mus musculus musculus" ) ) {
4286 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4287 .equals( "Mus musculus musculus" ) ) {
4290 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4291 .equals( "Mus musculus musculus" ) ) {
4294 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4295 .equals( "Mus musculus musculus" ) ) {
4298 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4301 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4302 .equals( "Mus musculus musculus" ) ) {
4305 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4306 .equals( "Mus musculus musculus" ) ) {
4309 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4312 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4315 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4318 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4321 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4322 .equals( "Mus musculus musculus" ) ) {
4325 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4328 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4331 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4334 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4337 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4340 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4343 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4346 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4349 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4350 .equals( "Mus musculus" ) ) {
4353 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4354 .equals( "Mus musculus" ) ) {
4357 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4360 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4361 .equals( "Mus musculus musculus" ) ) {
4364 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4365 .equals( "Mus musculus musculus" ) ) {
4368 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4369 .equals( "Mus musculus musculus" ) ) {
4372 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4375 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4376 .equals( "Pilostyles mexicana" ) ) {
4379 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4380 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4383 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4384 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4387 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4388 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4391 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4392 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4395 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4396 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4399 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4400 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4403 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4404 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4407 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4408 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4411 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4412 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4415 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4416 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4419 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4420 .equals( "Escherichia coli (strain K12)" ) ) {
4423 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4424 .equals( "Escherichia coli (strain K12)" ) ) {
4427 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4428 .equals( "Escherichia coli (str. K12)" ) ) {
4431 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4432 .equals( "Escherichia coli (str. K12)" ) ) {
4435 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4436 .equals( "Escherichia coli (str. K12)" ) ) {
4439 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4440 .equals( "Escherichia coli (var. K12)" ) ) {
4443 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4444 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4447 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4448 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4452 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4453 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4456 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4457 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4461 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4462 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4465 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4466 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4469 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4470 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4473 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4476 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4479 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4482 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4483 .equals( "Macrocera sp." ) ) {
4486 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4489 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4490 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4493 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4494 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4497 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4498 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4501 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4502 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4506 catch ( final Exception e ) {
4507 e.printStackTrace( System.out );
4513 private static boolean testExtractTaxonomyCodeFromNodeName() {
4515 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4518 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4519 .equals( "SOYBN" ) ) {
4522 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4523 .equals( "ARATH" ) ) {
4526 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4527 .equals( "ARATH" ) ) {
4530 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4533 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4536 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4539 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4540 .equals( "SOYBN" ) ) {
4543 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4544 .equals( "SOYBN" ) ) {
4547 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4548 .equals( "SOYBN" ) ) {
4551 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4552 .equals( "SOYBN" ) ) {
4555 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4556 .equals( "SOYBN" ) ) {
4559 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4560 .equals( "SOYBN" ) ) {
4563 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4564 .equals( "SOYBN" ) ) {
4567 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4568 .equals( "SOYBN" ) ) {
4571 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4574 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4575 .equals( "SOYBN" ) ) {
4578 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4579 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4582 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4583 .equals( "9YX45" ) ) {
4586 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4587 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4588 .equals( "MOUSE" ) ) {
4591 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4592 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4593 .equals( "MOUSE" ) ) {
4596 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4597 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4598 .equals( "MOUSE" ) ) {
4601 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4602 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4605 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4606 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4609 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4610 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4613 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4614 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4617 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4618 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4621 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4622 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4625 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4626 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4629 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4630 .equals( "RAT" ) ) {
4633 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4634 .equals( "PIG" ) ) {
4638 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4639 .equals( "MOUSE" ) ) {
4642 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4643 .equals( "MOUSE" ) ) {
4646 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4650 catch ( final Exception e ) {
4651 e.printStackTrace( System.out );
4657 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4659 PhylogenyNode n = new PhylogenyNode();
4660 n.setName( "tr|B3RJ64" );
4661 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4664 n.setName( "tr.B3RJ64" );
4665 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4668 n.setName( "tr=B3RJ64" );
4669 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4672 n.setName( "tr-B3RJ64" );
4673 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4676 n.setName( "tr/B3RJ64" );
4677 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4680 n.setName( "tr\\B3RJ64" );
4681 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4684 n.setName( "tr_B3RJ64" );
4685 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4688 n.setName( " tr|B3RJ64 " );
4689 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4692 n.setName( "-tr|B3RJ64-" );
4693 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4696 n.setName( "-tr=B3RJ64-" );
4697 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4700 n.setName( "_tr=B3RJ64_" );
4701 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4704 n.setName( " tr_tr|B3RJ64_sp|123 " );
4705 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4708 n.setName( "B3RJ64" );
4709 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4712 n.setName( "sp|B3RJ64" );
4713 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4716 n.setName( "sp|B3RJ64C" );
4717 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4720 n.setName( "sp B3RJ64" );
4721 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4724 n.setName( "sp|B3RJ6X" );
4725 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4728 n.setName( "sp|B3RJ6" );
4729 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4732 n.setName( "K1PYK7_CRAGI" );
4733 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4736 n.setName( "K1PYK7_PEA" );
4737 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4740 n.setName( "K1PYK7_RAT" );
4741 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4744 n.setName( "K1PYK7_PIG" );
4745 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4748 n.setName( "~K1PYK7_PIG~" );
4749 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4752 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4753 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4756 n.setName( "K1PYKX_CRAGI" );
4757 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4760 n.setName( "XXXXX_CRAGI" );
4761 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4764 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4765 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4768 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4769 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4772 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4773 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4776 n = new PhylogenyNode();
4777 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4778 seq.setSymbol( "K1PYK7_CRAGI" );
4779 n.getNodeData().addSequence( seq );
4780 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4783 seq.setSymbol( "tr|B3RJ64" );
4784 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4787 n = new PhylogenyNode();
4788 seq = new org.forester.phylogeny.data.Sequence();
4789 seq.setName( "K1PYK7_CRAGI" );
4790 n.getNodeData().addSequence( seq );
4791 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4794 seq.setName( "tr|B3RJ64" );
4795 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4798 n = new PhylogenyNode();
4799 seq = new org.forester.phylogeny.data.Sequence();
4800 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4801 n.getNodeData().addSequence( seq );
4802 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4805 n = new PhylogenyNode();
4806 seq = new org.forester.phylogeny.data.Sequence();
4807 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4808 n.getNodeData().addSequence( seq );
4809 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4813 n = new PhylogenyNode();
4814 n.setName( "ACP19736" );
4815 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4818 n = new PhylogenyNode();
4819 n.setName( "|ACP19736|" );
4820 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4824 catch ( final Exception e ) {
4825 e.printStackTrace( System.out );
4831 private static boolean testFastaParser() {
4833 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4836 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4839 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4840 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4843 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4846 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4849 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4852 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4855 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4859 catch ( final Exception e ) {
4860 e.printStackTrace();
4866 private static boolean testGenbankAccessorParsing() {
4867 //The format for GenBank Accession numbers are:
4868 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4869 //Protein: 3 letters + 5 numerals
4870 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4871 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4874 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4877 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4880 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4883 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4886 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4889 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4892 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4895 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4898 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4901 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4904 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4907 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4910 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4916 private static boolean testGeneralMsaParser() {
4918 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4919 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4920 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4921 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4922 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4923 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4924 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4925 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4926 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4929 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4932 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4935 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4938 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4941 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4944 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4947 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4950 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4953 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4956 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4959 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4962 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4963 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4966 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4969 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4972 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4973 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4976 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4979 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4982 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4983 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4986 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4989 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4993 catch ( final Exception e ) {
4994 e.printStackTrace();
5000 private static boolean testGeneralTable() {
5002 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
5003 t0.setValue( 3, 2, "23" );
5004 t0.setValue( 10, 1, "error" );
5005 t0.setValue( 10, 1, "110" );
5006 t0.setValue( 9, 1, "19" );
5007 t0.setValue( 1, 10, "101" );
5008 t0.setValue( 10, 10, "1010" );
5009 t0.setValue( 100, 10, "10100" );
5010 t0.setValue( 0, 0, "00" );
5011 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
5014 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
5017 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
5020 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
5023 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
5026 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
5029 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
5032 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
5035 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
5038 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
5039 t1.setValue( "3", "2", "23" );
5040 t1.setValue( "10", "1", "error" );
5041 t1.setValue( "10", "1", "110" );
5042 t1.setValue( "9", "1", "19" );
5043 t1.setValue( "1", "10", "101" );
5044 t1.setValue( "10", "10", "1010" );
5045 t1.setValue( "100", "10", "10100" );
5046 t1.setValue( "0", "0", "00" );
5047 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
5048 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
5051 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
5054 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
5057 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
5060 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
5063 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
5066 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
5069 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
5072 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5075 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5079 catch ( final Exception e ) {
5080 e.printStackTrace( System.out );
5086 private static boolean testGetDistance() {
5088 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5089 final Phylogeny p1 = factory.create( "(((A:1,B:2,X:100)ab:3,C:4)abc:5,(D:7,(E:9,F:10)ef:8)def:6)r",
5090 new NHXParser() )[ 0 ];
5091 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5094 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5097 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5100 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5103 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5106 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5109 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5112 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5115 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5118 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5121 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5124 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5127 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5130 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5133 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5136 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5139 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5142 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5145 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5148 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5151 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5154 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5157 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5160 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5163 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5166 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5169 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5172 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5175 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5178 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5181 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5184 final Phylogeny p2 = factory.create( "((A:4,B:5,C:6)abc:1,(D:7,E:8,F:9)def:2,(G:10,H:11,I:12)ghi:3)r",
5185 new NHXParser() )[ 0 ];
5186 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5189 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5192 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5195 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5198 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5201 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5204 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5207 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5210 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5213 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5216 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5220 catch ( final Exception e ) {
5221 e.printStackTrace( System.out );
5227 private static boolean testGetLCA() {
5229 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5230 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5231 new NHXParser() )[ 0 ];
5232 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5233 if ( !A.getName().equals( "A" ) ) {
5236 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5237 if ( !gh.getName().equals( "gh" ) ) {
5240 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5241 if ( !ab.getName().equals( "ab" ) ) {
5244 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5245 if ( !ab2.getName().equals( "ab" ) ) {
5248 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5249 if ( !gh2.getName().equals( "gh" ) ) {
5252 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5253 if ( !gh3.getName().equals( "gh" ) ) {
5256 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5257 if ( !abc.getName().equals( "abc" ) ) {
5260 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5261 if ( !abc2.getName().equals( "abc" ) ) {
5264 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5265 if ( !abcd.getName().equals( "abcd" ) ) {
5268 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5269 if ( !abcd2.getName().equals( "abcd" ) ) {
5272 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5273 if ( !abcdef.getName().equals( "abcdef" ) ) {
5276 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5277 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5280 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5281 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5284 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5285 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5288 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5289 if ( !abcde.getName().equals( "abcde" ) ) {
5292 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5293 if ( !abcde2.getName().equals( "abcde" ) ) {
5296 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5297 if ( !r.getName().equals( "abcdefgh" ) ) {
5300 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5301 if ( !r2.getName().equals( "abcdefgh" ) ) {
5304 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5305 if ( !r3.getName().equals( "abcdefgh" ) ) {
5308 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5309 if ( !abcde3.getName().equals( "abcde" ) ) {
5312 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5313 if ( !abcde4.getName().equals( "abcde" ) ) {
5316 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5317 if ( !ab3.getName().equals( "ab" ) ) {
5320 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5321 if ( !ab4.getName().equals( "ab" ) ) {
5324 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5325 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5326 if ( !cd.getName().equals( "cd" ) ) {
5329 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5330 if ( !cd2.getName().equals( "cd" ) ) {
5333 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5334 if ( !cde.getName().equals( "cde" ) ) {
5337 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5338 if ( !cde2.getName().equals( "cde" ) ) {
5341 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5342 if ( !cdef.getName().equals( "cdef" ) ) {
5345 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5346 if ( !cdef2.getName().equals( "cdef" ) ) {
5349 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5350 if ( !cdef3.getName().equals( "cdef" ) ) {
5353 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5354 if ( !rt.getName().equals( "r" ) ) {
5357 final Phylogeny p3 = factory
5358 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5359 new NHXParser() )[ 0 ];
5360 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5361 if ( !bc_3.getName().equals( "bc" ) ) {
5364 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5365 if ( !ac_3.getName().equals( "abc" ) ) {
5368 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5369 if ( !ad_3.getName().equals( "abcde" ) ) {
5372 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5373 if ( !af_3.getName().equals( "abcdef" ) ) {
5376 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5377 if ( !ag_3.getName().equals( "" ) ) {
5380 if ( !ag_3.isRoot() ) {
5383 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5384 if ( !al_3.getName().equals( "" ) ) {
5387 if ( !al_3.isRoot() ) {
5390 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5391 if ( !kl_3.getName().equals( "" ) ) {
5394 if ( !kl_3.isRoot() ) {
5397 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5398 if ( !fl_3.getName().equals( "" ) ) {
5401 if ( !fl_3.isRoot() ) {
5404 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5405 if ( !gk_3.getName().equals( "ghijk" ) ) {
5408 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5409 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5410 if ( !r_4.getName().equals( "r" ) ) {
5413 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5414 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5415 if ( !r_5.getName().equals( "root" ) ) {
5418 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5419 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5420 if ( !r_6.getName().equals( "rot" ) ) {
5423 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5424 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5425 if ( !r_7.getName().equals( "rott" ) ) {
5429 catch ( final Exception e ) {
5430 e.printStackTrace( System.out );
5436 private static boolean testGetLCA2() {
5438 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5439 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5440 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5441 PhylogenyMethods.preOrderReId( p_a );
5442 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5443 p_a.getNode( "a" ) );
5444 if ( !p_a_1.getName().equals( "a" ) ) {
5447 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5448 PhylogenyMethods.preOrderReId( p_b );
5449 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5450 p_b.getNode( "a" ) );
5451 if ( !p_b_1.getName().equals( "b" ) ) {
5454 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5455 p_b.getNode( "b" ) );
5456 if ( !p_b_2.getName().equals( "b" ) ) {
5459 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5460 PhylogenyMethods.preOrderReId( p_c );
5461 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5462 p_c.getNode( "a" ) );
5463 if ( !p_c_1.getName().equals( "b" ) ) {
5466 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5467 p_c.getNode( "c" ) );
5468 if ( !p_c_2.getName().equals( "c" ) ) {
5469 System.out.println( p_c_2.getName() );
5473 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5474 p_c.getNode( "b" ) );
5475 if ( !p_c_3.getName().equals( "b" ) ) {
5478 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5479 p_c.getNode( "a" ) );
5480 if ( !p_c_4.getName().equals( "c" ) ) {
5483 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5484 new NHXParser() )[ 0 ];
5485 PhylogenyMethods.preOrderReId( p1 );
5486 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5487 p1.getNode( "A" ) );
5488 if ( !A.getName().equals( "A" ) ) {
5491 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5492 p1.getNode( "gh" ) );
5493 if ( !gh.getName().equals( "gh" ) ) {
5496 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5497 p1.getNode( "B" ) );
5498 if ( !ab.getName().equals( "ab" ) ) {
5501 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5502 p1.getNode( "A" ) );
5503 if ( !ab2.getName().equals( "ab" ) ) {
5506 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5507 p1.getNode( "G" ) );
5508 if ( !gh2.getName().equals( "gh" ) ) {
5511 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5512 p1.getNode( "H" ) );
5513 if ( !gh3.getName().equals( "gh" ) ) {
5516 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5517 p1.getNode( "A" ) );
5518 if ( !abc.getName().equals( "abc" ) ) {
5521 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5522 p1.getNode( "C" ) );
5523 if ( !abc2.getName().equals( "abc" ) ) {
5526 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5527 p1.getNode( "D" ) );
5528 if ( !abcd.getName().equals( "abcd" ) ) {
5531 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5532 p1.getNode( "A" ) );
5533 if ( !abcd2.getName().equals( "abcd" ) ) {
5536 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5537 p1.getNode( "F" ) );
5538 if ( !abcdef.getName().equals( "abcdef" ) ) {
5541 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5542 p1.getNode( "A" ) );
5543 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5546 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5547 p1.getNode( "F" ) );
5548 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5551 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5552 p1.getNode( "ab" ) );
5553 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5556 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5557 p1.getNode( "E" ) );
5558 if ( !abcde.getName().equals( "abcde" ) ) {
5561 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5562 p1.getNode( "A" ) );
5563 if ( !abcde2.getName().equals( "abcde" ) ) {
5566 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5567 p1.getNode( "abcdefgh" ) );
5568 if ( !r.getName().equals( "abcdefgh" ) ) {
5571 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5572 p1.getNode( "H" ) );
5573 if ( !r2.getName().equals( "abcdefgh" ) ) {
5576 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5577 p1.getNode( "A" ) );
5578 if ( !r3.getName().equals( "abcdefgh" ) ) {
5581 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5582 p1.getNode( "abcde" ) );
5583 if ( !abcde3.getName().equals( "abcde" ) ) {
5586 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5587 p1.getNode( "E" ) );
5588 if ( !abcde4.getName().equals( "abcde" ) ) {
5591 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5592 p1.getNode( "B" ) );
5593 if ( !ab3.getName().equals( "ab" ) ) {
5596 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5597 p1.getNode( "ab" ) );
5598 if ( !ab4.getName().equals( "ab" ) ) {
5601 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5602 PhylogenyMethods.preOrderReId( p2 );
5603 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5604 p2.getNode( "d" ) );
5605 if ( !cd.getName().equals( "cd" ) ) {
5608 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5609 p2.getNode( "c" ) );
5610 if ( !cd2.getName().equals( "cd" ) ) {
5613 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5614 p2.getNode( "e" ) );
5615 if ( !cde.getName().equals( "cde" ) ) {
5618 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5619 p2.getNode( "c" ) );
5620 if ( !cde2.getName().equals( "cde" ) ) {
5623 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5624 p2.getNode( "f" ) );
5625 if ( !cdef.getName().equals( "cdef" ) ) {
5628 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5629 p2.getNode( "f" ) );
5630 if ( !cdef2.getName().equals( "cdef" ) ) {
5633 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5634 p2.getNode( "d" ) );
5635 if ( !cdef3.getName().equals( "cdef" ) ) {
5638 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5639 p2.getNode( "a" ) );
5640 if ( !rt.getName().equals( "r" ) ) {
5643 final Phylogeny p3 = factory
5644 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5645 new NHXParser() )[ 0 ];
5646 PhylogenyMethods.preOrderReId( p3 );
5647 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5648 p3.getNode( "c" ) );
5649 if ( !bc_3.getName().equals( "bc" ) ) {
5652 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5653 p3.getNode( "c" ) );
5654 if ( !ac_3.getName().equals( "abc" ) ) {
5657 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5658 p3.getNode( "d" ) );
5659 if ( !ad_3.getName().equals( "abcde" ) ) {
5662 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5663 p3.getNode( "f" ) );
5664 if ( !af_3.getName().equals( "abcdef" ) ) {
5667 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5668 p3.getNode( "g" ) );
5669 if ( !ag_3.getName().equals( "" ) ) {
5672 if ( !ag_3.isRoot() ) {
5675 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5676 p3.getNode( "l" ) );
5677 if ( !al_3.getName().equals( "" ) ) {
5680 if ( !al_3.isRoot() ) {
5683 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5684 p3.getNode( "l" ) );
5685 if ( !kl_3.getName().equals( "" ) ) {
5688 if ( !kl_3.isRoot() ) {
5691 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5692 p3.getNode( "l" ) );
5693 if ( !fl_3.getName().equals( "" ) ) {
5696 if ( !fl_3.isRoot() ) {
5699 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5700 p3.getNode( "k" ) );
5701 if ( !gk_3.getName().equals( "ghijk" ) ) {
5704 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5705 PhylogenyMethods.preOrderReId( p4 );
5706 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5707 p4.getNode( "c" ) );
5708 if ( !r_4.getName().equals( "r" ) ) {
5711 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5712 PhylogenyMethods.preOrderReId( p5 );
5713 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5714 p5.getNode( "c" ) );
5715 if ( !r_5.getName().equals( "root" ) ) {
5718 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5719 PhylogenyMethods.preOrderReId( p6 );
5720 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5721 p6.getNode( "a" ) );
5722 if ( !r_6.getName().equals( "rot" ) ) {
5725 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5726 PhylogenyMethods.preOrderReId( p7 );
5727 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5728 p7.getNode( "e" ) );
5729 if ( !r_7.getName().equals( "rott" ) ) {
5732 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5733 p7.getNode( "a" ) );
5734 if ( !r_71.getName().equals( "rott" ) ) {
5737 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5738 p7.getNode( "rott" ) );
5739 if ( !r_72.getName().equals( "rott" ) ) {
5742 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5743 p7.getNode( "a" ) );
5744 if ( !r_73.getName().equals( "rott" ) ) {
5747 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5748 p7.getNode( "rott" ) );
5749 if ( !r_74.getName().equals( "rott" ) ) {
5752 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5753 p7.getNode( "e" ) );
5754 if ( !r_75.getName().equals( "e" ) ) {
5758 catch ( final Exception e ) {
5759 e.printStackTrace( System.out );
5765 private static boolean testHmmscanOutputParser() {
5766 final String test_dir = Test.PATH_TO_TEST_DATA;
5768 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5769 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5771 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5772 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5773 final List<Protein> proteins = parser2.parse();
5774 if ( parser2.getProteinsEncountered() != 4 ) {
5777 if ( proteins.size() != 4 ) {
5780 if ( parser2.getDomainsEncountered() != 69 ) {
5783 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5786 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5789 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5792 final Protein p1 = proteins.get( 0 );
5793 if ( p1.getNumberOfProteinDomains() != 15 ) {
5796 if ( p1.getLength() != 850 ) {
5799 final Protein p2 = proteins.get( 1 );
5800 if ( p2.getNumberOfProteinDomains() != 51 ) {
5803 if ( p2.getLength() != 1291 ) {
5806 final Protein p3 = proteins.get( 2 );
5807 if ( p3.getNumberOfProteinDomains() != 2 ) {
5810 final Protein p4 = proteins.get( 3 );
5811 if ( p4.getNumberOfProteinDomains() != 1 ) {
5814 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5817 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5820 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5823 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5826 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5829 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5832 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5836 catch ( final Exception e ) {
5837 e.printStackTrace( System.out );
5843 private static boolean testLastExternalNodeMethods() {
5845 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5846 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5847 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5848 final PhylogenyNode n1 = t0.getNode( "A" );
5849 if ( n1.isLastExternalNode() ) {
5852 final PhylogenyNode n2 = t0.getNode( "B" );
5853 if ( n2.isLastExternalNode() ) {
5856 final PhylogenyNode n3 = t0.getNode( "C" );
5857 if ( n3.isLastExternalNode() ) {
5860 final PhylogenyNode n4 = t0.getNode( "D" );
5861 if ( !n4.isLastExternalNode() ) {
5865 catch ( final Exception e ) {
5866 e.printStackTrace( System.out );
5872 private static boolean testLevelOrderIterator() {
5874 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5875 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5876 PhylogenyNodeIterator it0;
5877 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5880 for( it0.reset(); it0.hasNext(); ) {
5883 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5884 if ( !it.next().getName().equals( "r" ) ) {
5887 if ( !it.next().getName().equals( "ab" ) ) {
5890 if ( !it.next().getName().equals( "cd" ) ) {
5893 if ( !it.next().getName().equals( "A" ) ) {
5896 if ( !it.next().getName().equals( "B" ) ) {
5899 if ( !it.next().getName().equals( "C" ) ) {
5902 if ( !it.next().getName().equals( "D" ) ) {
5905 if ( it.hasNext() ) {
5908 final Phylogeny t2 = factory.create( "(((1,2,(a,(X,Y,Z)b)3,4,5,6)A,B,C)abc,(D,E,(f1,(f21)f2,f3)F,G)defg)r",
5909 new NHXParser() )[ 0 ];
5910 PhylogenyNodeIterator it2;
5911 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5914 for( it2.reset(); it2.hasNext(); ) {
5917 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5918 if ( !it3.next().getName().equals( "r" ) ) {
5921 if ( !it3.next().getName().equals( "abc" ) ) {
5924 if ( !it3.next().getName().equals( "defg" ) ) {
5927 if ( !it3.next().getName().equals( "A" ) ) {
5930 if ( !it3.next().getName().equals( "B" ) ) {
5933 if ( !it3.next().getName().equals( "C" ) ) {
5936 if ( !it3.next().getName().equals( "D" ) ) {
5939 if ( !it3.next().getName().equals( "E" ) ) {
5942 if ( !it3.next().getName().equals( "F" ) ) {
5945 if ( !it3.next().getName().equals( "G" ) ) {
5948 if ( !it3.next().getName().equals( "1" ) ) {
5951 if ( !it3.next().getName().equals( "2" ) ) {
5954 if ( !it3.next().getName().equals( "3" ) ) {
5957 if ( !it3.next().getName().equals( "4" ) ) {
5960 if ( !it3.next().getName().equals( "5" ) ) {
5963 if ( !it3.next().getName().equals( "6" ) ) {
5966 if ( !it3.next().getName().equals( "f1" ) ) {
5969 if ( !it3.next().getName().equals( "f2" ) ) {
5972 if ( !it3.next().getName().equals( "f3" ) ) {
5975 if ( !it3.next().getName().equals( "a" ) ) {
5978 if ( !it3.next().getName().equals( "b" ) ) {
5981 if ( !it3.next().getName().equals( "f21" ) ) {
5984 if ( !it3.next().getName().equals( "X" ) ) {
5987 if ( !it3.next().getName().equals( "Y" ) ) {
5990 if ( !it3.next().getName().equals( "Z" ) ) {
5993 if ( it3.hasNext() ) {
5996 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5997 PhylogenyNodeIterator it4;
5998 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
6001 for( it4.reset(); it4.hasNext(); ) {
6004 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
6005 if ( !it5.next().getName().equals( "r" ) ) {
6008 if ( !it5.next().getName().equals( "A" ) ) {
6011 if ( !it5.next().getName().equals( "B" ) ) {
6014 if ( !it5.next().getName().equals( "C" ) ) {
6017 if ( !it5.next().getName().equals( "D" ) ) {
6020 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
6021 PhylogenyNodeIterator it6;
6022 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
6025 for( it6.reset(); it6.hasNext(); ) {
6028 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
6029 if ( !it7.next().getName().equals( "A" ) ) {
6032 if ( it.hasNext() ) {
6036 catch ( final Exception e ) {
6037 e.printStackTrace( System.out );
6043 private static boolean testMafft( final String path ) {
6045 final List<String> opts = new ArrayList<String>();
6046 opts.add( "--maxiterate" );
6048 opts.add( "--localpair" );
6049 opts.add( "--quiet" );
6051 final MsaInferrer mafft = Mafft.createInstance( path );
6052 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
6053 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
6056 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
6060 catch ( final Exception e ) {
6061 e.printStackTrace( System.out );
6067 private static boolean testMidpointrooting() {
6069 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6070 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
6071 PhylogenyMethods.midpointRoot( t0 );
6072 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6075 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6078 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6082 final Phylogeny t1 = factory.create( "((A:1,B:2)AB:1[&&NHX:B=55],(C:3,D:4)CD:3[&&NHX:B=10])ABCD:0.5",
6083 new NHXParser() )[ 0 ];
6084 if ( !t1.isRooted() ) {
6087 PhylogenyMethods.midpointRoot( t1 );
6088 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6091 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6094 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6097 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6100 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6103 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6106 t1.reRoot( t1.getNode( "A" ) );
6107 PhylogenyMethods.midpointRoot( t1 );
6108 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6111 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6114 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6117 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6120 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6124 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6128 catch ( final Exception e ) {
6129 e.printStackTrace( System.out );
6135 private static boolean testMsaQualityMethod() {
6137 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6138 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6139 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6140 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6141 final List<Sequence> l = new ArrayList<Sequence>();
6146 final Msa msa = BasicMsa.createInstance( l );
6147 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6150 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6153 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6156 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6159 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6162 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6165 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6169 catch ( final Exception e ) {
6170 e.printStackTrace( System.out );
6176 private static boolean testMsaEntropy() {
6178 final Sequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6179 final Sequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6180 final Sequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6181 final Sequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6182 final List<Sequence> l = new ArrayList<Sequence>();
6187 final Msa msa = BasicMsa.createInstance( l );
6188 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6189 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6190 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6191 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6192 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6193 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6194 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6195 System.out.println();
6196 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6197 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6198 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6199 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6200 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6201 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6202 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6203 final List<Sequence> l2 = new ArrayList<Sequence>();
6204 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6205 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6206 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6207 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6208 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6209 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6210 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6211 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6212 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6213 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6214 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6215 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6216 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6217 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6218 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6219 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6220 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6221 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6222 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6223 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6224 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6225 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6226 final Msa msa2 = BasicMsa.createInstance( l2 );
6227 System.out.println();
6228 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6229 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6230 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6232 catch ( final Exception e ) {
6233 e.printStackTrace( System.out );
6239 private static boolean testDeleteableMsa() {
6241 final Sequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6242 final Sequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6243 final Sequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6244 final Sequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6245 final Sequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6246 final Sequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6247 final List<Sequence> l0 = new ArrayList<Sequence>();
6254 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6255 dmsa0.deleteRow( "b", false );
6256 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6259 dmsa0.deleteRow( "e", false );
6260 dmsa0.deleteRow( "a", false );
6261 dmsa0.deleteRow( "f", false );
6262 if ( dmsa0.getLength() != 4 ) {
6265 if ( dmsa0.getNumberOfSequences() != 2 ) {
6268 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6271 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6274 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6277 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6280 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6283 dmsa0.deleteRow( "c", false );
6284 dmsa0.deleteRow( "d", false );
6285 if ( dmsa0.getNumberOfSequences() != 0 ) {
6289 final Sequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6290 final Sequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6291 final Sequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6292 final Sequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6293 final Sequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6294 final Sequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6295 final List<Sequence> l1 = new ArrayList<Sequence>();
6302 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6303 dmsa1.deleteGapOnlyColumns();
6304 dmsa1.deleteRow( "a", false );
6305 dmsa1.deleteRow( "f", false );
6306 dmsa1.deleteRow( "d", false );
6307 dmsa1.deleteGapOnlyColumns();
6308 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6311 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6314 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6317 dmsa1.deleteRow( "c", false );
6318 dmsa1.deleteGapOnlyColumns();
6319 final Writer w0 = new StringWriter();
6320 dmsa1.write( w0, MSA_FORMAT.FASTA );
6321 final Writer w1 = new StringWriter();
6322 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6323 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6326 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6330 final Sequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6331 final Sequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6332 final Sequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6333 final Sequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6334 final Sequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6335 final Sequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6336 final List<Sequence> l2 = new ArrayList<Sequence>();
6343 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6344 dmsa2.deleteGapColumns( 0.5 );
6345 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
6348 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
6351 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
6354 dmsa2.deleteGapColumns( 0.2 );
6355 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
6358 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
6361 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
6364 dmsa2.deleteGapColumns( 0 );
6365 dmsa2.deleteRow( "a", false );
6366 dmsa2.deleteRow( "b", false );
6367 dmsa2.deleteRow( "f", false );
6368 dmsa2.deleteRow( "e", false );
6369 dmsa2.setIdentifier( 0, "new_c" );
6370 dmsa2.setIdentifier( 1, "new_d" );
6371 dmsa2.setResidueAt( 0, 0, 'x' );
6372 final Sequence s = dmsa2.deleteRow( "new_d", true );
6373 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
6376 final Writer w = new StringWriter();
6377 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6378 final String phylip = w.toString();
6379 if ( !phylip.equals( "1 1" + ForesterUtil.LINE_SEPARATOR + "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6380 System.out.println( phylip );
6383 final Writer w2 = new StringWriter();
6384 dmsa2.write( w2, MSA_FORMAT.FASTA );
6385 final String fasta = w2.toString();
6386 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6387 System.out.println( fasta );
6391 catch ( final Exception e ) {
6392 e.printStackTrace( System.out );
6398 private static boolean testNextNodeWithCollapsing() {
6400 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6402 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6403 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6404 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6405 t0.getNode( "cd" ).setCollapse( true );
6406 t0.getNode( "cde" ).setCollapse( true );
6407 n = t0.getFirstExternalNode();
6408 while ( n != null ) {
6410 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6412 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6415 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6418 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6421 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6424 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6427 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6431 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6432 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6433 t1.getNode( "ab" ).setCollapse( true );
6434 t1.getNode( "cd" ).setCollapse( true );
6435 t1.getNode( "cde" ).setCollapse( true );
6436 n = t1.getNode( "ab" );
6437 ext = new ArrayList<PhylogenyNode>();
6438 while ( n != null ) {
6440 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6442 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6445 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6448 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6451 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6454 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6460 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6461 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6462 t2.getNode( "ab" ).setCollapse( true );
6463 t2.getNode( "cd" ).setCollapse( true );
6464 t2.getNode( "cde" ).setCollapse( true );
6465 t2.getNode( "c" ).setCollapse( true );
6466 t2.getNode( "d" ).setCollapse( true );
6467 t2.getNode( "e" ).setCollapse( true );
6468 t2.getNode( "gh" ).setCollapse( true );
6469 n = t2.getNode( "ab" );
6470 ext = new ArrayList<PhylogenyNode>();
6471 while ( n != null ) {
6473 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6475 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6478 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6481 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6484 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6490 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6491 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6492 t3.getNode( "ab" ).setCollapse( true );
6493 t3.getNode( "cd" ).setCollapse( true );
6494 t3.getNode( "cde" ).setCollapse( true );
6495 t3.getNode( "c" ).setCollapse( true );
6496 t3.getNode( "d" ).setCollapse( true );
6497 t3.getNode( "e" ).setCollapse( true );
6498 t3.getNode( "gh" ).setCollapse( true );
6499 t3.getNode( "fgh" ).setCollapse( true );
6500 n = t3.getNode( "ab" );
6501 ext = new ArrayList<PhylogenyNode>();
6502 while ( n != null ) {
6504 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6506 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6509 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6512 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6518 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6519 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6520 t4.getNode( "ab" ).setCollapse( true );
6521 t4.getNode( "cd" ).setCollapse( true );
6522 t4.getNode( "cde" ).setCollapse( true );
6523 t4.getNode( "c" ).setCollapse( true );
6524 t4.getNode( "d" ).setCollapse( true );
6525 t4.getNode( "e" ).setCollapse( true );
6526 t4.getNode( "gh" ).setCollapse( true );
6527 t4.getNode( "fgh" ).setCollapse( true );
6528 t4.getNode( "abcdefgh" ).setCollapse( true );
6529 n = t4.getNode( "abcdefgh" );
6530 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6535 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6536 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6538 n = t5.getFirstExternalNode();
6539 while ( n != null ) {
6541 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6543 if ( ext.size() != 8 ) {
6546 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6549 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6552 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6555 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6558 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6561 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6564 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6567 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6572 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6573 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6575 t6.getNode( "ab" ).setCollapse( true );
6576 n = t6.getNode( "ab" );
6577 while ( n != null ) {
6579 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6581 if ( ext.size() != 7 ) {
6584 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6587 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6590 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6593 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6596 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6599 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6602 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6607 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6608 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6610 t7.getNode( "cd" ).setCollapse( true );
6611 n = t7.getNode( "a" );
6612 while ( n != null ) {
6614 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6616 if ( ext.size() != 7 ) {
6619 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6622 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6625 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6628 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6631 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6634 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6637 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6642 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6643 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6645 t8.getNode( "cd" ).setCollapse( true );
6646 t8.getNode( "c" ).setCollapse( true );
6647 t8.getNode( "d" ).setCollapse( true );
6648 n = t8.getNode( "a" );
6649 while ( n != null ) {
6651 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6653 if ( ext.size() != 7 ) {
6656 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6659 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6662 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6663 System.out.println( "2 fail" );
6666 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6669 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6672 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6675 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6680 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6681 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6683 t9.getNode( "gh" ).setCollapse( true );
6684 n = t9.getNode( "a" );
6685 while ( n != null ) {
6687 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6689 if ( ext.size() != 7 ) {
6692 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6695 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6698 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6701 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6704 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6707 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6710 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6715 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6716 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6718 t10.getNode( "gh" ).setCollapse( true );
6719 t10.getNode( "g" ).setCollapse( true );
6720 t10.getNode( "h" ).setCollapse( true );
6721 n = t10.getNode( "a" );
6722 while ( n != null ) {
6724 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6726 if ( ext.size() != 7 ) {
6729 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6732 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6735 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6738 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6741 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6744 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6747 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6752 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6753 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6755 t11.getNode( "gh" ).setCollapse( true );
6756 t11.getNode( "fgh" ).setCollapse( true );
6757 n = t11.getNode( "a" );
6758 while ( n != null ) {
6760 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6762 if ( ext.size() != 6 ) {
6765 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6768 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6771 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6774 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6777 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6780 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6785 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6786 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6788 t12.getNode( "gh" ).setCollapse( true );
6789 t12.getNode( "fgh" ).setCollapse( true );
6790 t12.getNode( "g" ).setCollapse( true );
6791 t12.getNode( "h" ).setCollapse( true );
6792 t12.getNode( "f" ).setCollapse( true );
6793 n = t12.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" ) ) {
6821 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6822 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6824 t13.getNode( "ab" ).setCollapse( true );
6825 t13.getNode( "b" ).setCollapse( true );
6826 t13.getNode( "fgh" ).setCollapse( true );
6827 t13.getNode( "gh" ).setCollapse( true );
6828 n = t13.getNode( "ab" );
6829 while ( n != null ) {
6831 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6833 if ( ext.size() != 5 ) {
6836 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6839 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6842 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6845 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6848 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6853 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6854 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6856 t14.getNode( "ab" ).setCollapse( true );
6857 t14.getNode( "a" ).setCollapse( true );
6858 t14.getNode( "fgh" ).setCollapse( true );
6859 t14.getNode( "gh" ).setCollapse( true );
6860 n = t14.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" ) ) {
6885 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" );
6886 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6888 t15.getNode( "ab" ).setCollapse( true );
6889 t15.getNode( "a" ).setCollapse( true );
6890 t15.getNode( "fgh" ).setCollapse( true );
6891 t15.getNode( "gh" ).setCollapse( true );
6892 n = t15.getNode( "ab" );
6893 while ( n != null ) {
6895 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6897 if ( ext.size() != 6 ) {
6900 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6903 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6906 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6909 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6912 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6915 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6920 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" );
6921 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6923 t16.getNode( "ab" ).setCollapse( true );
6924 t16.getNode( "a" ).setCollapse( true );
6925 t16.getNode( "fgh" ).setCollapse( true );
6926 t16.getNode( "gh" ).setCollapse( true );
6927 t16.getNode( "cd" ).setCollapse( true );
6928 t16.getNode( "cde" ).setCollapse( true );
6929 t16.getNode( "d" ).setCollapse( true );
6930 t16.getNode( "x" ).setCollapse( true );
6931 n = t16.getNode( "ab" );
6932 while ( n != null ) {
6934 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6936 if ( ext.size() != 4 ) {
6939 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6942 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6945 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6948 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6952 catch ( final Exception e ) {
6953 e.printStackTrace( System.out );
6959 private static boolean testNexusCharactersParsing() {
6961 final NexusCharactersParser parser = new NexusCharactersParser();
6962 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6964 String[] labels = parser.getCharStateLabels();
6965 if ( labels.length != 7 ) {
6968 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6971 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6974 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6977 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6980 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6983 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6986 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6989 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6991 labels = parser.getCharStateLabels();
6992 if ( labels.length != 7 ) {
6995 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6998 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7001 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7004 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7007 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7010 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7013 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7017 catch ( final Exception e ) {
7018 e.printStackTrace( System.out );
7024 private static boolean testNexusMatrixParsing() {
7026 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
7027 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
7029 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
7030 if ( m.getNumberOfCharacters() != 9 ) {
7033 if ( m.getNumberOfIdentifiers() != 5 ) {
7036 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
7039 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
7042 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
7045 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
7048 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
7051 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
7054 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
7057 // if ( labels.length != 7 ) {
7060 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7063 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7066 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7069 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7072 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7075 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7078 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7081 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7083 // labels = parser.getCharStateLabels();
7084 // if ( labels.length != 7 ) {
7087 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7090 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7093 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7096 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7099 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7102 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7105 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7109 catch ( final Exception e ) {
7110 e.printStackTrace( System.out );
7116 private static boolean testNexusTreeParsing() {
7118 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7119 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7120 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7121 if ( phylogenies.length != 1 ) {
7124 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7127 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7131 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7132 if ( phylogenies.length != 1 ) {
7135 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7138 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7142 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7143 if ( phylogenies.length != 1 ) {
7146 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7149 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7152 if ( phylogenies[ 0 ].isRooted() ) {
7156 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7157 if ( phylogenies.length != 18 ) {
7160 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7163 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7166 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7169 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7172 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7175 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7178 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7181 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7184 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7187 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7190 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7193 if ( phylogenies[ 8 ].isRooted() ) {
7196 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7199 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7202 if ( !phylogenies[ 9 ].isRooted() ) {
7205 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7208 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7211 if ( !phylogenies[ 10 ].isRooted() ) {
7214 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7217 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7220 if ( phylogenies[ 11 ].isRooted() ) {
7223 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7226 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7229 if ( !phylogenies[ 12 ].isRooted() ) {
7232 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7235 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7238 if ( !phylogenies[ 13 ].isRooted() ) {
7241 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7244 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7247 if ( !phylogenies[ 14 ].isRooted() ) {
7250 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7253 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7256 if ( phylogenies[ 15 ].isRooted() ) {
7259 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7262 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7265 if ( !phylogenies[ 16 ].isRooted() ) {
7268 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7271 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7274 if ( phylogenies[ 17 ].isRooted() ) {
7277 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7280 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7282 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7283 if ( phylogenies.length != 9 ) {
7286 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7287 .getDistanceToParent() ) ) {
7290 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7291 .getDistanceToParent() ) ) {
7294 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7297 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7300 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7303 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7306 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7310 catch ( final Exception e ) {
7311 e.printStackTrace( System.out );
7317 private static boolean testNexusTreeParsingIterating() {
7319 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7320 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7321 if ( !p.hasNext() ) {
7324 Phylogeny phy = p.next();
7325 if ( phy == null ) {
7328 if ( phy.getNumberOfExternalNodes() != 25 ) {
7331 if ( !phy.getName().equals( "" ) ) {
7334 if ( p.hasNext() ) {
7338 if ( phy != null ) {
7343 if ( !p.hasNext() ) {
7347 if ( phy == null ) {
7350 if ( phy.getNumberOfExternalNodes() != 25 ) {
7353 if ( !phy.getName().equals( "" ) ) {
7356 if ( p.hasNext() ) {
7360 if ( phy != null ) {
7364 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7365 if ( !p.hasNext() ) {
7369 if ( phy == null ) {
7372 if ( phy.getNumberOfExternalNodes() != 10 ) {
7375 if ( !phy.getName().equals( "name" ) ) {
7378 if ( p.hasNext() ) {
7382 if ( phy != null ) {
7387 if ( !p.hasNext() ) {
7391 if ( phy == null ) {
7394 if ( phy.getNumberOfExternalNodes() != 10 ) {
7397 if ( !phy.getName().equals( "name" ) ) {
7400 if ( p.hasNext() ) {
7404 if ( phy != null ) {
7408 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7409 if ( !p.hasNext() ) {
7413 if ( phy == null ) {
7416 if ( phy.getNumberOfExternalNodes() != 3 ) {
7419 if ( !phy.getName().equals( "" ) ) {
7422 if ( phy.isRooted() ) {
7425 if ( p.hasNext() ) {
7429 if ( phy != null ) {
7434 if ( !p.hasNext() ) {
7438 if ( phy == null ) {
7441 if ( phy.getNumberOfExternalNodes() != 3 ) {
7444 if ( !phy.getName().equals( "" ) ) {
7447 if ( p.hasNext() ) {
7451 if ( phy != null ) {
7455 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7456 if ( !p.hasNext() ) {
7461 if ( phy == null ) {
7464 if ( phy.getNumberOfExternalNodes() != 10 ) {
7467 if ( !phy.getName().equals( "tree 0" ) ) {
7471 if ( !p.hasNext() ) {
7475 if ( phy == null ) {
7478 if ( phy.getNumberOfExternalNodes() != 10 ) {
7481 if ( !phy.getName().equals( "tree 1" ) ) {
7485 if ( !p.hasNext() ) {
7489 if ( phy == null ) {
7492 if ( phy.getNumberOfExternalNodes() != 3 ) {
7493 System.out.println( phy.toString() );
7496 if ( !phy.getName().equals( "" ) ) {
7499 if ( phy.isRooted() ) {
7503 if ( !p.hasNext() ) {
7507 if ( phy == null ) {
7510 if ( phy.getNumberOfExternalNodes() != 4 ) {
7513 if ( !phy.getName().equals( "" ) ) {
7516 if ( !phy.isRooted() ) {
7520 if ( !p.hasNext() ) {
7524 if ( phy == null ) {
7527 if ( phy.getNumberOfExternalNodes() != 5 ) {
7528 System.out.println( phy.getNumberOfExternalNodes() );
7531 if ( !phy.getName().equals( "" ) ) {
7534 if ( !phy.isRooted() ) {
7538 if ( !p.hasNext() ) {
7542 if ( phy == null ) {
7545 if ( phy.getNumberOfExternalNodes() != 3 ) {
7548 if ( !phy.getName().equals( "" ) ) {
7551 if ( phy.isRooted() ) {
7555 if ( !p.hasNext() ) {
7559 if ( phy == null ) {
7562 if ( phy.getNumberOfExternalNodes() != 2 ) {
7565 if ( !phy.getName().equals( "" ) ) {
7568 if ( !phy.isRooted() ) {
7572 if ( !p.hasNext() ) {
7576 if ( phy.getNumberOfExternalNodes() != 3 ) {
7579 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7582 if ( !phy.isRooted() ) {
7586 if ( !p.hasNext() ) {
7590 if ( phy.getNumberOfExternalNodes() != 3 ) {
7593 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7596 if ( !phy.getName().equals( "tree 8" ) ) {
7600 if ( !p.hasNext() ) {
7604 if ( phy.getNumberOfExternalNodes() != 3 ) {
7607 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7610 if ( !phy.getName().equals( "tree 9" ) ) {
7614 if ( !p.hasNext() ) {
7618 if ( phy.getNumberOfExternalNodes() != 3 ) {
7621 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7624 if ( !phy.getName().equals( "tree 10" ) ) {
7627 if ( !phy.isRooted() ) {
7631 if ( !p.hasNext() ) {
7635 if ( phy.getNumberOfExternalNodes() != 3 ) {
7638 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7641 if ( !phy.getName().equals( "tree 11" ) ) {
7644 if ( phy.isRooted() ) {
7648 if ( !p.hasNext() ) {
7652 if ( phy.getNumberOfExternalNodes() != 3 ) {
7655 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7658 if ( !phy.getName().equals( "tree 12" ) ) {
7661 if ( !phy.isRooted() ) {
7665 if ( !p.hasNext() ) {
7669 if ( phy.getNumberOfExternalNodes() != 3 ) {
7672 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7675 if ( !phy.getName().equals( "tree 13" ) ) {
7678 if ( !phy.isRooted() ) {
7682 if ( !p.hasNext() ) {
7686 if ( phy.getNumberOfExternalNodes() != 10 ) {
7687 System.out.println( phy.getNumberOfExternalNodes() );
7692 .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;" ) ) {
7693 System.out.println( phy.toNewHampshire() );
7696 if ( !phy.getName().equals( "tree 14" ) ) {
7699 if ( !phy.isRooted() ) {
7703 if ( !p.hasNext() ) {
7707 if ( phy.getNumberOfExternalNodes() != 10 ) {
7708 System.out.println( phy.getNumberOfExternalNodes() );
7713 .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;" ) ) {
7714 System.out.println( phy.toNewHampshire() );
7717 if ( !phy.getName().equals( "tree 15" ) ) {
7720 if ( phy.isRooted() ) {
7724 if ( !p.hasNext() ) {
7728 if ( phy.getNumberOfExternalNodes() != 10 ) {
7729 System.out.println( phy.getNumberOfExternalNodes() );
7734 .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;" ) ) {
7735 System.out.println( phy.toNewHampshire() );
7738 if ( !phy.getName().equals( "tree 16" ) ) {
7741 if ( !phy.isRooted() ) {
7745 if ( !p.hasNext() ) {
7749 if ( phy.getNumberOfExternalNodes() != 10 ) {
7750 System.out.println( phy.getNumberOfExternalNodes() );
7755 .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;" ) ) {
7756 System.out.println( phy.toNewHampshire() );
7759 if ( !phy.getName().equals( "tree 17" ) ) {
7762 if ( phy.isRooted() ) {
7766 if ( p.hasNext() ) {
7770 if ( phy != null ) {
7775 if ( !p.hasNext() ) {
7779 if ( phy == null ) {
7782 if ( phy.getNumberOfExternalNodes() != 10 ) {
7785 if ( !phy.getName().equals( "tree 0" ) ) {
7789 if ( !p.hasNext() ) {
7793 if ( phy == null ) {
7796 if ( phy.getNumberOfExternalNodes() != 10 ) {
7799 if ( !phy.getName().equals( "tree 1" ) ) {
7803 if ( !p.hasNext() ) {
7807 if ( phy == null ) {
7810 if ( phy.getNumberOfExternalNodes() != 3 ) {
7813 if ( !phy.getName().equals( "" ) ) {
7816 if ( phy.isRooted() ) {
7820 if ( !p.hasNext() ) {
7824 if ( phy == null ) {
7827 if ( phy.getNumberOfExternalNodes() != 4 ) {
7830 if ( !phy.getName().equals( "" ) ) {
7833 if ( !phy.isRooted() ) {
7837 if ( !p.hasNext() ) {
7841 if ( phy == null ) {
7844 if ( phy.getNumberOfExternalNodes() != 5 ) {
7845 System.out.println( phy.getNumberOfExternalNodes() );
7848 if ( !phy.getName().equals( "" ) ) {
7851 if ( !phy.isRooted() ) {
7855 if ( !p.hasNext() ) {
7859 if ( phy == null ) {
7862 if ( phy.getNumberOfExternalNodes() != 3 ) {
7865 if ( !phy.getName().equals( "" ) ) {
7868 if ( phy.isRooted() ) {
7872 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7873 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7875 if ( !p2.hasNext() ) {
7879 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7882 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7886 if ( !p2.hasNext() ) {
7891 if ( !p2.hasNext() ) {
7896 if ( !p2.hasNext() ) {
7901 if ( !p2.hasNext() ) {
7906 if ( !p2.hasNext() ) {
7911 if ( !p2.hasNext() ) {
7916 if ( !p2.hasNext() ) {
7921 if ( !p2.hasNext() ) {
7925 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7928 if ( p2.hasNext() ) {
7932 if ( phy != null ) {
7937 if ( !p2.hasNext() ) {
7941 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7944 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7948 catch ( final Exception e ) {
7949 e.printStackTrace( System.out );
7955 private static boolean testNexusTreeParsingTranslating() {
7957 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7958 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7959 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7960 if ( phylogenies.length != 1 ) {
7963 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7966 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7969 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7972 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7975 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7976 .equals( "Aranaeus" ) ) {
7980 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7981 if ( phylogenies.length != 3 ) {
7984 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7987 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7990 if ( phylogenies[ 0 ].isRooted() ) {
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" ) ) {
8003 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8006 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8009 if ( phylogenies[ 1 ].isRooted() ) {
8012 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8015 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8018 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8019 .equals( "Aranaeus" ) ) {
8022 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8025 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8028 if ( !phylogenies[ 2 ].isRooted() ) {
8031 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8034 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8037 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8038 .equals( "Aranaeus" ) ) {
8042 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
8043 if ( phylogenies.length != 3 ) {
8046 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8049 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8052 if ( phylogenies[ 0 ].isRooted() ) {
8055 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8058 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8061 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8062 .equals( "Aranaeus" ) ) {
8065 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8068 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8071 if ( phylogenies[ 1 ].isRooted() ) {
8074 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8077 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8080 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8081 .equals( "Aranaeus" ) ) {
8084 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8087 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8090 if ( !phylogenies[ 2 ].isRooted() ) {
8093 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8096 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8099 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8100 .equals( "Aranaeus" ) ) {
8103 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8104 if ( phylogenies.length != 3 ) {
8107 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8112 catch ( final Exception e ) {
8113 e.printStackTrace( System.out );
8119 private static boolean testNHParsing() {
8121 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8122 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8123 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8126 final NHXParser nhxp = new NHXParser();
8127 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8128 nhxp.setReplaceUnderscores( true );
8129 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8130 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8133 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8136 final Phylogeny p1b = factory
8137 .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 ",
8138 new NHXParser() )[ 0 ];
8139 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8142 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8145 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
8146 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8147 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8148 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
8149 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8150 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8151 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8152 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8153 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8154 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8155 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8156 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
8157 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8159 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8162 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8165 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8168 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8171 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8172 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8173 final String p16_S = "((A,B),C)";
8174 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8175 if ( p16.length != 1 ) {
8178 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8181 final String p17_S = "(C,(A,B))";
8182 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8183 if ( p17.length != 1 ) {
8186 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8189 final String p18_S = "((A,B),(C,D))";
8190 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8191 if ( p18.length != 1 ) {
8194 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8197 final String p19_S = "(((A,B),C),D)";
8198 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8199 if ( p19.length != 1 ) {
8202 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8205 final String p20_S = "(A,(B,(C,D)))";
8206 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8207 if ( p20.length != 1 ) {
8210 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8213 final String p21_S = "(A,(B,(C,(D,E))))";
8214 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8215 if ( p21.length != 1 ) {
8218 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8221 final String p22_S = "((((A,B),C),D),E)";
8222 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8223 if ( p22.length != 1 ) {
8226 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8229 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8230 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8231 if ( p23.length != 1 ) {
8232 System.out.println( "xl=" + p23.length );
8236 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8239 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8240 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8241 if ( p24.length != 1 ) {
8244 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8247 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8248 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8249 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8250 if ( p241.length != 2 ) {
8253 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8256 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8259 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8260 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8261 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8262 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8263 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8264 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8265 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8266 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8267 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8268 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8271 final String p26_S = "(A,B)ab";
8272 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8273 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8276 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8277 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8278 if ( p27s.length != 1 ) {
8279 System.out.println( "xxl=" + p27s.length );
8283 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8284 System.out.println( p27s[ 0 ].toNewHampshireX() );
8288 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8290 if ( p27.length != 1 ) {
8291 System.out.println( "yl=" + p27.length );
8295 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8296 System.out.println( p27[ 0 ].toNewHampshireX() );
8300 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8301 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8302 final String p28_S3 = "(A,B)ab";
8303 final String p28_S4 = "((((A,B),C),D),;E;)";
8304 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8306 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8309 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8312 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8315 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8318 if ( p28.length != 4 ) {
8321 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";
8322 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8323 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8326 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";
8327 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8328 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8331 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8332 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8333 if ( ( p32.length != 0 ) ) {
8336 final String p33_S = "A";
8337 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8338 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8341 final String p34_S = "B;";
8342 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8343 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8346 final String p35_S = "B:0.2";
8347 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8348 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8351 final String p36_S = "(A)";
8352 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8353 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8356 final String p37_S = "((A))";
8357 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8358 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8361 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8362 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8363 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8366 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8367 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8368 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8371 final String p40_S = "(A,B,C)";
8372 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8373 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8376 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8377 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8378 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8381 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8382 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8383 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8386 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)";
8387 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8388 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8391 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)))";
8392 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8393 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8396 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8397 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8398 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8401 final String p46_S = "";
8402 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8403 if ( p46.length != 0 ) {
8406 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8407 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8410 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8411 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8414 final Phylogeny p49 = factory
8415 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8416 new NHXParser() )[ 0 ];
8417 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8420 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8421 if ( p50.getNode( "A" ) == null ) {
8424 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8425 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8428 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8431 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8432 .equals( "((A,B)88:2.0,C);" ) ) {
8435 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8436 if ( p51.getNode( "A(A" ) == null ) {
8439 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8440 if ( p52.getNode( "A(A" ) == null ) {
8443 final Phylogeny p53 = factory
8444 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8445 new NHXParser() )[ 0 ];
8446 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8449 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8450 if ( p54.getNode( "A" ) == null ) {
8453 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8456 final Phylogeny p55 = factory
8457 .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);" ),
8458 new NHXParser() )[ 0 ];
8461 .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);" ) ) {
8462 System.out.println( p55.toNewHampshire() );
8465 final Phylogeny p56 = factory
8466 .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);" ),
8467 new NHXParser() )[ 0 ];
8470 .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);" ) ) {
8471 System.out.println( p56.toNewHampshire() );
8474 final Phylogeny p57 = factory
8475 .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);" ),
8476 new NHXParser() )[ 0 ];
8479 .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);" ) ) {
8480 System.out.println( p56.toNewHampshire() );
8483 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8484 final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ];
8485 if ( !p58.toNewHampshire().equals( s58 ) ) {
8486 System.out.println( p58.toNewHampshire() );
8489 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8490 final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ];
8491 if ( !p59.toNewHampshire().equals( s59 ) ) {
8492 System.out.println( p59.toNewHampshire() );
8495 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8496 final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ];
8497 if ( !p60.toNewHampshire().equals( s60 ) ) {
8498 System.out.println( p60.toNewHampshire() );
8501 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8502 final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ];
8503 if ( !p61.toNewHampshire()
8504 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8505 System.out.println( p61.toNewHampshire() );
8509 catch ( final Exception e ) {
8510 e.printStackTrace( System.out );
8516 private static boolean testNHParsingIter() {
8518 final String p0_str = "(A,B);";
8519 final NHXParser p = new NHXParser();
8520 p.setSource( p0_str );
8521 if ( !p.hasNext() ) {
8524 final Phylogeny p0 = p.next();
8525 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8526 System.out.println( p0.toNewHampshire() );
8529 if ( p.hasNext() ) {
8532 if ( p.next() != null ) {
8536 final String p00_str = "(A,B)root;";
8537 p.setSource( p00_str );
8538 final Phylogeny p00 = p.next();
8539 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8540 System.out.println( p00.toNewHampshire() );
8544 final String p000_str = "A;";
8545 p.setSource( p000_str );
8546 final Phylogeny p000 = p.next();
8547 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8548 System.out.println( p000.toNewHampshire() );
8552 final String p0000_str = "A";
8553 p.setSource( p0000_str );
8554 final Phylogeny p0000 = p.next();
8555 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8556 System.out.println( p0000.toNewHampshire() );
8560 p.setSource( "(A)" );
8561 final Phylogeny p00000 = p.next();
8562 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8563 System.out.println( p00000.toNewHampshire() );
8567 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8568 p.setSource( p1_str );
8569 if ( !p.hasNext() ) {
8572 final Phylogeny p1_0 = p.next();
8573 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8574 System.out.println( p1_0.toNewHampshire() );
8577 if ( !p.hasNext() ) {
8580 final Phylogeny p1_1 = p.next();
8581 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8582 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8585 if ( !p.hasNext() ) {
8588 final Phylogeny p1_2 = p.next();
8589 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8590 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8593 if ( !p.hasNext() ) {
8596 final Phylogeny p1_3 = p.next();
8597 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8598 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8601 if ( p.hasNext() ) {
8604 if ( p.next() != null ) {
8608 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8609 p.setSource( p2_str );
8610 if ( !p.hasNext() ) {
8613 Phylogeny p2_0 = p.next();
8614 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8615 System.out.println( p2_0.toNewHampshire() );
8618 if ( !p.hasNext() ) {
8621 Phylogeny p2_1 = p.next();
8622 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8623 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8626 if ( !p.hasNext() ) {
8629 Phylogeny p2_2 = p.next();
8630 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8631 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8634 if ( !p.hasNext() ) {
8637 Phylogeny p2_3 = p.next();
8638 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8639 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8642 if ( !p.hasNext() ) {
8645 Phylogeny p2_4 = p.next();
8646 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8647 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8650 if ( p.hasNext() ) {
8653 if ( p.next() != null ) {
8658 if ( !p.hasNext() ) {
8662 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8663 System.out.println( p2_0.toNewHampshire() );
8666 if ( !p.hasNext() ) {
8670 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8671 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8674 if ( !p.hasNext() ) {
8678 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8679 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8682 if ( !p.hasNext() ) {
8686 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8687 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8690 if ( !p.hasNext() ) {
8694 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8695 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8698 if ( p.hasNext() ) {
8701 if ( p.next() != null ) {
8705 final String p3_str = "((A,B),C)abc";
8706 p.setSource( p3_str );
8707 if ( !p.hasNext() ) {
8710 final Phylogeny p3_0 = p.next();
8711 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8714 if ( p.hasNext() ) {
8717 if ( p.next() != null ) {
8721 final String p4_str = "((A,B)ab,C)abc";
8722 p.setSource( p4_str );
8723 if ( !p.hasNext() ) {
8726 final Phylogeny p4_0 = p.next();
8727 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8730 if ( p.hasNext() ) {
8733 if ( p.next() != null ) {
8737 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8738 p.setSource( p5_str );
8739 if ( !p.hasNext() ) {
8742 final Phylogeny p5_0 = p.next();
8743 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8746 if ( p.hasNext() ) {
8749 if ( p.next() != null ) {
8753 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8754 p.setSource( p6_str );
8755 if ( !p.hasNext() ) {
8758 Phylogeny p6_0 = p.next();
8759 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8762 if ( p.hasNext() ) {
8765 if ( p.next() != null ) {
8769 if ( !p.hasNext() ) {
8773 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8776 if ( p.hasNext() ) {
8779 if ( p.next() != null ) {
8783 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8784 p.setSource( p7_str );
8785 if ( !p.hasNext() ) {
8788 Phylogeny p7_0 = p.next();
8789 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8792 if ( p.hasNext() ) {
8795 if ( p.next() != null ) {
8799 if ( !p.hasNext() ) {
8803 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8806 if ( p.hasNext() ) {
8809 if ( p.next() != null ) {
8813 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8814 p.setSource( p8_str );
8815 if ( !p.hasNext() ) {
8818 Phylogeny p8_0 = p.next();
8819 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8822 if ( !p.hasNext() ) {
8825 if ( !p.hasNext() ) {
8828 Phylogeny p8_1 = p.next();
8829 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8832 if ( p.hasNext() ) {
8835 if ( p.next() != null ) {
8839 if ( !p.hasNext() ) {
8843 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8846 if ( !p.hasNext() ) {
8850 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8853 if ( p.hasNext() ) {
8856 if ( p.next() != null ) {
8862 if ( p.hasNext() ) {
8866 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8867 if ( !p.hasNext() ) {
8870 Phylogeny p_27 = p.next();
8871 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8872 System.out.println( p_27.toNewHampshireX() );
8876 if ( p.hasNext() ) {
8879 if ( p.next() != null ) {
8883 if ( !p.hasNext() ) {
8887 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8888 System.out.println( p_27.toNewHampshireX() );
8892 if ( p.hasNext() ) {
8895 if ( p.next() != null ) {
8899 final String p30_str = "(A,B);(C,D)";
8900 final NHXParser p30 = new NHXParser();
8901 p30.setSource( p30_str );
8902 if ( !p30.hasNext() ) {
8905 Phylogeny phy30 = p30.next();
8906 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8907 System.out.println( phy30.toNewHampshire() );
8910 if ( !p30.hasNext() ) {
8913 Phylogeny phy301 = p30.next();
8914 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8915 System.out.println( phy301.toNewHampshire() );
8918 if ( p30.hasNext() ) {
8921 if ( p30.hasNext() ) {
8924 if ( p30.next() != null ) {
8927 if ( p30.next() != null ) {
8931 if ( !p30.hasNext() ) {
8935 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8936 System.out.println( phy30.toNewHampshire() );
8939 if ( !p30.hasNext() ) {
8942 phy301 = p30.next();
8943 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8944 System.out.println( phy301.toNewHampshire() );
8947 if ( p30.hasNext() ) {
8950 if ( p30.hasNext() ) {
8953 if ( p30.next() != null ) {
8956 if ( p30.next() != null ) {
8960 catch ( final Exception e ) {
8961 e.printStackTrace( System.out );
8967 private static boolean testNHXconversion() {
8969 final PhylogenyNode n1 = new PhylogenyNode();
8970 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8971 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8972 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8973 final PhylogenyNode n5 = PhylogenyNode
8974 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8975 final PhylogenyNode n6 = PhylogenyNode
8976 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8977 if ( !n1.toNewHampshireX().equals( "" ) ) {
8980 if ( !n2.toNewHampshireX().equals( "" ) ) {
8983 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8986 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8989 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8992 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8993 System.out.println( n6.toNewHampshireX() );
8996 final PhylogenyNode n7 = new PhylogenyNode();
8997 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
8998 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8999 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
9000 System.out.println( n7
9001 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
9005 catch ( final Exception e ) {
9006 e.printStackTrace( System.out );
9012 private static boolean testNHXNodeParsing() {
9014 final PhylogenyNode n1 = new PhylogenyNode();
9015 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9016 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9017 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9018 final PhylogenyNode n5 = PhylogenyNode
9019 .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]" );
9020 if ( !n3.getName().equals( "n3" ) ) {
9023 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9026 if ( n3.isDuplication() ) {
9029 if ( n3.isHasAssignedEvent() ) {
9032 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
9035 if ( !n4.getName().equals( "n4" ) ) {
9038 if ( n4.getDistanceToParent() != 0.01 ) {
9041 if ( !n5.getName().equals( "n5" ) ) {
9044 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
9047 if ( n5.getDistanceToParent() != 0.1 ) {
9050 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
9053 if ( !n5.isDuplication() ) {
9056 if ( !n5.isHasAssignedEvent() ) {
9059 final PhylogenyNode n8 = PhylogenyNode
9060 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
9061 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9062 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9065 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
9068 final PhylogenyNode n9 = PhylogenyNode
9069 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
9070 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9071 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
9074 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9077 final PhylogenyNode n10 = PhylogenyNode
9078 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9079 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9082 final PhylogenyNode n20 = PhylogenyNode
9083 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9084 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9087 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9090 final PhylogenyNode n20x = PhylogenyNode
9091 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9092 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9095 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9098 final PhylogenyNode n20xx = PhylogenyNode
9099 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9100 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9103 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9106 final PhylogenyNode n20xxx = PhylogenyNode
9107 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9108 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9111 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9114 final PhylogenyNode n20xxxx = PhylogenyNode
9115 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9116 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9119 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9122 final PhylogenyNode n21 = PhylogenyNode
9123 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9124 if ( !n21.getName().equals( "N21_PIG" ) ) {
9127 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9130 final PhylogenyNode n21x = PhylogenyNode
9131 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9132 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9135 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9138 final PhylogenyNode n22 = PhylogenyNode
9139 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9140 if ( !n22.getName().equals( "n22/PIG" ) ) {
9143 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9146 final PhylogenyNode n23 = PhylogenyNode
9147 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9148 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9151 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9154 final PhylogenyNode a = PhylogenyNode
9155 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9156 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9159 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9162 final PhylogenyNode c1 = PhylogenyNode
9163 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9164 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9165 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9168 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9171 final PhylogenyNode c2 = PhylogenyNode
9172 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9173 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9174 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9177 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9180 final PhylogenyNode e3 = PhylogenyNode
9181 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9182 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9185 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9188 final PhylogenyNode n11 = PhylogenyNode
9189 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9190 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9191 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9194 if ( n11.getDistanceToParent() != 0.4 ) {
9197 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9200 final PhylogenyNode n12 = PhylogenyNode
9201 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9202 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9203 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9206 if ( n12.getDistanceToParent() != 0.4 ) {
9209 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9212 final PhylogenyNode o = PhylogenyNode
9213 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9214 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9217 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9220 if ( n1.getName().compareTo( "" ) != 0 ) {
9223 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9226 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9229 if ( n2.getName().compareTo( "" ) != 0 ) {
9232 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9235 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9238 final PhylogenyNode n00 = PhylogenyNode
9239 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9240 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9243 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9246 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9247 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9250 final PhylogenyNode n13 = PhylogenyNode
9251 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9252 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9255 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9258 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9261 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9264 final PhylogenyNode n14 = PhylogenyNode
9265 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9266 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9269 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9272 final PhylogenyNode n15 = PhylogenyNode
9273 .createInstanceFromNhxString( "something_wicked[123]",
9274 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9275 if ( !n15.getName().equals( "something_wicked" ) ) {
9278 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9281 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9284 final PhylogenyNode n16 = PhylogenyNode
9285 .createInstanceFromNhxString( "something_wicked2[9]",
9286 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9287 if ( !n16.getName().equals( "something_wicked2" ) ) {
9290 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9293 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9296 final PhylogenyNode n17 = PhylogenyNode
9297 .createInstanceFromNhxString( "something_wicked3[a]",
9298 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9299 if ( !n17.getName().equals( "something_wicked3" ) ) {
9302 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9305 final PhylogenyNode n18 = PhylogenyNode
9306 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9307 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9310 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9313 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9316 final PhylogenyNode n19 = PhylogenyNode
9317 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9318 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9321 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9324 final PhylogenyNode n30 = PhylogenyNode
9325 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9326 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9327 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9330 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9333 final PhylogenyNode n31 = PhylogenyNode
9334 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9335 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9336 if ( n31.getNodeData().isHasTaxonomy() ) {
9339 final PhylogenyNode n32 = PhylogenyNode
9340 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9341 if ( n32.getNodeData().isHasTaxonomy() ) {
9344 final PhylogenyNode n40 = PhylogenyNode
9345 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9346 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9349 final PhylogenyNode n41 = PhylogenyNode
9350 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9351 if ( n41.getNodeData().isHasTaxonomy() ) {
9354 final PhylogenyNode n42 = PhylogenyNode
9355 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9356 if ( n42.getNodeData().isHasTaxonomy() ) {
9359 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9360 NHXParser.TAXONOMY_EXTRACTION.NO );
9361 if ( n43.getNodeData().isHasTaxonomy() ) {
9364 final PhylogenyNode n44 = PhylogenyNode
9365 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9366 if ( n44.getNodeData().isHasTaxonomy() ) {
9370 catch ( final Exception e ) {
9371 e.printStackTrace( System.out );
9377 private static boolean testNHXParsing() {
9379 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9380 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9381 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9384 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]";
9385 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9386 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9389 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]";
9390 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9391 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9394 final Phylogeny[] p3 = factory
9395 .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]",
9397 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9400 final Phylogeny[] p4 = factory
9401 .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(]",
9403 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9406 final Phylogeny[] p5 = factory
9407 .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(((]",
9409 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9412 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)";
9413 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)";
9414 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9415 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9418 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)))";
9419 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)))";
9420 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9421 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9424 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]) ))[,,, ])))))))";
9425 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9426 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9427 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9430 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9431 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9434 final Phylogeny p10 = factory
9435 .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]",
9436 new NHXParser() )[ 0 ];
9437 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9440 final Phylogeny p11 = factory
9441 .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]",
9442 new NHXParser() )[ 0 ];
9443 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9447 catch ( final Exception e ) {
9448 e.printStackTrace( System.out );
9454 private static boolean testNHXParsingMB() {
9456 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9457 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9458 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9459 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9460 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9461 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9462 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9463 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9464 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9465 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9466 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9469 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9472 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9473 0.1100000000000000e+00 ) ) {
9476 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9479 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9482 final Phylogeny p2 = factory
9483 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9484 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9485 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9486 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9487 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9488 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9489 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9490 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9491 + "7.369400000000000e-02}])",
9492 new NHXParser() )[ 0 ];
9493 if ( p2.getNode( "1" ) == null ) {
9496 if ( p2.getNode( "2" ) == null ) {
9500 catch ( final Exception e ) {
9501 e.printStackTrace( System.out );
9508 private static boolean testNHXParsingQuotes() {
9510 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9511 final NHXParser p = new NHXParser();
9512 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9513 if ( phylogenies_0.length != 5 ) {
9516 final Phylogeny phy = phylogenies_0[ 4 ];
9517 if ( phy.getNumberOfExternalNodes() != 7 ) {
9520 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9523 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9526 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9527 .getScientificName().equals( "hsapiens" ) ) {
9530 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9533 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9536 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9539 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9542 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9545 final NHXParser p1p = new NHXParser();
9546 p1p.setIgnoreQuotes( true );
9547 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9548 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9551 final NHXParser p2p = new NHXParser();
9552 p1p.setIgnoreQuotes( false );
9553 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9554 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9557 final NHXParser p3p = new NHXParser();
9558 p3p.setIgnoreQuotes( false );
9559 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9560 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9563 final NHXParser p4p = new NHXParser();
9564 p4p.setIgnoreQuotes( false );
9565 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9566 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9569 final Phylogeny p10 = factory
9570 .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]",
9571 new NHXParser() )[ 0 ];
9572 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]";
9573 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9576 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9577 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9580 final Phylogeny p12 = factory
9581 .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]",
9582 new NHXParser() )[ 0 ];
9583 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]";
9584 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9587 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9588 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9591 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;";
9592 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9595 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9596 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9600 catch ( final Exception e ) {
9601 e.printStackTrace( System.out );
9607 private static boolean testNodeRemoval() {
9609 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9610 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9611 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9612 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9615 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9616 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9617 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9620 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9621 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9622 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9626 catch ( final Exception e ) {
9627 e.printStackTrace( System.out );
9633 private static boolean testPhylogenyBranch() {
9635 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9636 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9637 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9638 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9639 if ( !a1b1.equals( a1b1 ) ) {
9642 if ( !a1b1.equals( b1a1 ) ) {
9645 if ( !b1a1.equals( a1b1 ) ) {
9648 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9649 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9650 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9651 if ( a1_b1.equals( b1_a1 ) ) {
9654 if ( a1_b1.equals( a1_b1_ ) ) {
9657 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9658 if ( !a1_b1.equals( b1_a1_ ) ) {
9661 if ( a1_b1_.equals( b1_a1_ ) ) {
9664 if ( !a1_b1_.equals( b1_a1 ) ) {
9668 catch ( final Exception e ) {
9669 e.printStackTrace( System.out );
9675 private static boolean testPhyloXMLparsingOfDistributionElement() {
9677 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9678 PhyloXmlParser xml_parser = null;
9680 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9682 catch ( final Exception e ) {
9683 // Do nothing -- means were not running from jar.
9685 if ( xml_parser == null ) {
9686 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9687 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9688 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9691 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9694 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9696 if ( xml_parser.getErrorCount() > 0 ) {
9697 System.out.println( xml_parser.getErrorMessages().toString() );
9700 if ( phylogenies_0.length != 1 ) {
9703 final Phylogeny t1 = phylogenies_0[ 0 ];
9704 PhylogenyNode n = null;
9705 Distribution d = null;
9706 n = t1.getNode( "root node" );
9707 if ( !n.getNodeData().isHasDistribution() ) {
9710 if ( n.getNodeData().getDistributions().size() != 1 ) {
9713 d = n.getNodeData().getDistribution();
9714 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9717 if ( d.getPoints().size() != 1 ) {
9720 if ( d.getPolygons() != null ) {
9723 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9726 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9729 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9732 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9735 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9738 n = t1.getNode( "node a" );
9739 if ( !n.getNodeData().isHasDistribution() ) {
9742 if ( n.getNodeData().getDistributions().size() != 2 ) {
9745 d = n.getNodeData().getDistribution( 1 );
9746 if ( !d.getDesc().equals( "San Diego" ) ) {
9749 if ( d.getPoints().size() != 1 ) {
9752 if ( d.getPolygons() != null ) {
9755 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9758 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9761 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9764 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9767 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9770 n = t1.getNode( "node bb" );
9771 if ( !n.getNodeData().isHasDistribution() ) {
9774 if ( n.getNodeData().getDistributions().size() != 1 ) {
9777 d = n.getNodeData().getDistribution( 0 );
9778 if ( d.getPoints().size() != 3 ) {
9781 if ( d.getPolygons().size() != 2 ) {
9784 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9787 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9790 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9793 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9796 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9799 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9802 Polygon p = d.getPolygons().get( 0 );
9803 if ( p.getPoints().size() != 3 ) {
9806 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9809 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9812 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9815 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9818 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9821 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9824 p = d.getPolygons().get( 1 );
9825 if ( p.getPoints().size() != 3 ) {
9828 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9831 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9834 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9838 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9839 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9840 if ( rt.length != 1 ) {
9843 final Phylogeny t1_rt = rt[ 0 ];
9844 n = t1_rt.getNode( "root node" );
9845 if ( !n.getNodeData().isHasDistribution() ) {
9848 if ( n.getNodeData().getDistributions().size() != 1 ) {
9851 d = n.getNodeData().getDistribution();
9852 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9855 if ( d.getPoints().size() != 1 ) {
9858 if ( d.getPolygons() != null ) {
9861 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9864 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9867 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9870 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9873 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9876 n = t1_rt.getNode( "node a" );
9877 if ( !n.getNodeData().isHasDistribution() ) {
9880 if ( n.getNodeData().getDistributions().size() != 2 ) {
9883 d = n.getNodeData().getDistribution( 1 );
9884 if ( !d.getDesc().equals( "San Diego" ) ) {
9887 if ( d.getPoints().size() != 1 ) {
9890 if ( d.getPolygons() != null ) {
9893 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9896 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9899 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9902 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9905 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9908 n = t1_rt.getNode( "node bb" );
9909 if ( !n.getNodeData().isHasDistribution() ) {
9912 if ( n.getNodeData().getDistributions().size() != 1 ) {
9915 d = n.getNodeData().getDistribution( 0 );
9916 if ( d.getPoints().size() != 3 ) {
9919 if ( d.getPolygons().size() != 2 ) {
9922 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9925 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9928 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9931 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9934 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9937 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9940 p = d.getPolygons().get( 0 );
9941 if ( p.getPoints().size() != 3 ) {
9944 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9947 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9950 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9953 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9956 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9959 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9962 p = d.getPolygons().get( 1 );
9963 if ( p.getPoints().size() != 3 ) {
9966 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9969 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9972 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9976 catch ( final Exception e ) {
9977 e.printStackTrace( System.out );
9983 private static boolean testPostOrderIterator() {
9985 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9986 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9987 PhylogenyNodeIterator it0;
9988 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9991 for( it0.reset(); it0.hasNext(); ) {
9994 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9995 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9996 if ( !it.next().getName().equals( "A" ) ) {
9999 if ( !it.next().getName().equals( "B" ) ) {
10002 if ( !it.next().getName().equals( "ab" ) ) {
10005 if ( !it.next().getName().equals( "C" ) ) {
10008 if ( !it.next().getName().equals( "D" ) ) {
10011 if ( !it.next().getName().equals( "cd" ) ) {
10014 if ( !it.next().getName().equals( "abcd" ) ) {
10017 if ( !it.next().getName().equals( "E" ) ) {
10020 if ( !it.next().getName().equals( "F" ) ) {
10023 if ( !it.next().getName().equals( "ef" ) ) {
10026 if ( !it.next().getName().equals( "G" ) ) {
10029 if ( !it.next().getName().equals( "H" ) ) {
10032 if ( !it.next().getName().equals( "gh" ) ) {
10035 if ( !it.next().getName().equals( "efgh" ) ) {
10038 if ( !it.next().getName().equals( "r" ) ) {
10041 if ( it.hasNext() ) {
10045 catch ( final Exception e ) {
10046 e.printStackTrace( System.out );
10052 private static boolean testPreOrderIterator() {
10054 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10055 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10056 PhylogenyNodeIterator it0;
10057 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
10060 for( it0.reset(); it0.hasNext(); ) {
10063 PhylogenyNodeIterator it = t0.iteratorPreorder();
10064 if ( !it.next().getName().equals( "r" ) ) {
10067 if ( !it.next().getName().equals( "ab" ) ) {
10070 if ( !it.next().getName().equals( "A" ) ) {
10073 if ( !it.next().getName().equals( "B" ) ) {
10076 if ( !it.next().getName().equals( "cd" ) ) {
10079 if ( !it.next().getName().equals( "C" ) ) {
10082 if ( !it.next().getName().equals( "D" ) ) {
10085 if ( it.hasNext() ) {
10088 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10089 it = t1.iteratorPreorder();
10090 if ( !it.next().getName().equals( "r" ) ) {
10093 if ( !it.next().getName().equals( "abcd" ) ) {
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.next().getName().equals( "efgh" ) ) {
10117 if ( !it.next().getName().equals( "ef" ) ) {
10120 if ( !it.next().getName().equals( "E" ) ) {
10123 if ( !it.next().getName().equals( "F" ) ) {
10126 if ( !it.next().getName().equals( "gh" ) ) {
10129 if ( !it.next().getName().equals( "G" ) ) {
10132 if ( !it.next().getName().equals( "H" ) ) {
10135 if ( it.hasNext() ) {
10139 catch ( final Exception e ) {
10140 e.printStackTrace( System.out );
10146 private static boolean testPropertiesMap() {
10148 final PropertiesMap pm = new PropertiesMap();
10149 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10150 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10151 final Property p2 = new Property( "something:else",
10153 "improbable:research",
10156 pm.addProperty( p0 );
10157 pm.addProperty( p1 );
10158 pm.addProperty( p2 );
10159 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
10162 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
10165 if ( pm.getProperties().size() != 3 ) {
10168 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10171 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10174 if ( pm.getProperties().size() != 3 ) {
10177 pm.removeProperty( "dimensions:diameter" );
10178 if ( pm.getProperties().size() != 2 ) {
10181 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
10184 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10188 catch ( final Exception e ) {
10189 e.printStackTrace( System.out );
10195 private static boolean testProteinId() {
10197 final ProteinId id1 = new ProteinId( "a" );
10198 final ProteinId id2 = new ProteinId( "a" );
10199 final ProteinId id3 = new ProteinId( "A" );
10200 final ProteinId id4 = new ProteinId( "b" );
10201 if ( !id1.equals( id1 ) ) {
10204 if ( id1.getId().equals( "x" ) ) {
10207 if ( id1.getId().equals( null ) ) {
10210 if ( !id1.equals( id2 ) ) {
10213 if ( id1.equals( id3 ) ) {
10216 if ( id1.hashCode() != id1.hashCode() ) {
10219 if ( id1.hashCode() != id2.hashCode() ) {
10222 if ( id1.hashCode() == id3.hashCode() ) {
10225 if ( id1.compareTo( id1 ) != 0 ) {
10228 if ( id1.compareTo( id2 ) != 0 ) {
10231 if ( id1.compareTo( id3 ) != 0 ) {
10234 if ( id1.compareTo( id4 ) >= 0 ) {
10237 if ( id4.compareTo( id1 ) <= 0 ) {
10240 if ( !id4.getId().equals( "b" ) ) {
10243 final ProteinId id5 = new ProteinId( " C " );
10244 if ( !id5.getId().equals( "C" ) ) {
10247 if ( id5.equals( id1 ) ) {
10251 catch ( final Exception e ) {
10252 e.printStackTrace( System.out );
10258 private static boolean testReIdMethods() {
10260 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10261 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10262 final long count = PhylogenyNode.getNodeCount();
10263 p.levelOrderReID();
10264 if ( p.getNode( "r" ).getId() != count ) {
10267 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10270 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10273 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10276 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10279 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10282 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10285 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10288 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10291 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10294 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10297 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10300 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10303 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10306 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10310 catch ( final Exception e ) {
10311 e.printStackTrace( System.out );
10317 private static boolean testRerooting() {
10319 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10320 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",
10321 new NHXParser() )[ 0 ];
10322 if ( !t1.isRooted() ) {
10325 t1.reRoot( t1.getNode( "D" ) );
10326 t1.reRoot( t1.getNode( "CD" ) );
10327 t1.reRoot( t1.getNode( "A" ) );
10328 t1.reRoot( t1.getNode( "B" ) );
10329 t1.reRoot( t1.getNode( "AB" ) );
10330 t1.reRoot( t1.getNode( "D" ) );
10331 t1.reRoot( t1.getNode( "C" ) );
10332 t1.reRoot( t1.getNode( "CD" ) );
10333 t1.reRoot( t1.getNode( "A" ) );
10334 t1.reRoot( t1.getNode( "B" ) );
10335 t1.reRoot( t1.getNode( "AB" ) );
10336 t1.reRoot( t1.getNode( "D" ) );
10337 t1.reRoot( t1.getNode( "D" ) );
10338 t1.reRoot( t1.getNode( "C" ) );
10339 t1.reRoot( t1.getNode( "A" ) );
10340 t1.reRoot( t1.getNode( "B" ) );
10341 t1.reRoot( t1.getNode( "AB" ) );
10342 t1.reRoot( t1.getNode( "C" ) );
10343 t1.reRoot( t1.getNode( "D" ) );
10344 t1.reRoot( t1.getNode( "CD" ) );
10345 t1.reRoot( t1.getNode( "D" ) );
10346 t1.reRoot( t1.getNode( "A" ) );
10347 t1.reRoot( t1.getNode( "B" ) );
10348 t1.reRoot( t1.getNode( "AB" ) );
10349 t1.reRoot( t1.getNode( "C" ) );
10350 t1.reRoot( t1.getNode( "D" ) );
10351 t1.reRoot( t1.getNode( "CD" ) );
10352 t1.reRoot( t1.getNode( "D" ) );
10353 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10356 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10359 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10362 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10365 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10368 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10371 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",
10372 new NHXParser() )[ 0 ];
10373 t2.reRoot( t2.getNode( "A" ) );
10374 t2.reRoot( t2.getNode( "D" ) );
10375 t2.reRoot( t2.getNode( "ABC" ) );
10376 t2.reRoot( t2.getNode( "A" ) );
10377 t2.reRoot( t2.getNode( "B" ) );
10378 t2.reRoot( t2.getNode( "D" ) );
10379 t2.reRoot( t2.getNode( "C" ) );
10380 t2.reRoot( t2.getNode( "ABC" ) );
10381 t2.reRoot( t2.getNode( "A" ) );
10382 t2.reRoot( t2.getNode( "B" ) );
10383 t2.reRoot( t2.getNode( "AB" ) );
10384 t2.reRoot( t2.getNode( "AB" ) );
10385 t2.reRoot( t2.getNode( "D" ) );
10386 t2.reRoot( t2.getNode( "C" ) );
10387 t2.reRoot( t2.getNode( "B" ) );
10388 t2.reRoot( t2.getNode( "AB" ) );
10389 t2.reRoot( t2.getNode( "D" ) );
10390 t2.reRoot( t2.getNode( "D" ) );
10391 t2.reRoot( t2.getNode( "ABC" ) );
10392 t2.reRoot( t2.getNode( "A" ) );
10393 t2.reRoot( t2.getNode( "B" ) );
10394 t2.reRoot( t2.getNode( "AB" ) );
10395 t2.reRoot( t2.getNode( "D" ) );
10396 t2.reRoot( t2.getNode( "C" ) );
10397 t2.reRoot( t2.getNode( "ABC" ) );
10398 t2.reRoot( t2.getNode( "A" ) );
10399 t2.reRoot( t2.getNode( "B" ) );
10400 t2.reRoot( t2.getNode( "AB" ) );
10401 t2.reRoot( t2.getNode( "D" ) );
10402 t2.reRoot( t2.getNode( "D" ) );
10403 t2.reRoot( t2.getNode( "C" ) );
10404 t2.reRoot( t2.getNode( "A" ) );
10405 t2.reRoot( t2.getNode( "B" ) );
10406 t2.reRoot( t2.getNode( "AB" ) );
10407 t2.reRoot( t2.getNode( "C" ) );
10408 t2.reRoot( t2.getNode( "D" ) );
10409 t2.reRoot( t2.getNode( "ABC" ) );
10410 t2.reRoot( t2.getNode( "D" ) );
10411 t2.reRoot( t2.getNode( "A" ) );
10412 t2.reRoot( t2.getNode( "B" ) );
10413 t2.reRoot( t2.getNode( "AB" ) );
10414 t2.reRoot( t2.getNode( "C" ) );
10415 t2.reRoot( t2.getNode( "D" ) );
10416 t2.reRoot( t2.getNode( "ABC" ) );
10417 t2.reRoot( t2.getNode( "D" ) );
10418 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10421 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10424 t2.reRoot( t2.getNode( "ABC" ) );
10425 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10428 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10431 t2.reRoot( t2.getNode( "AB" ) );
10432 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10435 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10438 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10441 t2.reRoot( t2.getNode( "AB" ) );
10442 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10445 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10448 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10451 t2.reRoot( t2.getNode( "D" ) );
10452 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10455 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10458 t2.reRoot( t2.getNode( "ABC" ) );
10459 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10462 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10465 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10466 new NHXParser() )[ 0 ];
10467 t3.reRoot( t3.getNode( "B" ) );
10468 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10471 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10474 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10477 t3.reRoot( t3.getNode( "B" ) );
10478 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10481 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10484 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10487 t3.reRoot( t3.getRoot() );
10488 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10491 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10494 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10498 catch ( final Exception e ) {
10499 e.printStackTrace( System.out );
10505 private static boolean testSDIse() {
10507 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10508 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10509 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10510 gene1.setRooted( true );
10511 species1.setRooted( true );
10512 final SDI sdi = new SDI( gene1, species1 );
10513 if ( !gene1.getRoot().isDuplication() ) {
10516 final Phylogeny species2 = factory
10517 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10518 new NHXParser() )[ 0 ];
10519 final Phylogeny gene2 = factory
10520 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10521 new NHXParser() )[ 0 ];
10522 species2.setRooted( true );
10523 gene2.setRooted( true );
10524 final SDI sdi2 = new SDI( gene2, species2 );
10525 if ( sdi2.getDuplicationsSum() != 0 ) {
10528 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10531 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10534 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10537 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10540 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10543 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10546 final Phylogeny species3 = factory
10547 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10548 new NHXParser() )[ 0 ];
10549 final Phylogeny gene3 = factory
10550 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10551 new NHXParser() )[ 0 ];
10552 species3.setRooted( true );
10553 gene3.setRooted( true );
10554 final SDI sdi3 = new SDI( gene3, species3 );
10555 if ( sdi3.getDuplicationsSum() != 1 ) {
10558 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10561 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10564 final Phylogeny species4 = factory
10565 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10566 new NHXParser() )[ 0 ];
10567 final Phylogeny gene4 = factory
10568 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10569 new NHXParser() )[ 0 ];
10570 species4.setRooted( true );
10571 gene4.setRooted( true );
10572 final SDI sdi4 = new SDI( gene4, species4 );
10573 if ( sdi4.getDuplicationsSum() != 1 ) {
10576 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10579 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10582 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10585 if ( species4.getNumberOfExternalNodes() != 6 ) {
10588 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10591 final Phylogeny species5 = factory
10592 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10593 new NHXParser() )[ 0 ];
10594 final Phylogeny gene5 = factory
10595 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10596 new NHXParser() )[ 0 ];
10597 species5.setRooted( true );
10598 gene5.setRooted( true );
10599 final SDI sdi5 = new SDI( gene5, species5 );
10600 if ( sdi5.getDuplicationsSum() != 2 ) {
10603 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10606 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10609 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10612 if ( species5.getNumberOfExternalNodes() != 6 ) {
10615 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10618 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10619 // Conjecture for Comparing Molecular Phylogenies"
10620 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10621 final Phylogeny species6 = factory
10622 .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,"
10623 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10624 new NHXParser() )[ 0 ];
10625 final Phylogeny gene6 = factory
10626 .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,"
10627 + "((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,"
10628 + "(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;",
10629 new NHXParser() )[ 0 ];
10630 species6.setRooted( true );
10631 gene6.setRooted( true );
10632 final SDI sdi6 = new SDI( gene6, species6 );
10633 if ( sdi6.getDuplicationsSum() != 3 ) {
10636 if ( !gene6.getNode( "r" ).isDuplication() ) {
10639 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10642 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10645 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10648 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10651 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10654 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10657 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10660 sdi6.computeMappingCostL();
10661 if ( sdi6.computeMappingCostL() != 17 ) {
10664 if ( species6.getNumberOfExternalNodes() != 9 ) {
10667 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10670 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10671 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10672 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10673 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10674 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10675 species7.setRooted( true );
10676 final Phylogeny gene7_1 = Test
10677 .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])" );
10678 gene7_1.setRooted( true );
10679 final SDI sdi7 = new SDI( gene7_1, species7 );
10680 if ( sdi7.getDuplicationsSum() != 0 ) {
10683 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10686 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10689 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10692 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10695 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10698 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10701 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10704 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10707 final Phylogeny gene7_2 = Test
10708 .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])" );
10709 gene7_2.setRooted( true );
10710 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10711 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10714 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10717 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10720 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10723 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10726 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10729 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10732 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10735 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10738 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10742 catch ( final Exception e ) {
10748 private static boolean testSDIunrooted() {
10750 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10751 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10752 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10753 final Iterator<PhylogenyBranch> iter = l.iterator();
10754 PhylogenyBranch br = iter.next();
10755 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10758 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10762 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10765 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10769 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10772 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10776 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10779 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10783 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10786 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10790 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10793 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10797 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10800 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10804 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10807 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10811 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10814 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10818 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10821 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10825 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10828 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10832 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10835 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10839 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10842 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10846 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10849 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10853 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10856 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10859 if ( iter.hasNext() ) {
10862 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10863 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10864 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10866 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10869 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10873 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10876 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10880 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10883 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10886 if ( iter1.hasNext() ) {
10889 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10890 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10891 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10893 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10896 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10900 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10903 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10907 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10910 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10913 if ( iter2.hasNext() ) {
10916 final Phylogeny species0 = factory
10917 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10918 new NHXParser() )[ 0 ];
10919 final Phylogeny gene1 = factory
10920 .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])",
10921 new NHXParser() )[ 0 ];
10922 species0.setRooted( true );
10923 gene1.setRooted( true );
10924 final SDIR sdi_unrooted = new SDIR();
10925 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10926 if ( sdi_unrooted.getCount() != 1 ) {
10929 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10932 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10935 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10938 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10941 final Phylogeny gene2 = factory
10942 .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])",
10943 new NHXParser() )[ 0 ];
10944 gene2.setRooted( true );
10945 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10946 if ( sdi_unrooted.getCount() != 1 ) {
10949 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10952 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10955 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10958 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10961 final Phylogeny species6 = factory
10962 .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,"
10963 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10964 new NHXParser() )[ 0 ];
10965 final Phylogeny gene6 = factory
10966 .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],"
10967 + "(((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],"
10968 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10969 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10970 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10971 new NHXParser() )[ 0 ];
10972 species6.setRooted( true );
10973 gene6.setRooted( true );
10974 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10975 if ( sdi_unrooted.getCount() != 1 ) {
10978 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10981 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10984 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10987 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10990 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10993 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10996 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10999 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
11002 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11005 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
11008 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
11011 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11015 final Phylogeny species7 = factory
11016 .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,"
11017 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11018 new NHXParser() )[ 0 ];
11019 final Phylogeny gene7 = factory
11020 .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],"
11021 + "(((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],"
11022 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11023 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11024 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11025 new NHXParser() )[ 0 ];
11026 species7.setRooted( true );
11027 gene7.setRooted( true );
11028 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
11029 if ( sdi_unrooted.getCount() != 1 ) {
11032 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11035 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11038 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11041 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
11044 if ( !p7[ 0 ].getRoot().isDuplication() ) {
11047 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11050 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11053 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
11056 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11059 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
11062 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
11065 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11069 final Phylogeny species8 = factory
11070 .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,"
11071 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11072 new NHXParser() )[ 0 ];
11073 final Phylogeny gene8 = factory
11074 .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],"
11075 + "(((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],"
11076 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11077 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11078 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11079 new NHXParser() )[ 0 ];
11080 species8.setRooted( true );
11081 gene8.setRooted( true );
11082 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
11083 if ( sdi_unrooted.getCount() != 1 ) {
11086 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11089 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11092 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11095 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11098 if ( !p8[ 0 ].getRoot().isDuplication() ) {
11101 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11104 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11107 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
11110 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11113 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
11116 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
11119 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11124 catch ( final Exception e ) {
11125 e.printStackTrace( System.out );
11131 private static boolean testSequenceDbWsTools1() {
11133 final PhylogenyNode n = new PhylogenyNode();
11134 n.setName( "NP_001025424" );
11135 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11136 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11137 || !acc.getValue().equals( "NP_001025424" ) ) {
11140 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11141 acc = SequenceDbWsTools.obtainSeqAccession( n );
11142 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11143 || !acc.getValue().equals( "NP_001025424" ) ) {
11146 n.setName( "NP_001025424.1" );
11147 acc = SequenceDbWsTools.obtainSeqAccession( n );
11148 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11149 || !acc.getValue().equals( "NP_001025424" ) ) {
11152 n.setName( "NM_001030253" );
11153 acc = SequenceDbWsTools.obtainSeqAccession( n );
11154 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11155 || !acc.getValue().equals( "NM_001030253" ) ) {
11158 n.setName( "BCL2_HUMAN" );
11159 acc = SequenceDbWsTools.obtainSeqAccession( n );
11160 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11161 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11162 System.out.println( acc.toString() );
11165 n.setName( "P10415" );
11166 acc = SequenceDbWsTools.obtainSeqAccession( n );
11167 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11168 || !acc.getValue().equals( "P10415" ) ) {
11169 System.out.println( acc.toString() );
11172 n.setName( " P10415 " );
11173 acc = SequenceDbWsTools.obtainSeqAccession( n );
11174 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11175 || !acc.getValue().equals( "P10415" ) ) {
11176 System.out.println( acc.toString() );
11179 n.setName( "_P10415|" );
11180 acc = SequenceDbWsTools.obtainSeqAccession( n );
11181 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11182 || !acc.getValue().equals( "P10415" ) ) {
11183 System.out.println( acc.toString() );
11186 n.setName( "AY695820" );
11187 acc = SequenceDbWsTools.obtainSeqAccession( n );
11188 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11189 || !acc.getValue().equals( "AY695820" ) ) {
11190 System.out.println( acc.toString() );
11193 n.setName( "_AY695820_" );
11194 acc = SequenceDbWsTools.obtainSeqAccession( n );
11195 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11196 || !acc.getValue().equals( "AY695820" ) ) {
11197 System.out.println( acc.toString() );
11200 n.setName( "AAA59452" );
11201 acc = SequenceDbWsTools.obtainSeqAccession( n );
11202 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11203 || !acc.getValue().equals( "AAA59452" ) ) {
11204 System.out.println( acc.toString() );
11207 n.setName( "_AAA59452_" );
11208 acc = SequenceDbWsTools.obtainSeqAccession( n );
11209 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11210 || !acc.getValue().equals( "AAA59452" ) ) {
11211 System.out.println( acc.toString() );
11214 n.setName( "AAA59452.1" );
11215 acc = SequenceDbWsTools.obtainSeqAccession( n );
11216 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11217 || !acc.getValue().equals( "AAA59452.1" ) ) {
11218 System.out.println( acc.toString() );
11221 n.setName( "_AAA59452.1_" );
11222 acc = SequenceDbWsTools.obtainSeqAccession( n );
11223 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11224 || !acc.getValue().equals( "AAA59452.1" ) ) {
11225 System.out.println( acc.toString() );
11228 n.setName( "GI:94894583" );
11229 acc = SequenceDbWsTools.obtainSeqAccession( n );
11230 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11231 || !acc.getValue().equals( "94894583" ) ) {
11232 System.out.println( acc.toString() );
11235 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11236 acc = SequenceDbWsTools.obtainSeqAccession( n );
11237 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11238 || !acc.getValue().equals( "71845847" ) ) {
11239 System.out.println( acc.toString() );
11242 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11243 acc = SequenceDbWsTools.obtainSeqAccession( n );
11244 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11245 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11246 System.out.println( acc.toString() );
11250 catch ( final Exception e ) {
11256 private static boolean testSequenceDbWsTools2() {
11258 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11259 SequenceDbWsTools.obtainSeqInformation( n1 );
11260 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11263 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11266 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11269 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11272 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11273 SequenceDbWsTools.obtainSeqInformation( n2 );
11274 if ( !n2.getNodeData().getSequence().getName()
11275 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
11278 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11281 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11284 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11287 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11288 SequenceDbWsTools.obtainSeqInformation( n3 );
11289 if ( !n3.getNodeData().getSequence().getName()
11290 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11293 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11296 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11299 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11303 catch ( final IOException e ) {
11304 System.out.println();
11305 System.out.println( "the following might be due to absence internet connection:" );
11306 e.printStackTrace( System.out );
11309 catch ( final Exception e ) {
11310 e.printStackTrace();
11316 private static boolean testSequenceIdParsing() {
11318 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11319 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11320 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11321 if ( id != null ) {
11322 System.out.println( "value =" + id.getValue() );
11323 System.out.println( "provider=" + id.getSource() );
11327 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11328 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11329 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11330 if ( id != null ) {
11331 System.out.println( "value =" + id.getValue() );
11332 System.out.println( "provider=" + id.getSource() );
11336 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11337 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11338 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11339 if ( id != null ) {
11340 System.out.println( "value =" + id.getValue() );
11341 System.out.println( "provider=" + id.getSource() );
11345 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11346 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11347 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11348 if ( id != null ) {
11349 System.out.println( "value =" + id.getValue() );
11350 System.out.println( "provider=" + id.getSource() );
11354 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11355 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11356 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11357 if ( id != null ) {
11358 System.out.println( "value =" + id.getValue() );
11359 System.out.println( "provider=" + id.getSource() );
11363 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11364 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11365 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11366 if ( id != null ) {
11367 System.out.println( "value =" + id.getValue() );
11368 System.out.println( "provider=" + id.getSource() );
11372 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11373 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11374 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11375 if ( id != null ) {
11376 System.out.println( "value =" + id.getValue() );
11377 System.out.println( "provider=" + id.getSource() );
11381 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11382 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11383 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11384 if ( id != null ) {
11385 System.out.println( "value =" + id.getValue() );
11386 System.out.println( "provider=" + id.getSource() );
11390 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11391 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11392 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11393 if ( id != null ) {
11394 System.out.println( "value =" + id.getValue() );
11395 System.out.println( "provider=" + id.getSource() );
11399 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11400 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11401 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11402 if ( id != null ) {
11403 System.out.println( "value =" + id.getValue() );
11404 System.out.println( "provider=" + id.getSource() );
11408 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11409 if ( id != null ) {
11410 System.out.println( "value =" + id.getValue() );
11411 System.out.println( "provider=" + id.getSource() );
11415 id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" );
11416 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11417 || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) {
11418 if ( id != null ) {
11419 System.out.println( "value =" + id.getValue() );
11420 System.out.println( "provider=" + id.getSource() );
11424 id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" );
11425 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11426 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
11427 if ( id != null ) {
11428 System.out.println( "value =" + id.getValue() );
11429 System.out.println( "provider=" + id.getSource() );
11433 id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" );
11434 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11435 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
11436 if ( id != null ) {
11437 System.out.println( "value =" + id.getValue() );
11438 System.out.println( "provider=" + id.getSource() );
11442 id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" );
11443 if ( id != null ) {
11444 System.out.println( "value =" + id.getValue() );
11445 System.out.println( "provider=" + id.getSource() );
11449 catch ( final Exception e ) {
11450 e.printStackTrace( System.out );
11456 private static boolean testSequenceWriter() {
11458 final String n = ForesterUtil.LINE_SEPARATOR;
11459 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11462 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11465 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11468 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11471 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11472 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11475 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11476 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11480 catch ( final Exception e ) {
11481 e.printStackTrace();
11487 private static boolean testSpecies() {
11489 final Species s1 = new BasicSpecies( "a" );
11490 final Species s2 = new BasicSpecies( "a" );
11491 final Species s3 = new BasicSpecies( "A" );
11492 final Species s4 = new BasicSpecies( "b" );
11493 if ( !s1.equals( s1 ) ) {
11496 if ( s1.getSpeciesId().equals( "x" ) ) {
11499 if ( s1.getSpeciesId().equals( null ) ) {
11502 if ( !s1.equals( s2 ) ) {
11505 if ( s1.equals( s3 ) ) {
11508 if ( s1.hashCode() != s1.hashCode() ) {
11511 if ( s1.hashCode() != s2.hashCode() ) {
11514 if ( s1.hashCode() == s3.hashCode() ) {
11517 if ( s1.compareTo( s1 ) != 0 ) {
11520 if ( s1.compareTo( s2 ) != 0 ) {
11523 if ( s1.compareTo( s3 ) != 0 ) {
11526 if ( s1.compareTo( s4 ) >= 0 ) {
11529 if ( s4.compareTo( s1 ) <= 0 ) {
11532 if ( !s4.getSpeciesId().equals( "b" ) ) {
11535 final Species s5 = new BasicSpecies( " C " );
11536 if ( !s5.getSpeciesId().equals( "C" ) ) {
11539 if ( s5.equals( s1 ) ) {
11543 catch ( final Exception e ) {
11544 e.printStackTrace( System.out );
11550 private static boolean testSplit() {
11552 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11553 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11554 //Archaeopteryx.createApplication( p0 );
11555 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11556 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11557 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11558 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11559 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11560 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11561 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11562 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11563 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11564 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11565 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11566 // System.out.println( s0.toString() );
11568 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11569 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11570 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11571 if ( s0.match( query_nodes ) ) {
11574 query_nodes = new HashSet<PhylogenyNode>();
11575 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11576 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11577 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11578 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11579 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11580 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11581 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11582 if ( !s0.match( query_nodes ) ) {
11586 query_nodes = new HashSet<PhylogenyNode>();
11587 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11588 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11589 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11590 if ( !s0.match( query_nodes ) ) {
11594 query_nodes = new HashSet<PhylogenyNode>();
11595 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11596 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11597 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11598 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11599 if ( !s0.match( query_nodes ) ) {
11603 query_nodes = new HashSet<PhylogenyNode>();
11604 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11605 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11606 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11607 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11608 if ( !s0.match( query_nodes ) ) {
11612 query_nodes = new HashSet<PhylogenyNode>();
11613 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11614 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11615 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11616 if ( !s0.match( query_nodes ) ) {
11620 query_nodes = new HashSet<PhylogenyNode>();
11621 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11622 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11623 if ( !s0.match( query_nodes ) ) {
11627 query_nodes = new HashSet<PhylogenyNode>();
11628 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11629 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11630 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11632 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11633 if ( !s0.match( query_nodes ) ) {
11637 query_nodes = new HashSet<PhylogenyNode>();
11638 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11639 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11640 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11641 if ( !s0.match( query_nodes ) ) {
11645 query_nodes = new HashSet<PhylogenyNode>();
11646 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11647 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11648 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11649 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11650 if ( !s0.match( query_nodes ) ) {
11654 query_nodes = new HashSet<PhylogenyNode>();
11655 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11656 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11657 if ( s0.match( query_nodes ) ) {
11661 query_nodes = new HashSet<PhylogenyNode>();
11662 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11663 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11664 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11665 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11666 if ( s0.match( query_nodes ) ) {
11670 query_nodes = new HashSet<PhylogenyNode>();
11671 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11672 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11673 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11674 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11675 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11676 if ( s0.match( query_nodes ) ) {
11680 query_nodes = new HashSet<PhylogenyNode>();
11681 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11682 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11683 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11684 if ( s0.match( query_nodes ) ) {
11688 query_nodes = new HashSet<PhylogenyNode>();
11689 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11690 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11691 if ( s0.match( query_nodes ) ) {
11695 query_nodes = new HashSet<PhylogenyNode>();
11696 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11697 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11698 if ( s0.match( query_nodes ) ) {
11702 query_nodes = new HashSet<PhylogenyNode>();
11703 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11704 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11705 if ( s0.match( query_nodes ) ) {
11709 query_nodes = new HashSet<PhylogenyNode>();
11710 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11711 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11712 if ( s0.match( query_nodes ) ) {
11716 query_nodes = new HashSet<PhylogenyNode>();
11717 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11718 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11719 if ( s0.match( query_nodes ) ) {
11723 query_nodes = new HashSet<PhylogenyNode>();
11724 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11725 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11726 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 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11734 if ( s0.match( query_nodes ) ) {
11738 query_nodes = new HashSet<PhylogenyNode>();
11739 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11740 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11741 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11742 if ( s0.match( query_nodes ) ) {
11746 query_nodes = new HashSet<PhylogenyNode>();
11747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11748 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11749 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11750 if ( s0.match( query_nodes ) ) {
11754 query_nodes = new HashSet<PhylogenyNode>();
11755 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11756 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11757 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11758 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11759 if ( s0.match( query_nodes ) ) {
11763 // query_nodes = new HashSet<PhylogenyNode>();
11764 // query_nodes.add( new PhylogenyNode( "X" ) );
11765 // query_nodes.add( new PhylogenyNode( "Y" ) );
11766 // query_nodes.add( new PhylogenyNode( "A" ) );
11767 // query_nodes.add( new PhylogenyNode( "B" ) );
11768 // query_nodes.add( new PhylogenyNode( "C" ) );
11769 // query_nodes.add( new PhylogenyNode( "D" ) );
11770 // query_nodes.add( new PhylogenyNode( "E" ) );
11771 // query_nodes.add( new PhylogenyNode( "F" ) );
11772 // query_nodes.add( new PhylogenyNode( "G" ) );
11773 // if ( !s0.match( query_nodes ) ) {
11776 // query_nodes = new HashSet<PhylogenyNode>();
11777 // query_nodes.add( new PhylogenyNode( "X" ) );
11778 // query_nodes.add( new PhylogenyNode( "Y" ) );
11779 // query_nodes.add( new PhylogenyNode( "A" ) );
11780 // query_nodes.add( new PhylogenyNode( "B" ) );
11781 // query_nodes.add( new PhylogenyNode( "C" ) );
11782 // if ( !s0.match( query_nodes ) ) {
11786 // query_nodes = new HashSet<PhylogenyNode>();
11787 // query_nodes.add( new PhylogenyNode( "X" ) );
11788 // query_nodes.add( new PhylogenyNode( "Y" ) );
11789 // query_nodes.add( new PhylogenyNode( "D" ) );
11790 // query_nodes.add( new PhylogenyNode( "E" ) );
11791 // query_nodes.add( new PhylogenyNode( "F" ) );
11792 // query_nodes.add( new PhylogenyNode( "G" ) );
11793 // if ( !s0.match( query_nodes ) ) {
11797 // query_nodes = new HashSet<PhylogenyNode>();
11798 // query_nodes.add( new PhylogenyNode( "X" ) );
11799 // query_nodes.add( new PhylogenyNode( "Y" ) );
11800 // query_nodes.add( new PhylogenyNode( "A" ) );
11801 // query_nodes.add( new PhylogenyNode( "B" ) );
11802 // query_nodes.add( new PhylogenyNode( "C" ) );
11803 // query_nodes.add( new PhylogenyNode( "D" ) );
11804 // if ( !s0.match( query_nodes ) ) {
11808 // query_nodes = new HashSet<PhylogenyNode>();
11809 // query_nodes.add( new PhylogenyNode( "X" ) );
11810 // query_nodes.add( new PhylogenyNode( "Y" ) );
11811 // query_nodes.add( new PhylogenyNode( "E" ) );
11812 // query_nodes.add( new PhylogenyNode( "F" ) );
11813 // query_nodes.add( new PhylogenyNode( "G" ) );
11814 // if ( !s0.match( query_nodes ) ) {
11818 // query_nodes = new HashSet<PhylogenyNode>();
11819 // query_nodes.add( new PhylogenyNode( "X" ) );
11820 // query_nodes.add( new PhylogenyNode( "Y" ) );
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( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11829 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11830 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11831 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "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( "A" ) );
11840 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11841 if ( s0.match( query_nodes ) ) {
11844 ///////////////////////////
11846 query_nodes = new HashSet<PhylogenyNode>();
11847 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11848 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11849 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11850 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11851 if ( s0.match( query_nodes ) ) {
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( "B" ) );
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( "C" ) );
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( "E" ) );
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( "F" ) );
11887 if ( s0.match( query_nodes ) ) {
11891 query_nodes = new HashSet<PhylogenyNode>();
11892 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11893 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11894 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11895 if ( s0.match( query_nodes ) ) {
11899 query_nodes = new HashSet<PhylogenyNode>();
11900 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11901 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11902 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11903 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11904 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11905 if ( s0.match( query_nodes ) ) {
11909 query_nodes = new HashSet<PhylogenyNode>();
11910 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11911 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11912 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11913 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11914 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11915 if ( s0.match( query_nodes ) ) {
11919 query_nodes = new HashSet<PhylogenyNode>();
11920 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11921 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11922 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11923 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11924 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11925 if ( s0.match( query_nodes ) ) {
11929 query_nodes = new HashSet<PhylogenyNode>();
11930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11931 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11932 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11933 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11934 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11935 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11936 if ( s0.match( query_nodes ) ) {
11940 catch ( final Exception e ) {
11941 e.printStackTrace();
11947 private static boolean testSplitStrict() {
11949 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11950 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11951 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11952 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11953 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11954 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11955 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11956 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11957 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11958 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11959 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11960 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11961 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11962 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11963 if ( s0.match( query_nodes ) ) {
11966 query_nodes = new HashSet<PhylogenyNode>();
11967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11968 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11969 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11970 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11971 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11972 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11973 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11974 if ( !s0.match( query_nodes ) ) {
11978 query_nodes = new HashSet<PhylogenyNode>();
11979 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11980 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11981 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11982 if ( !s0.match( query_nodes ) ) {
11986 query_nodes = new HashSet<PhylogenyNode>();
11987 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11988 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11989 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11990 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11991 if ( !s0.match( query_nodes ) ) {
11995 query_nodes = new HashSet<PhylogenyNode>();
11996 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11997 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11998 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11999 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12000 if ( !s0.match( query_nodes ) ) {
12004 query_nodes = new HashSet<PhylogenyNode>();
12005 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12006 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12007 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12008 if ( !s0.match( query_nodes ) ) {
12012 query_nodes = new HashSet<PhylogenyNode>();
12013 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12014 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12015 if ( !s0.match( query_nodes ) ) {
12019 query_nodes = new HashSet<PhylogenyNode>();
12020 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12021 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12022 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12023 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12024 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12025 if ( !s0.match( query_nodes ) ) {
12029 query_nodes = new HashSet<PhylogenyNode>();
12030 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12031 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12032 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12033 if ( !s0.match( query_nodes ) ) {
12037 query_nodes = new HashSet<PhylogenyNode>();
12038 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12039 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12040 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12041 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
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( "A" ) );
12049 if ( s0.match( query_nodes ) ) {
12053 query_nodes = new HashSet<PhylogenyNode>();
12054 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12055 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12056 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12057 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12058 if ( s0.match( query_nodes ) ) {
12062 query_nodes = new HashSet<PhylogenyNode>();
12063 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12064 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12065 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12066 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12067 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12068 if ( s0.match( query_nodes ) ) {
12072 query_nodes = new HashSet<PhylogenyNode>();
12073 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12074 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12075 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12076 if ( s0.match( query_nodes ) ) {
12080 query_nodes = new HashSet<PhylogenyNode>();
12081 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12082 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12083 if ( s0.match( query_nodes ) ) {
12087 query_nodes = new HashSet<PhylogenyNode>();
12088 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12089 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12090 if ( s0.match( query_nodes ) ) {
12094 query_nodes = new HashSet<PhylogenyNode>();
12095 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12096 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12097 if ( s0.match( query_nodes ) ) {
12101 query_nodes = new HashSet<PhylogenyNode>();
12102 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12103 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12104 if ( s0.match( query_nodes ) ) {
12108 query_nodes = new HashSet<PhylogenyNode>();
12109 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12110 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12111 if ( s0.match( query_nodes ) ) {
12115 query_nodes = new HashSet<PhylogenyNode>();
12116 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12117 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12118 if ( s0.match( query_nodes ) ) {
12122 query_nodes = new HashSet<PhylogenyNode>();
12123 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12124 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12125 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12126 if ( s0.match( query_nodes ) ) {
12130 query_nodes = new HashSet<PhylogenyNode>();
12131 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12132 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12133 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12134 if ( s0.match( query_nodes ) ) {
12138 query_nodes = new HashSet<PhylogenyNode>();
12139 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12140 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12141 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12142 if ( s0.match( query_nodes ) ) {
12146 query_nodes = new HashSet<PhylogenyNode>();
12147 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12148 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12149 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12150 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12151 if ( s0.match( query_nodes ) ) {
12155 catch ( final Exception e ) {
12156 e.printStackTrace();
12162 private static boolean testSubtreeDeletion() {
12164 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12165 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12166 t1.deleteSubtree( t1.getNode( "A" ), false );
12167 if ( t1.getNumberOfExternalNodes() != 5 ) {
12170 t1.toNewHampshireX();
12171 t1.deleteSubtree( t1.getNode( "E" ), false );
12172 if ( t1.getNumberOfExternalNodes() != 4 ) {
12175 t1.toNewHampshireX();
12176 t1.deleteSubtree( t1.getNode( "F" ), false );
12177 if ( t1.getNumberOfExternalNodes() != 3 ) {
12180 t1.toNewHampshireX();
12181 t1.deleteSubtree( t1.getNode( "D" ), false );
12182 t1.toNewHampshireX();
12183 if ( t1.getNumberOfExternalNodes() != 3 ) {
12186 t1.deleteSubtree( t1.getNode( "def" ), false );
12187 t1.toNewHampshireX();
12188 if ( t1.getNumberOfExternalNodes() != 2 ) {
12191 t1.deleteSubtree( t1.getNode( "B" ), false );
12192 t1.toNewHampshireX();
12193 if ( t1.getNumberOfExternalNodes() != 1 ) {
12196 t1.deleteSubtree( t1.getNode( "C" ), false );
12197 t1.toNewHampshireX();
12198 if ( t1.getNumberOfExternalNodes() != 1 ) {
12201 t1.deleteSubtree( t1.getNode( "abc" ), false );
12202 t1.toNewHampshireX();
12203 if ( t1.getNumberOfExternalNodes() != 1 ) {
12206 t1.deleteSubtree( t1.getNode( "r" ), false );
12207 if ( t1.getNumberOfExternalNodes() != 0 ) {
12210 if ( !t1.isEmpty() ) {
12213 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12214 t2.deleteSubtree( t2.getNode( "A" ), false );
12215 t2.toNewHampshireX();
12216 if ( t2.getNumberOfExternalNodes() != 5 ) {
12219 t2.deleteSubtree( t2.getNode( "abc" ), false );
12220 t2.toNewHampshireX();
12221 if ( t2.getNumberOfExternalNodes() != 3 ) {
12224 t2.deleteSubtree( t2.getNode( "def" ), false );
12225 t2.toNewHampshireX();
12226 if ( t2.getNumberOfExternalNodes() != 1 ) {
12230 catch ( final Exception e ) {
12231 e.printStackTrace( System.out );
12237 private static boolean testSupportCount() {
12239 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12240 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
12241 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
12242 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
12243 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
12244 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
12245 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12247 SupportCount.count( t0_1, phylogenies_1, true, false );
12248 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12249 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12250 + "(((((A,B),C),D),E),((F,G),X))"
12251 + "(((((A,Y),B),C),D),((F,G),E))"
12252 + "(((((A,B),C),D),E),(F,G))"
12253 + "(((((A,B),C),D),E),(F,G))"
12254 + "(((((A,B),C),D),E),(F,G))"
12255 + "(((((A,B),C),D),E),(F,G),Z)"
12256 + "(((((A,B),C),D),E),(F,G))"
12257 + "((((((A,B),C),D),E),F),G)"
12258 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12260 SupportCount.count( t0_2, phylogenies_2, true, false );
12261 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12262 while ( it.hasNext() ) {
12263 final PhylogenyNode n = it.next();
12264 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12268 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12269 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12270 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12271 SupportCount.count( t0_3, phylogenies_3, true, false );
12272 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12273 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12276 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12279 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12282 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12285 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12288 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12291 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12294 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12297 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12300 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12303 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12304 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12305 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12306 SupportCount.count( t0_4, phylogenies_4, true, false );
12307 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12308 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12311 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12314 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12317 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12320 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12323 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12326 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12329 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12332 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12335 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12338 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12339 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12340 double d = SupportCount.compare( b1, a, true, true, true );
12341 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12344 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12345 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12346 d = SupportCount.compare( b2, a, true, true, true );
12347 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12350 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12351 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12352 d = SupportCount.compare( b3, a, true, true, true );
12353 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12356 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12357 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12358 d = SupportCount.compare( b4, a, true, true, false );
12359 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12363 catch ( final Exception e ) {
12364 e.printStackTrace( System.out );
12370 private static boolean testSupportTransfer() {
12372 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12373 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)",
12374 new NHXParser() )[ 0 ];
12375 final Phylogeny p2 = factory
12376 .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 ];
12377 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12380 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12383 support_transfer.moveBranchLengthsToBootstrap( p1 );
12384 support_transfer.transferSupportValues( p1, p2 );
12385 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12388 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12391 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12394 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12397 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12400 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12403 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12406 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12410 catch ( final Exception e ) {
12411 e.printStackTrace( System.out );
12417 private static boolean testTaxonomyExtraction() {
12419 final PhylogenyNode n0 = PhylogenyNode
12420 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12421 if ( n0.getNodeData().isHasTaxonomy() ) {
12424 final PhylogenyNode n1 = PhylogenyNode
12425 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12426 if ( n1.getNodeData().isHasTaxonomy() ) {
12427 System.out.println( n1.toString() );
12430 final PhylogenyNode n2x = PhylogenyNode
12431 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12432 if ( n2x.getNodeData().isHasTaxonomy() ) {
12435 final PhylogenyNode n3 = PhylogenyNode
12436 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12437 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12438 System.out.println( n3.toString() );
12441 final PhylogenyNode n4 = PhylogenyNode
12442 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12443 if ( n4.getNodeData().isHasTaxonomy() ) {
12444 System.out.println( n4.toString() );
12447 final PhylogenyNode n5 = PhylogenyNode
12448 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12449 if ( n5.getNodeData().isHasTaxonomy() ) {
12450 System.out.println( n5.toString() );
12453 final PhylogenyNode n6 = PhylogenyNode
12454 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12455 if ( n6.getNodeData().isHasTaxonomy() ) {
12456 System.out.println( n6.toString() );
12459 final PhylogenyNode n7 = PhylogenyNode
12460 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12461 if ( n7.getNodeData().isHasTaxonomy() ) {
12462 System.out.println( n7.toString() );
12465 final PhylogenyNode n8 = PhylogenyNode
12466 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12467 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12468 System.out.println( n8.toString() );
12471 final PhylogenyNode n9 = PhylogenyNode
12472 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12473 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12474 System.out.println( n9.toString() );
12477 final PhylogenyNode n10x = PhylogenyNode
12478 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12479 if ( n10x.getNodeData().isHasTaxonomy() ) {
12480 System.out.println( n10x.toString() );
12483 final PhylogenyNode n10xx = PhylogenyNode
12484 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12485 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12486 System.out.println( n10xx.toString() );
12489 final PhylogenyNode n10 = PhylogenyNode
12490 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12491 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12492 System.out.println( n10.toString() );
12495 final PhylogenyNode n11 = PhylogenyNode
12496 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12497 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12498 System.out.println( n11.toString() );
12501 final PhylogenyNode n12 = PhylogenyNode
12502 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12503 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12504 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12505 System.out.println( n12.toString() );
12508 final PhylogenyNode n13 = PhylogenyNode
12509 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12510 if ( n13.getNodeData().isHasTaxonomy() ) {
12511 System.out.println( n13.toString() );
12514 final PhylogenyNode n14 = PhylogenyNode
12515 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12516 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12517 System.out.println( n14.toString() );
12520 final PhylogenyNode n15 = PhylogenyNode
12521 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12522 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12523 System.out.println( n15.toString() );
12526 final PhylogenyNode n16 = PhylogenyNode
12527 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12528 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12529 System.out.println( n16.toString() );
12532 final PhylogenyNode n17 = PhylogenyNode
12533 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12534 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12535 System.out.println( n17.toString() );
12539 final PhylogenyNode n18 = PhylogenyNode
12540 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12541 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12542 System.out.println( n18.toString() );
12545 final PhylogenyNode n19 = PhylogenyNode
12546 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12547 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12548 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12549 System.out.println( n19.toString() );
12552 final PhylogenyNode n20 = PhylogenyNode
12553 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12554 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12555 System.out.println( n20.toString() );
12558 final PhylogenyNode n21 = PhylogenyNode
12559 .createInstanceFromNhxString( "Mus musculus musculus K392",
12560 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12561 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12562 System.out.println( n21.toString() );
12565 final PhylogenyNode n22 = PhylogenyNode
12566 .createInstanceFromNhxString( "NEMVE_Nematostella_vectensis",
12567 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12568 if ( !n22.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12569 System.out.println( n22.toString() );
12572 final PhylogenyNode n23 = PhylogenyNode
12573 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
12574 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12575 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12576 System.out.println( n23.toString() );
12579 final PhylogenyNode n24 = PhylogenyNode
12580 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12581 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12582 System.out.println( n24.toString() );
12586 final PhylogenyNode n25 = PhylogenyNode
12587 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
12588 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12589 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12590 System.out.println( n25.toString() );
12593 final PhylogenyNode n26 = PhylogenyNode
12594 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
12595 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12596 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12597 System.out.println( n26.toString() );
12600 final PhylogenyNode n27 = PhylogenyNode
12601 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12602 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12603 System.out.println( n27.toString() );
12607 catch ( final Exception e ) {
12608 e.printStackTrace( System.out );
12614 private static boolean testTreeCopy() {
12616 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12617 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12618 final Phylogeny t1 = t0.copy();
12619 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12622 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12625 t0.deleteSubtree( t0.getNode( "c" ), true );
12626 t0.deleteSubtree( t0.getNode( "a" ), true );
12627 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12628 t0.getNode( "b" ).setName( "Bee" );
12629 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12632 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12635 t0.deleteSubtree( t0.getNode( "e" ), true );
12636 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12637 t0.deleteSubtree( t0.getNode( "d" ), true );
12638 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12642 catch ( final Exception e ) {
12643 e.printStackTrace();
12649 private static boolean testTreeMethods() {
12651 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12652 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12653 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12654 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12655 System.out.println( t0.toNewHampshireX() );
12658 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12659 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12660 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12663 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12666 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12670 catch ( final Exception e ) {
12671 e.printStackTrace( System.out );
12677 private static boolean testUniprotEntryRetrieval() {
12679 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
12680 if ( !entry.getAccession().equals( "P12345" ) ) {
12683 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12686 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12689 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12692 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12695 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12699 catch ( final IOException e ) {
12700 System.out.println();
12701 System.out.println( "the following might be due to absence internet connection:" );
12702 e.printStackTrace( System.out );
12705 catch ( final Exception e ) {
12711 private static boolean testUniprotTaxonomySearch() {
12713 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12715 if ( results.size() != 1 ) {
12718 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12721 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12724 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12727 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12730 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12734 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12735 if ( results.size() != 1 ) {
12738 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12741 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12744 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12747 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12750 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12754 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12755 if ( results.size() != 1 ) {
12758 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12761 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12764 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12767 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12770 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12774 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12775 if ( results.size() != 1 ) {
12778 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12781 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12784 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12787 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12790 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12793 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12796 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12799 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12800 .equals( "Nematostella vectensis" ) ) {
12801 System.out.println( results.get( 0 ).getLineage() );
12806 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12807 if ( results.size() != 1 ) {
12810 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12813 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12816 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12819 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12822 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12825 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12826 .equals( "Xenopus tropicalis" ) ) {
12827 System.out.println( results.get( 0 ).getLineage() );
12832 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12833 if ( results.size() != 1 ) {
12836 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12839 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12842 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12845 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12848 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12851 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12852 .equals( "Xenopus tropicalis" ) ) {
12853 System.out.println( results.get( 0 ).getLineage() );
12858 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12859 if ( results.size() != 1 ) {
12862 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12865 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12868 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12871 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12874 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12877 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12878 .equals( "Xenopus tropicalis" ) ) {
12879 System.out.println( results.get( 0 ).getLineage() );
12883 catch ( final IOException e ) {
12884 System.out.println();
12885 System.out.println( "the following might be due to absence internet connection:" );
12886 e.printStackTrace( System.out );
12889 catch ( final Exception e ) {
12895 private static boolean testWabiTxSearch() {
12897 String result = "";
12898 result = TxSearch.searchSimple( "nematostella" );
12899 result = TxSearch.getTxId( "nematostella" );
12900 if ( !result.equals( "45350" ) ) {
12903 result = TxSearch.getTxName( "45350" );
12904 if ( !result.equals( "Nematostella" ) ) {
12907 result = TxSearch.getTxId( "nematostella vectensis" );
12908 if ( !result.equals( "45351" ) ) {
12911 result = TxSearch.getTxName( "45351" );
12912 if ( !result.equals( "Nematostella vectensis" ) ) {
12915 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12916 if ( !result.equals( "536089" ) ) {
12919 result = TxSearch.getTxName( "536089" );
12920 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12923 final List<String> queries = new ArrayList<String>();
12924 queries.add( "Campylobacter coli" );
12925 queries.add( "Escherichia coli" );
12926 queries.add( "Arabidopsis" );
12927 queries.add( "Trichoplax" );
12928 queries.add( "Samanea saman" );
12929 queries.add( "Kluyveromyces marxianus" );
12930 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12931 queries.add( "Bornavirus parrot/PDD/2008" );
12932 final List<RANKS> ranks = new ArrayList<RANKS>();
12933 ranks.add( RANKS.SUPERKINGDOM );
12934 ranks.add( RANKS.KINGDOM );
12935 ranks.add( RANKS.FAMILY );
12936 ranks.add( RANKS.GENUS );
12937 ranks.add( RANKS.TRIBE );
12938 result = TxSearch.searchLineage( queries, ranks );
12939 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12940 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12942 catch ( final Exception e ) {
12943 System.out.println();
12944 System.out.println( "the following might be due to absence internet connection:" );
12945 e.printStackTrace( System.out );