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;
32 import java.util.ArrayList;
33 import java.util.Date;
34 import java.util.HashSet;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.Locale;
39 import java.util.SortedSet;
41 import org.forester.application.support_transfer;
42 import org.forester.archaeopteryx.TreePanelUtil;
43 import org.forester.archaeopteryx.webservices.WebserviceUtil;
44 import org.forester.development.DevelopmentTools;
45 import org.forester.evoinference.TestPhylogenyReconstruction;
46 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
47 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
48 import org.forester.go.TestGo;
49 import org.forester.io.parsers.FastaParser;
50 import org.forester.io.parsers.GeneralMsaParser;
51 import org.forester.io.parsers.HmmscanPerDomainTableParser;
52 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
53 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
54 import org.forester.io.parsers.nexus.NexusCharactersParser;
55 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
56 import org.forester.io.parsers.nhx.NHXParser;
57 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
58 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
59 import org.forester.io.parsers.tol.TolParser;
60 import org.forester.io.parsers.util.ParserUtils;
61 import org.forester.io.writers.PhylogenyWriter;
62 import org.forester.io.writers.SequenceWriter;
63 import org.forester.msa.BasicMsa;
64 import org.forester.msa.DeleteableMsa;
65 import org.forester.msa.Mafft;
66 import org.forester.msa.Msa;
67 import org.forester.msa.MsaInferrer;
68 import org.forester.msa.MsaMethods;
69 import org.forester.pccx.TestPccx;
70 import org.forester.phylogeny.Phylogeny;
71 import org.forester.phylogeny.PhylogenyBranch;
72 import org.forester.phylogeny.PhylogenyMethods;
73 import org.forester.phylogeny.PhylogenyNode;
74 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
75 import org.forester.phylogeny.data.Accession;
76 import org.forester.phylogeny.data.Accession.Source;
77 import org.forester.phylogeny.data.BinaryCharacters;
78 import org.forester.phylogeny.data.BranchWidth;
79 import org.forester.phylogeny.data.Confidence;
80 import org.forester.phylogeny.data.Distribution;
81 import org.forester.phylogeny.data.DomainArchitecture;
82 import org.forester.phylogeny.data.Event;
83 import org.forester.phylogeny.data.Identifier;
84 import org.forester.phylogeny.data.PhylogenyData;
85 import org.forester.phylogeny.data.PhylogenyDataUtil;
86 import org.forester.phylogeny.data.Polygon;
87 import org.forester.phylogeny.data.PropertiesMap;
88 import org.forester.phylogeny.data.Property;
89 import org.forester.phylogeny.data.Property.AppliesTo;
90 import org.forester.phylogeny.data.ProteinDomain;
91 import org.forester.phylogeny.data.Taxonomy;
92 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
93 import org.forester.phylogeny.factories.PhylogenyFactory;
94 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
95 import org.forester.protein.BasicDomain;
96 import org.forester.protein.BasicProtein;
97 import org.forester.protein.Domain;
98 import org.forester.protein.Protein;
99 import org.forester.protein.ProteinId;
100 import org.forester.rio.TestRIO;
101 import org.forester.sdi.SDI;
102 import org.forester.sdi.SDIR;
103 import org.forester.sdi.TestGSDI;
104 import org.forester.sequence.BasicSequence;
105 import org.forester.sequence.Sequence;
106 import org.forester.species.BasicSpecies;
107 import org.forester.species.Species;
108 import org.forester.surfacing.TestSurfacing;
109 import org.forester.tools.ConfidenceAssessor;
110 import org.forester.tools.SupportCount;
111 import org.forester.tools.TreeSplitMatrix;
112 import org.forester.util.AsciiHistogram;
113 import org.forester.util.BasicDescriptiveStatistics;
114 import org.forester.util.BasicTable;
115 import org.forester.util.BasicTableParser;
116 import org.forester.util.DescriptiveStatistics;
117 import org.forester.util.ForesterConstants;
118 import org.forester.util.ForesterUtil;
119 import org.forester.util.GeneralTable;
120 import org.forester.util.SequenceAccessionTools;
121 import org.forester.ws.seqdb.SequenceDatabaseEntry;
122 import org.forester.ws.seqdb.SequenceDbWsTools;
123 import org.forester.ws.seqdb.UniProtTaxonomy;
124 import org.forester.ws.wabi.TxSearch;
125 import org.forester.ws.wabi.TxSearch.RANKS;
126 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
127 import org.forester.ws.wabi.TxSearch.TAX_RANK;
129 @SuppressWarnings( "unused")
130 public final class Test {
132 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
133 + ForesterUtil.getFileSeparator() + "resources"
134 + ForesterUtil.getFileSeparator();
135 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
136 + ForesterUtil.getFileSeparator() + "test_data"
137 + ForesterUtil.getFileSeparator();
138 private final static boolean PERFORM_DB_TESTS = false;
139 private static final boolean PERFORM_WEB_TREE_ACCESS = true;
140 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
141 + ForesterConstants.PHYLO_XML_VERSION + "/"
142 + ForesterConstants.PHYLO_XML_XSD;
143 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
144 + ForesterConstants.PHYLO_XML_VERSION + "/"
145 + ForesterConstants.PHYLO_XML_XSD;
146 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
147 private final static double ZERO_DIFF = 1.0E-9;
149 public static boolean isEqual( final double a, final double b ) {
150 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
153 public static void main( final String[] args ) {
154 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
155 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
157 Locale.setDefault( Locale.US );
158 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
161 System.out.print( "[Test if directory with files for testing exists/is readable: " );
162 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
163 System.out.println( "OK.]" );
166 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
167 System.out.println( "Testing aborted." );
170 System.out.print( "[Test if resources directory exists/is readable: " );
171 if ( testDir( PATH_TO_RESOURCES ) ) {
172 System.out.println( "OK.]" );
175 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
176 System.out.println( "Testing aborted." );
179 final long start_time = new Date().getTime();
180 System.out.print( "Basic node methods: " );
181 if ( Test.testBasicNodeMethods() ) {
182 System.out.println( "OK." );
186 System.out.println( "failed." );
189 System.out.print( "Protein id: " );
190 if ( !testProteinId() ) {
191 System.out.println( "failed." );
197 System.out.println( "OK." );
198 System.out.print( "Species: " );
199 if ( !testSpecies() ) {
200 System.out.println( "failed." );
206 System.out.println( "OK." );
207 System.out.print( "Basic domain: " );
208 if ( !testBasicDomain() ) {
209 System.out.println( "failed." );
215 System.out.println( "OK." );
216 System.out.print( "Basic protein: " );
217 if ( !testBasicProtein() ) {
218 System.out.println( "failed." );
224 System.out.println( "OK." );
225 System.out.print( "Sequence writer: " );
226 if ( testSequenceWriter() ) {
227 System.out.println( "OK." );
231 System.out.println( "failed." );
234 System.out.print( "Sequence id parsing: " );
235 if ( testSequenceIdParsing() ) {
236 System.out.println( "OK." );
240 System.out.println( "failed." );
243 System.out.print( "UniProtKB id extraction: " );
244 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
245 System.out.println( "OK." );
249 System.out.println( "failed." );
252 System.out.print( "Sequence DB tools 1: " );
253 if ( testSequenceDbWsTools1() ) {
254 System.out.println( "OK." );
258 System.out.println( "failed." );
261 System.out.print( "Hmmscan output parser: " );
262 if ( testHmmscanOutputParser() ) {
263 System.out.println( "OK." );
267 System.out.println( "failed." );
270 System.out.print( "Overlap removal: " );
271 if ( !org.forester.test.Test.testOverlapRemoval() ) {
272 System.out.println( "failed." );
278 System.out.println( "OK." );
279 System.out.print( "Engulfing overlap removal: " );
280 if ( !Test.testEngulfingOverlapRemoval() ) {
281 System.out.println( "failed." );
287 System.out.println( "OK." );
288 System.out.print( "Taxonomy code extraction: " );
289 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
290 System.out.println( "OK." );
294 System.out.println( "failed." );
297 System.out.print( "SN extraction: " );
298 if ( Test.testExtractSNFromNodeName() ) {
299 System.out.println( "OK." );
303 System.out.println( "failed." );
306 System.out.print( "Taxonomy extraction (general): " );
307 if ( Test.testTaxonomyExtraction() ) {
308 System.out.println( "OK." );
312 System.out.println( "failed." );
315 System.out.print( "Uri for Aptx web sequence accession: " );
316 if ( Test.testCreateUriForSeqWeb() ) {
317 System.out.println( "OK." );
321 System.out.println( "failed." );
324 System.out.print( "Basic node construction and parsing of NHX (node level): " );
325 if ( Test.testNHXNodeParsing() ) {
326 System.out.println( "OK." );
330 System.out.println( "failed." );
333 System.out.print( "NHX parsing iterating: " );
334 if ( Test.testNHParsingIter() ) {
335 System.out.println( "OK." );
339 System.out.println( "failed." );
342 System.out.print( "NH parsing: " );
343 if ( Test.testNHParsing() ) {
344 System.out.println( "OK." );
348 System.out.println( "failed." );
351 System.out.print( "Conversion to NHX (node level): " );
352 if ( Test.testNHXconversion() ) {
353 System.out.println( "OK." );
357 System.out.println( "failed." );
360 System.out.print( "NHX parsing: " );
361 if ( Test.testNHXParsing() ) {
362 System.out.println( "OK." );
366 System.out.println( "failed." );
369 System.out.print( "NHX parsing with quotes: " );
370 if ( Test.testNHXParsingQuotes() ) {
371 System.out.println( "OK." );
375 System.out.println( "failed." );
378 System.out.print( "NHX parsing (MrBayes): " );
379 if ( Test.testNHXParsingMB() ) {
380 System.out.println( "OK." );
384 System.out.println( "failed." );
387 System.out.print( "Nexus characters parsing: " );
388 if ( Test.testNexusCharactersParsing() ) {
389 System.out.println( "OK." );
393 System.out.println( "failed." );
396 System.out.print( "Nexus tree parsing iterating: " );
397 if ( Test.testNexusTreeParsingIterating() ) {
398 System.out.println( "OK." );
402 System.out.println( "failed." );
405 System.out.print( "Nexus tree parsing: " );
406 if ( Test.testNexusTreeParsing() ) {
407 System.out.println( "OK." );
411 System.out.println( "failed." );
414 System.out.print( "Nexus tree parsing (translating): " );
415 if ( Test.testNexusTreeParsingTranslating() ) {
416 System.out.println( "OK." );
420 System.out.println( "failed." );
423 System.out.print( "Nexus matrix parsing: " );
424 if ( Test.testNexusMatrixParsing() ) {
425 System.out.println( "OK." );
429 System.out.println( "failed." );
432 System.out.print( "Basic phyloXML parsing: " );
433 if ( Test.testBasicPhyloXMLparsing() ) {
434 System.out.println( "OK." );
438 System.out.println( "failed." );
441 System.out.print( "Basic phyloXML parsing (validating against schema): " );
442 if ( testBasicPhyloXMLparsingValidating() ) {
443 System.out.println( "OK." );
447 System.out.println( "failed." );
450 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
451 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
452 System.out.println( "OK." );
456 System.out.println( "failed." );
459 System.out.print( "phyloXML Distribution Element: " );
460 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
461 System.out.println( "OK." );
465 System.out.println( "failed." );
468 System.out.print( "Tol XML parsing: " );
469 if ( Test.testBasicTolXMLparsing() ) {
470 System.out.println( "OK." );
474 System.out.println( "failed." );
477 System.out.print( "Copying of node data: " );
478 if ( Test.testCopyOfNodeData() ) {
479 System.out.println( "OK." );
483 System.out.println( "failed." );
486 System.out.print( "Tree copy: " );
487 if ( Test.testTreeCopy() ) {
488 System.out.println( "OK." );
492 System.out.println( "failed." );
495 System.out.print( "Basic tree methods: " );
496 if ( Test.testBasicTreeMethods() ) {
497 System.out.println( "OK." );
501 System.out.println( "failed." );
504 System.out.print( "Tree methods: " );
505 if ( Test.testTreeMethods() ) {
506 System.out.println( "OK." );
510 System.out.println( "failed." );
513 System.out.print( "Postorder Iterator: " );
514 if ( Test.testPostOrderIterator() ) {
515 System.out.println( "OK." );
519 System.out.println( "failed." );
522 System.out.print( "Preorder Iterator: " );
523 if ( Test.testPreOrderIterator() ) {
524 System.out.println( "OK." );
528 System.out.println( "failed." );
531 System.out.print( "Levelorder Iterator: " );
532 if ( Test.testLevelOrderIterator() ) {
533 System.out.println( "OK." );
537 System.out.println( "failed." );
540 System.out.print( "Re-id methods: " );
541 if ( Test.testReIdMethods() ) {
542 System.out.println( "OK." );
546 System.out.println( "failed." );
549 System.out.print( "Methods on last external nodes: " );
550 if ( Test.testLastExternalNodeMethods() ) {
551 System.out.println( "OK." );
555 System.out.println( "failed." );
558 System.out.print( "Methods on external nodes: " );
559 if ( Test.testExternalNodeRelatedMethods() ) {
560 System.out.println( "OK." );
564 System.out.println( "failed." );
567 System.out.print( "Deletion of external nodes: " );
568 if ( Test.testDeletionOfExternalNodes() ) {
569 System.out.println( "OK." );
573 System.out.println( "failed." );
576 System.out.print( "Subtree deletion: " );
577 if ( Test.testSubtreeDeletion() ) {
578 System.out.println( "OK." );
582 System.out.println( "failed." );
585 System.out.print( "Phylogeny branch: " );
586 if ( Test.testPhylogenyBranch() ) {
587 System.out.println( "OK." );
591 System.out.println( "failed." );
594 System.out.print( "Rerooting: " );
595 if ( Test.testRerooting() ) {
596 System.out.println( "OK." );
600 System.out.println( "failed." );
603 System.out.print( "Mipoint rooting: " );
604 if ( Test.testMidpointrooting() ) {
605 System.out.println( "OK." );
609 System.out.println( "failed." );
612 System.out.print( "Node removal: " );
613 if ( Test.testNodeRemoval() ) {
614 System.out.println( "OK." );
618 System.out.println( "failed." );
621 System.out.print( "Support count: " );
622 if ( Test.testSupportCount() ) {
623 System.out.println( "OK." );
627 System.out.println( "failed." );
630 System.out.print( "Support transfer: " );
631 if ( Test.testSupportTransfer() ) {
632 System.out.println( "OK." );
636 System.out.println( "failed." );
639 System.out.print( "Finding of LCA: " );
640 if ( Test.testGetLCA() ) {
641 System.out.println( "OK." );
645 System.out.println( "failed." );
648 System.out.print( "Finding of LCA 2: " );
649 if ( Test.testGetLCA2() ) {
650 System.out.println( "OK." );
654 System.out.println( "failed." );
657 System.out.print( "Calculation of distance between nodes: " );
658 if ( Test.testGetDistance() ) {
659 System.out.println( "OK." );
663 System.out.println( "failed." );
666 System.out.print( "Descriptive statistics: " );
667 if ( Test.testDescriptiveStatistics() ) {
668 System.out.println( "OK." );
672 System.out.println( "failed." );
675 System.out.print( "Data objects and methods: " );
676 if ( Test.testDataObjects() ) {
677 System.out.println( "OK." );
681 System.out.println( "failed." );
684 System.out.print( "Properties map: " );
685 if ( Test.testPropertiesMap() ) {
686 System.out.println( "OK." );
690 System.out.println( "failed." );
693 System.out.print( "SDIse: " );
694 if ( Test.testSDIse() ) {
695 System.out.println( "OK." );
699 System.out.println( "failed." );
702 System.out.print( "SDIunrooted: " );
703 if ( Test.testSDIunrooted() ) {
704 System.out.println( "OK." );
708 System.out.println( "failed." );
711 System.out.print( "GSDI: " );
712 if ( TestGSDI.test() ) {
713 System.out.println( "OK." );
717 System.out.println( "failed." );
720 System.out.print( "RIO: " );
721 if ( TestRIO.test() ) {
722 System.out.println( "OK." );
726 System.out.println( "failed." );
729 System.out.print( "Phylogeny reconstruction:" );
730 System.out.println();
731 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
732 System.out.println( "OK." );
736 System.out.println( "failed." );
739 System.out.print( "Analysis of domain architectures: " );
740 System.out.println();
741 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
742 System.out.println( "OK." );
746 System.out.println( "failed." );
749 System.out.print( "GO: " );
750 System.out.println();
751 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
752 System.out.println( "OK." );
756 System.out.println( "failed." );
759 System.out.print( "Modeling tools: " );
760 if ( TestPccx.test() ) {
761 System.out.println( "OK." );
765 System.out.println( "failed." );
768 System.out.print( "Split Matrix strict: " );
769 if ( Test.testSplitStrict() ) {
770 System.out.println( "OK." );
774 System.out.println( "failed." );
777 System.out.print( "Split Matrix: " );
778 if ( Test.testSplit() ) {
779 System.out.println( "OK." );
783 System.out.println( "failed." );
786 System.out.print( "Confidence Assessor: " );
787 if ( Test.testConfidenceAssessor() ) {
788 System.out.println( "OK." );
792 System.out.println( "failed." );
795 System.out.print( "Basic table: " );
796 if ( Test.testBasicTable() ) {
797 System.out.println( "OK." );
801 System.out.println( "failed." );
804 System.out.print( "General table: " );
805 if ( Test.testGeneralTable() ) {
806 System.out.println( "OK." );
810 System.out.println( "failed." );
813 System.out.print( "Amino acid sequence: " );
814 if ( Test.testAminoAcidSequence() ) {
815 System.out.println( "OK." );
819 System.out.println( "failed." );
822 System.out.print( "General MSA parser: " );
823 if ( Test.testGeneralMsaParser() ) {
824 System.out.println( "OK." );
828 System.out.println( "failed." );
831 System.out.print( "Fasta parser for msa: " );
832 if ( Test.testFastaParser() ) {
833 System.out.println( "OK." );
837 System.out.println( "failed." );
840 System.out.print( "Creation of balanced phylogeny: " );
841 if ( Test.testCreateBalancedPhylogeny() ) {
842 System.out.println( "OK." );
846 System.out.println( "failed." );
849 System.out.print( "Genbank accessor parsing: " );
850 if ( Test.testGenbankAccessorParsing() ) {
851 System.out.println( "OK." );
855 System.out.println( "failed." );
859 final String os = ForesterUtil.OS_NAME.toLowerCase();
860 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
861 path = "/usr/local/bin/mafft";
863 else if ( os.indexOf( "win" ) >= 0 ) {
864 path = "C:\\Program Files\\mafft-win\\mafft.bat";
868 if ( !MsaInferrer.isInstalled( path ) ) {
869 path = "/usr/bin/mafft";
871 if ( !MsaInferrer.isInstalled( path ) ) {
872 path = "/usr/local/bin/mafft";
875 if ( MsaInferrer.isInstalled( path ) ) {
876 System.out.print( "MAFFT (external program): " );
877 if ( Test.testMafft( path ) ) {
878 System.out.println( "OK." );
882 System.out.println( "failed [will not count towards failed tests]" );
885 System.out.print( "Next nodes with collapsed: " );
886 if ( Test.testNextNodeWithCollapsing() ) {
887 System.out.println( "OK." );
891 System.out.println( "failed." );
894 System.out.print( "Simple MSA quality: " );
895 if ( Test.testMsaQualityMethod() ) {
896 System.out.println( "OK." );
900 System.out.println( "failed." );
903 System.out.print( "Deleteable MSA: " );
904 if ( Test.testDeleteableMsa() ) {
905 System.out.println( "OK." );
909 System.out.println( "failed." );
913 if ( PERFORM_DB_TESTS ) {
914 System.out.print( "Uniprot Entry Retrieval: " );
915 if ( Test.testUniprotEntryRetrieval() ) {
916 System.out.println( "OK." );
920 System.out.println( "failed." );
923 System.out.print( "Ebi Entry Retrieval: " );
924 if ( Test.testEbiEntryRetrieval() ) {
925 System.out.println( "OK." );
929 System.out.println( "failed." );
932 System.out.print( "Sequence DB tools 2: " );
933 if ( testSequenceDbWsTools2() ) {
934 System.out.println( "OK." );
938 System.out.println( "failed." );
942 System.out.print( "Uniprot Taxonomy Search: " );
943 if ( Test.testUniprotTaxonomySearch() ) {
944 System.out.println( "OK." );
948 System.out.println( "failed." );
952 if ( PERFORM_WEB_TREE_ACCESS ) {
953 System.out.print( "NHX parsing from URL: " );
954 if ( Test.testNHXparsingFromURL() ) {
955 System.out.println( "OK." );
959 System.out.println( "failed." );
962 System.out.print( "phyloXML parsing from URL: " );
963 if ( Test.testPhyloXMLparsingFromURL() ) {
964 System.out.println( "OK." );
968 System.out.println( "failed." );
971 System.out.print( "TreeBase acccess: " );
972 if ( Test.testTreeBaseReading() ) {
973 System.out.println( "OK." );
977 System.out.println( "failed." );
981 System.out.print( "ToL access: " );
982 if ( Test.testToLReading() ) {
983 System.out.println( "OK." );
987 System.out.println( "failed." );
991 System.out.print( "TreeFam access: " );
992 if ( Test.testTreeFamReading() ) {
993 System.out.println( "OK." );
997 System.out.println( "failed." );
1002 System.out.print( "Pfam tree access: " );
1003 if ( Test.testPfamTreeReading() ) {
1004 System.out.println( "OK." );
1008 System.out.println( "failed." );
1012 System.out.println();
1013 final Runtime rt = java.lang.Runtime.getRuntime();
1014 final long free_memory = rt.freeMemory() / 1000000;
1015 final long total_memory = rt.totalMemory() / 1000000;
1016 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1017 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1018 System.out.println();
1019 System.out.println( "Successful tests: " + succeeded );
1020 System.out.println( "Failed tests: " + failed );
1021 System.out.println();
1023 System.out.println( "OK." );
1026 System.out.println( "Not OK." );
1030 public static boolean testEngulfingOverlapRemoval() {
1032 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1033 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1034 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1035 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1036 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1037 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1038 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1039 final List<Boolean> covered = new ArrayList<Boolean>();
1040 covered.add( true ); // 0
1041 covered.add( false ); // 1
1042 covered.add( true ); // 2
1043 covered.add( false ); // 3
1044 covered.add( true ); // 4
1045 covered.add( true ); // 5
1046 covered.add( false ); // 6
1047 covered.add( true ); // 7
1048 covered.add( true ); // 8
1049 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1052 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1055 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1058 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1061 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1064 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1067 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1070 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1071 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1072 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1073 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1074 abc.addProteinDomain( a );
1075 abc.addProteinDomain( b );
1076 abc.addProteinDomain( c );
1077 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1078 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1079 if ( abc.getNumberOfProteinDomains() != 3 ) {
1082 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1085 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1088 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1091 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1094 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1095 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1096 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1097 final Protein def = new BasicProtein( "def", "nemve", 0 );
1098 def.addProteinDomain( d );
1099 def.addProteinDomain( e );
1100 def.addProteinDomain( f );
1101 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1102 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1103 if ( def.getNumberOfProteinDomains() != 3 ) {
1106 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1109 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1112 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1115 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1118 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1122 catch ( final Exception e ) {
1123 e.printStackTrace( System.out );
1129 public static final boolean testNHXparsingFromURL() {
1131 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1132 final URL u = new URL( s );
1133 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1134 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1135 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1138 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1139 System.out.println( phys[ 0 ].toNewHampshire() );
1142 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1143 System.out.println( phys[ 1 ].toNewHampshire() );
1146 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1147 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1150 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1151 System.out.println( phys2[ 0 ].toNewHampshire() );
1154 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1155 final NHXParser p = new NHXParser();
1156 final URL u2 = new URL( s );
1158 if ( !p.hasNext() ) {
1161 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1164 if ( !p.hasNext() ) {
1168 if ( !p.hasNext() ) {
1171 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1174 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1178 if ( !p.hasNext() ) {
1181 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1184 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1188 catch ( final Exception e ) {
1189 e.printStackTrace();
1194 public static boolean testOverlapRemoval() {
1196 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1197 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1198 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1199 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1200 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1201 final List<Boolean> covered = new ArrayList<Boolean>();
1202 covered.add( true ); // 0
1203 covered.add( false ); // 1
1204 covered.add( true ); // 2
1205 covered.add( false ); // 3
1206 covered.add( true ); // 4
1207 covered.add( true ); // 5
1208 covered.add( false ); // 6
1209 covered.add( true ); // 7
1210 covered.add( true ); // 8
1211 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1214 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1217 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1220 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1223 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1226 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1227 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1228 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1229 ab.addProteinDomain( a );
1230 ab.addProteinDomain( b );
1231 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1232 if ( ab.getNumberOfProteinDomains() != 2 ) {
1235 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1238 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1241 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1242 if ( ab.getNumberOfProteinDomains() != 2 ) {
1245 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1248 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1249 final Domain d = new BasicDomain( "d",
1256 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1257 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1258 cde.addProteinDomain( c );
1259 cde.addProteinDomain( d );
1260 cde.addProteinDomain( e );
1261 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1262 if ( cde.getNumberOfProteinDomains() != 3 ) {
1265 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1268 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1269 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1270 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1271 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1272 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1273 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1274 fghi.addProteinDomain( f );
1275 fghi.addProteinDomain( g );
1276 fghi.addProteinDomain( h );
1277 fghi.addProteinDomain( i );
1278 fghi.addProteinDomain( i );
1279 fghi.addProteinDomain( i );
1280 fghi.addProteinDomain( i2 );
1281 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1282 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1285 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1288 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1291 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1292 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1295 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1298 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1299 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1300 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1301 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1302 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1303 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1304 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1305 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1306 jklm.addProteinDomain( j );
1307 jklm.addProteinDomain( k );
1308 jklm.addProteinDomain( l );
1309 jklm.addProteinDomain( m );
1310 jklm.addProteinDomain( m0 );
1311 jklm.addProteinDomain( m1 );
1312 jklm.addProteinDomain( m2 );
1313 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1314 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1317 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1320 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1323 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1324 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1327 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1330 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1331 final Protein od = new BasicProtein( "od", "varanus", 0 );
1332 od.addProteinDomain( only );
1333 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1334 if ( od.getNumberOfProteinDomains() != 1 ) {
1337 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1341 catch ( final Exception e ) {
1342 e.printStackTrace( System.out );
1348 public static final boolean testPfamTreeReading() {
1350 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1351 final NHXParser parser = new NHXParser();
1352 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1353 parser.setReplaceUnderscores( false );
1354 parser.setGuessRootedness( true );
1355 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1356 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1357 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1360 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1364 catch ( final Exception e ) {
1365 e.printStackTrace();
1370 public static final boolean testPhyloXMLparsingFromURL() {
1372 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1373 final URL u = new URL( s );
1374 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1375 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1376 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1380 catch ( final Exception e ) {
1381 e.printStackTrace();
1386 public static final boolean testToLReading() {
1388 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1389 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1390 final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
1391 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1394 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1397 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1400 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1404 catch ( final Exception e ) {
1405 e.printStackTrace();
1410 public static final boolean testTreeBaseReading() {
1412 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1413 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1414 parser.setReplaceUnderscores( true );
1415 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1416 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1417 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1420 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1421 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1422 parser2.setReplaceUnderscores( true );
1423 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1424 final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
1425 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1429 catch ( final Exception e ) {
1430 e.printStackTrace();
1435 public static final boolean testTreeFamReading() {
1437 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1438 final NHXParser parser = new NHXParser();
1439 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
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 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1458 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1462 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1463 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1466 private static boolean testAminoAcidSequence() {
1468 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1469 if ( aa1.getLength() != 13 ) {
1472 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1475 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1478 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1481 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1482 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1485 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1486 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1489 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1490 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1494 catch ( final Exception e ) {
1495 e.printStackTrace();
1501 private static boolean testBasicDomain() {
1503 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1504 if ( !pd.getDomainId().equals( "id" ) ) {
1507 if ( pd.getNumber() != 1 ) {
1510 if ( pd.getTotalCount() != 4 ) {
1513 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1516 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1517 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1518 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1519 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1520 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1521 if ( !a1.equals( a1 ) ) {
1524 if ( !a1.equals( a1_copy ) ) {
1527 if ( !a1.equals( a1_equal ) ) {
1530 if ( !a1.equals( a2 ) ) {
1533 if ( a1.equals( a3 ) ) {
1536 if ( a1.compareTo( a1 ) != 0 ) {
1539 if ( a1.compareTo( a1_copy ) != 0 ) {
1542 if ( a1.compareTo( a1_equal ) != 0 ) {
1545 if ( a1.compareTo( a2 ) != 0 ) {
1548 if ( a1.compareTo( a3 ) == 0 ) {
1552 catch ( final Exception e ) {
1553 e.printStackTrace( System.out );
1559 private static boolean testBasicNodeMethods() {
1561 if ( PhylogenyNode.getNodeCount() != 0 ) {
1564 final PhylogenyNode n1 = new PhylogenyNode();
1565 final PhylogenyNode n2 = PhylogenyNode
1566 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1567 final PhylogenyNode n3 = PhylogenyNode
1568 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1569 final PhylogenyNode n4 = PhylogenyNode
1570 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1571 if ( n1.isHasAssignedEvent() ) {
1574 if ( PhylogenyNode.getNodeCount() != 4 ) {
1577 if ( n3.getIndicator() != 0 ) {
1580 if ( n3.getNumberOfExternalNodes() != 1 ) {
1583 if ( !n3.isExternal() ) {
1586 if ( !n3.isRoot() ) {
1589 if ( !n4.getName().equals( "n4" ) ) {
1593 catch ( final Exception e ) {
1594 e.printStackTrace( System.out );
1600 private static boolean testBasicPhyloXMLparsing() {
1602 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1603 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1604 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1606 if ( xml_parser.getErrorCount() > 0 ) {
1607 System.out.println( xml_parser.getErrorMessages().toString() );
1610 if ( phylogenies_0.length != 4 ) {
1613 final Phylogeny t1 = phylogenies_0[ 0 ];
1614 final Phylogeny t2 = phylogenies_0[ 1 ];
1615 final Phylogeny t3 = phylogenies_0[ 2 ];
1616 final Phylogeny t4 = phylogenies_0[ 3 ];
1617 if ( t1.getNumberOfExternalNodes() != 1 ) {
1620 if ( !t1.isRooted() ) {
1623 if ( t1.isRerootable() ) {
1626 if ( !t1.getType().equals( "gene_tree" ) ) {
1629 if ( t2.getNumberOfExternalNodes() != 2 ) {
1632 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1635 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1638 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1641 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1644 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1647 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1650 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1651 .startsWith( "actgtgggggt" ) ) {
1654 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1655 .startsWith( "ctgtgatgcat" ) ) {
1658 if ( t3.getNumberOfExternalNodes() != 4 ) {
1661 if ( !t1.getName().equals( "t1" ) ) {
1664 if ( !t2.getName().equals( "t2" ) ) {
1667 if ( !t3.getName().equals( "t3" ) ) {
1670 if ( !t4.getName().equals( "t4" ) ) {
1673 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1676 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1679 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1682 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1683 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1686 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1689 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1692 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1695 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1696 .equals( "apoptosis" ) ) {
1699 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1700 .equals( "GO:0006915" ) ) {
1703 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1704 .equals( "UniProtKB" ) ) {
1707 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1708 .equals( "experimental" ) ) {
1711 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1712 .equals( "function" ) ) {
1715 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1716 .getValue() != 1 ) {
1719 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1720 .getType().equals( "ml" ) ) {
1723 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1724 .equals( "apoptosis" ) ) {
1727 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1728 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1731 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1732 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1735 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1736 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1739 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1740 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1743 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1744 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1747 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1748 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1751 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1752 .equals( "GO:0005829" ) ) {
1755 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1756 .equals( "intracellular organelle" ) ) {
1759 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1762 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1763 .equals( "UniProt link" ) ) ) {
1766 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1769 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1770 if ( x.size() != 4 ) {
1774 for( final Accession acc : x ) {
1776 if ( !acc.getSource().equals( "KEGG" ) ) {
1779 if ( !acc.getValue().equals( "hsa:596" ) ) {
1786 catch ( final Exception e ) {
1787 e.printStackTrace( System.out );
1793 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1795 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1796 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1797 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1798 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1801 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1803 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1805 if ( xml_parser.getErrorCount() > 0 ) {
1806 System.out.println( xml_parser.getErrorMessages().toString() );
1809 if ( phylogenies_0.length != 4 ) {
1812 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1813 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1814 if ( phylogenies_t1.length != 1 ) {
1817 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1818 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1821 if ( !t1_rt.isRooted() ) {
1824 if ( t1_rt.isRerootable() ) {
1827 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1830 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1831 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1832 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1833 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1836 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1839 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1842 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1845 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1846 .startsWith( "actgtgggggt" ) ) {
1849 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1850 .startsWith( "ctgtgatgcat" ) ) {
1853 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1854 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1855 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1856 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1857 if ( phylogenies_1.length != 1 ) {
1860 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1861 if ( !t3_rt.getName().equals( "t3" ) ) {
1864 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1867 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1870 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1873 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1876 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1877 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1880 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1883 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1886 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1887 .equals( "UniProtKB" ) ) {
1890 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1891 .equals( "apoptosis" ) ) {
1894 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1895 .equals( "GO:0006915" ) ) {
1898 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1899 .equals( "UniProtKB" ) ) {
1902 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1903 .equals( "experimental" ) ) {
1906 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1907 .equals( "function" ) ) {
1910 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1911 .getValue() != 1 ) {
1914 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1915 .getType().equals( "ml" ) ) {
1918 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1919 .equals( "apoptosis" ) ) {
1922 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1923 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1926 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1927 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1930 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1931 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1934 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1935 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1938 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1939 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1942 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1943 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1946 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1947 .equals( "GO:0005829" ) ) {
1950 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1951 .equals( "intracellular organelle" ) ) {
1954 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1957 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1958 .equals( "UniProt link" ) ) ) {
1961 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1964 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1967 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1968 .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." ) ) ) {
1971 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1974 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1977 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1980 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1983 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1984 .equals( "ncbi" ) ) {
1987 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1990 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1991 .getName().equals( "B" ) ) {
1994 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1995 .getFrom() != 21 ) {
1998 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
2001 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2002 .getLength() != 24 ) {
2005 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2006 .getConfidence() != 2144 ) {
2009 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2010 .equals( "pfam" ) ) {
2013 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2016 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2019 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2022 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2025 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2026 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2029 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2032 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2035 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2038 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2041 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2044 if ( taxbb.getSynonyms().size() != 2 ) {
2047 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2050 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2053 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2056 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2059 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2062 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2063 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2066 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2069 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2072 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2075 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2078 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2081 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2084 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2088 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2091 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2092 .equalsIgnoreCase( "435" ) ) {
2095 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2098 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2099 .equalsIgnoreCase( "443.7" ) ) {
2102 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2105 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2108 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2109 .equalsIgnoreCase( "433" ) ) {
2112 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2113 .getCrossReferences();
2114 if ( x.size() != 4 ) {
2118 for( final Accession acc : x ) {
2120 if ( !acc.getSource().equals( "KEGG" ) ) {
2123 if ( !acc.getValue().equals( "hsa:596" ) ) {
2130 catch ( final Exception e ) {
2131 e.printStackTrace( System.out );
2137 private static boolean testBasicPhyloXMLparsingValidating() {
2139 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2140 PhyloXmlParser xml_parser = null;
2142 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2144 catch ( final Exception e ) {
2145 // Do nothing -- means were not running from jar.
2147 if ( xml_parser == null ) {
2148 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2149 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2150 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2153 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2156 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2158 if ( xml_parser.getErrorCount() > 0 ) {
2159 System.out.println( xml_parser.getErrorMessages().toString() );
2162 if ( phylogenies_0.length != 4 ) {
2165 final Phylogeny t1 = phylogenies_0[ 0 ];
2166 final Phylogeny t2 = phylogenies_0[ 1 ];
2167 final Phylogeny t3 = phylogenies_0[ 2 ];
2168 final Phylogeny t4 = phylogenies_0[ 3 ];
2169 if ( !t1.getName().equals( "t1" ) ) {
2172 if ( !t2.getName().equals( "t2" ) ) {
2175 if ( !t3.getName().equals( "t3" ) ) {
2178 if ( !t4.getName().equals( "t4" ) ) {
2181 if ( t1.getNumberOfExternalNodes() != 1 ) {
2184 if ( t2.getNumberOfExternalNodes() != 2 ) {
2187 if ( t3.getNumberOfExternalNodes() != 4 ) {
2190 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2191 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2192 if ( xml_parser.getErrorCount() > 0 ) {
2193 System.out.println( "errors:" );
2194 System.out.println( xml_parser.getErrorMessages().toString() );
2197 if ( phylogenies_1.length != 4 ) {
2200 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2202 if ( xml_parser.getErrorCount() > 0 ) {
2203 System.out.println( "errors:" );
2204 System.out.println( xml_parser.getErrorMessages().toString() );
2207 if ( phylogenies_2.length != 1 ) {
2210 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2213 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2215 if ( xml_parser.getErrorCount() > 0 ) {
2216 System.out.println( xml_parser.getErrorMessages().toString() );
2219 if ( phylogenies_3.length != 2 ) {
2222 final Phylogeny a = phylogenies_3[ 0 ];
2223 if ( !a.getName().equals( "tree 4" ) ) {
2226 if ( a.getNumberOfExternalNodes() != 3 ) {
2229 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2232 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2235 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2237 if ( xml_parser.getErrorCount() > 0 ) {
2238 System.out.println( xml_parser.getErrorMessages().toString() );
2241 if ( phylogenies_4.length != 1 ) {
2244 final Phylogeny s = phylogenies_4[ 0 ];
2245 if ( s.getNumberOfExternalNodes() != 6 ) {
2248 s.getNode( "first" );
2250 s.getNode( "\"<a'b&c'd\">\"" );
2251 s.getNode( "'''\"" );
2252 s.getNode( "\"\"\"" );
2253 s.getNode( "dick & doof" );
2255 catch ( final Exception e ) {
2256 e.printStackTrace( System.out );
2262 private static boolean testBasicProtein() {
2264 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2265 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2266 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2267 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2268 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2269 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2270 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2271 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2272 p0.addProteinDomain( y );
2273 p0.addProteinDomain( e );
2274 p0.addProteinDomain( b );
2275 p0.addProteinDomain( c );
2276 p0.addProteinDomain( d );
2277 p0.addProteinDomain( a );
2278 p0.addProteinDomain( x );
2279 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2282 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2286 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2287 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2288 aa0.addProteinDomain( a1 );
2289 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2292 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2296 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2297 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2298 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2299 aa1.addProteinDomain( a11 );
2300 aa1.addProteinDomain( a12 );
2301 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2304 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2307 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2308 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2311 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2314 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2317 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2318 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2321 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2324 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2327 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2330 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2331 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2334 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2337 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2340 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2343 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2344 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2347 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2350 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2353 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2357 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2358 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2359 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2360 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2361 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2362 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2363 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2364 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2365 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2366 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2367 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2368 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2369 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2370 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2371 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2372 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2373 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2374 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2375 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2376 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2377 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2378 p00.addProteinDomain( y0 );
2379 p00.addProteinDomain( e0 );
2380 p00.addProteinDomain( b0 );
2381 p00.addProteinDomain( c0 );
2382 p00.addProteinDomain( d0 );
2383 p00.addProteinDomain( a0 );
2384 p00.addProteinDomain( x0 );
2385 p00.addProteinDomain( y1 );
2386 p00.addProteinDomain( y2 );
2387 p00.addProteinDomain( y3 );
2388 p00.addProteinDomain( e1 );
2389 p00.addProteinDomain( e2 );
2390 p00.addProteinDomain( e3 );
2391 p00.addProteinDomain( e4 );
2392 p00.addProteinDomain( e5 );
2393 p00.addProteinDomain( z0 );
2394 p00.addProteinDomain( z1 );
2395 p00.addProteinDomain( z2 );
2396 p00.addProteinDomain( zz0 );
2397 p00.addProteinDomain( zz1 );
2398 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2401 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2404 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2407 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2410 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" ) ) {
2413 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2414 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2415 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2416 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2417 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2418 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2419 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2420 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2421 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2422 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2423 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2424 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2425 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2426 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2427 p.addProteinDomain( B15 );
2428 p.addProteinDomain( C50 );
2429 p.addProteinDomain( A60 );
2430 p.addProteinDomain( A30 );
2431 p.addProteinDomain( C70 );
2432 p.addProteinDomain( B35 );
2433 p.addProteinDomain( B40 );
2434 p.addProteinDomain( A0 );
2435 p.addProteinDomain( A10 );
2436 p.addProteinDomain( A20 );
2437 p.addProteinDomain( B25 );
2438 p.addProteinDomain( D80 );
2439 List<String> domains_ids = new ArrayList<String>();
2440 domains_ids.add( "A" );
2441 domains_ids.add( "B" );
2442 domains_ids.add( "C" );
2443 if ( !p.contains( domains_ids, false ) ) {
2446 if ( !p.contains( domains_ids, true ) ) {
2449 domains_ids.add( "X" );
2450 if ( p.contains( domains_ids, false ) ) {
2453 if ( p.contains( domains_ids, true ) ) {
2456 domains_ids = new ArrayList<String>();
2457 domains_ids.add( "A" );
2458 domains_ids.add( "C" );
2459 domains_ids.add( "D" );
2460 if ( !p.contains( domains_ids, false ) ) {
2463 if ( !p.contains( domains_ids, true ) ) {
2466 domains_ids = new ArrayList<String>();
2467 domains_ids.add( "A" );
2468 domains_ids.add( "D" );
2469 domains_ids.add( "C" );
2470 if ( !p.contains( domains_ids, false ) ) {
2473 if ( p.contains( domains_ids, true ) ) {
2476 domains_ids = new ArrayList<String>();
2477 domains_ids.add( "A" );
2478 domains_ids.add( "A" );
2479 domains_ids.add( "B" );
2480 if ( !p.contains( domains_ids, false ) ) {
2483 if ( !p.contains( domains_ids, true ) ) {
2486 domains_ids = new ArrayList<String>();
2487 domains_ids.add( "A" );
2488 domains_ids.add( "A" );
2489 domains_ids.add( "A" );
2490 domains_ids.add( "B" );
2491 domains_ids.add( "B" );
2492 if ( !p.contains( domains_ids, false ) ) {
2495 if ( !p.contains( domains_ids, true ) ) {
2498 domains_ids = new ArrayList<String>();
2499 domains_ids.add( "A" );
2500 domains_ids.add( "A" );
2501 domains_ids.add( "B" );
2502 domains_ids.add( "A" );
2503 domains_ids.add( "B" );
2504 domains_ids.add( "B" );
2505 domains_ids.add( "A" );
2506 domains_ids.add( "B" );
2507 domains_ids.add( "C" );
2508 domains_ids.add( "A" );
2509 domains_ids.add( "C" );
2510 domains_ids.add( "D" );
2511 if ( !p.contains( domains_ids, false ) ) {
2514 if ( p.contains( domains_ids, true ) ) {
2518 catch ( final Exception e ) {
2519 e.printStackTrace( System.out );
2525 private static boolean testBasicTable() {
2527 final BasicTable<String> t0 = new BasicTable<String>();
2528 if ( t0.getNumberOfColumns() != 0 ) {
2531 if ( t0.getNumberOfRows() != 0 ) {
2534 t0.setValue( 3, 2, "23" );
2535 t0.setValue( 10, 1, "error" );
2536 t0.setValue( 10, 1, "110" );
2537 t0.setValue( 9, 1, "19" );
2538 t0.setValue( 1, 10, "101" );
2539 t0.setValue( 10, 10, "1010" );
2540 t0.setValue( 100, 10, "10100" );
2541 t0.setValue( 0, 0, "00" );
2542 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2545 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2548 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2551 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2554 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2557 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2560 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2563 if ( t0.getNumberOfColumns() != 101 ) {
2566 if ( t0.getNumberOfRows() != 11 ) {
2569 if ( t0.getValueAsString( 49, 4 ) != null ) {
2572 final String l = ForesterUtil.getLineSeparator();
2573 final StringBuffer source = new StringBuffer();
2574 source.append( "" + l );
2575 source.append( "# 1 1 1 1 1 1 1 1" + l );
2576 source.append( " 00 01 02 03" + l );
2577 source.append( " 10 11 12 13 " + l );
2578 source.append( "20 21 22 23 " + l );
2579 source.append( " 30 31 32 33" + l );
2580 source.append( "40 41 42 43" + l );
2581 source.append( " # 1 1 1 1 1 " + l );
2582 source.append( "50 51 52 53 54" + l );
2583 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2584 if ( t1.getNumberOfColumns() != 5 ) {
2587 if ( t1.getNumberOfRows() != 6 ) {
2590 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2593 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2596 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2599 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2602 final StringBuffer source1 = new StringBuffer();
2603 source1.append( "" + l );
2604 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2605 source1.append( " 00; 01 ;02;03" + l );
2606 source1.append( " 10; 11; 12; 13 " + l );
2607 source1.append( "20; 21; 22; 23 " + l );
2608 source1.append( " 30; 31; 32; 33" + l );
2609 source1.append( "40;41;42;43" + l );
2610 source1.append( " # 1 1 1 1 1 " + l );
2611 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2612 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2613 if ( t2.getNumberOfColumns() != 5 ) {
2616 if ( t2.getNumberOfRows() != 6 ) {
2619 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2622 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2625 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2628 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2631 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2634 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2637 final StringBuffer source2 = new StringBuffer();
2638 source2.append( "" + l );
2639 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2640 source2.append( " 00; 01 ;02;03" + l );
2641 source2.append( " 10; 11; 12; 13 " + l );
2642 source2.append( "20; 21; 22; 23 " + l );
2643 source2.append( " " + l );
2644 source2.append( " 30; 31; 32; 33" + l );
2645 source2.append( "40;41;42;43" + l );
2646 source2.append( " comment: 1 1 1 1 1 " + l );
2647 source2.append( ";;;50 ; 52; 53;;54 " + l );
2648 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2654 if ( tl.size() != 2 ) {
2657 final BasicTable<String> t3 = tl.get( 0 );
2658 final BasicTable<String> t4 = tl.get( 1 );
2659 if ( t3.getNumberOfColumns() != 4 ) {
2662 if ( t3.getNumberOfRows() != 3 ) {
2665 if ( t4.getNumberOfColumns() != 4 ) {
2668 if ( t4.getNumberOfRows() != 3 ) {
2671 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2674 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2678 catch ( final Exception e ) {
2679 e.printStackTrace( System.out );
2685 private static boolean testBasicTolXMLparsing() {
2687 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2688 final TolParser parser = new TolParser();
2689 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2690 if ( parser.getErrorCount() > 0 ) {
2691 System.out.println( parser.getErrorMessages().toString() );
2694 if ( phylogenies_0.length != 1 ) {
2697 final Phylogeny t1 = phylogenies_0[ 0 ];
2698 if ( t1.getNumberOfExternalNodes() != 5 ) {
2701 if ( !t1.isRooted() ) {
2704 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2707 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2710 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2713 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2716 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2717 if ( parser.getErrorCount() > 0 ) {
2718 System.out.println( parser.getErrorMessages().toString() );
2721 if ( phylogenies_1.length != 1 ) {
2724 final Phylogeny t2 = phylogenies_1[ 0 ];
2725 if ( t2.getNumberOfExternalNodes() != 664 ) {
2728 if ( !t2.isRooted() ) {
2731 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2734 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2737 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2740 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2743 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2746 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2747 .equals( "Aquifex" ) ) {
2750 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2751 if ( parser.getErrorCount() > 0 ) {
2752 System.out.println( parser.getErrorMessages().toString() );
2755 if ( phylogenies_2.length != 1 ) {
2758 final Phylogeny t3 = phylogenies_2[ 0 ];
2759 if ( t3.getNumberOfExternalNodes() != 184 ) {
2762 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2765 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2768 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2771 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2772 if ( parser.getErrorCount() > 0 ) {
2773 System.out.println( parser.getErrorMessages().toString() );
2776 if ( phylogenies_3.length != 1 ) {
2779 final Phylogeny t4 = phylogenies_3[ 0 ];
2780 if ( t4.getNumberOfExternalNodes() != 1 ) {
2783 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2786 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2789 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2792 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2793 if ( parser.getErrorCount() > 0 ) {
2794 System.out.println( parser.getErrorMessages().toString() );
2797 if ( phylogenies_4.length != 1 ) {
2800 final Phylogeny t5 = phylogenies_4[ 0 ];
2801 if ( t5.getNumberOfExternalNodes() != 13 ) {
2804 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2807 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2810 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2814 catch ( final Exception e ) {
2815 e.printStackTrace( System.out );
2821 private static boolean testBasicTreeMethods() {
2823 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2824 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2825 if ( t2.getNumberOfExternalNodes() != 4 ) {
2828 if ( t2.getHeight() != 8.5 ) {
2831 if ( !t2.isCompletelyBinary() ) {
2834 if ( t2.isEmpty() ) {
2837 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2838 if ( t3.getNumberOfExternalNodes() != 5 ) {
2841 if ( t3.getHeight() != 11 ) {
2844 if ( t3.isCompletelyBinary() ) {
2847 final PhylogenyNode n = t3.getNode( "ABC" );
2848 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 ];
2849 if ( t4.getNumberOfExternalNodes() != 9 ) {
2852 if ( t4.getHeight() != 11 ) {
2855 if ( t4.isCompletelyBinary() ) {
2858 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)" );
2859 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2860 if ( t5.getNumberOfExternalNodes() != 8 ) {
2863 if ( t5.getHeight() != 15 ) {
2866 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)" );
2867 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2868 if ( t6.getHeight() != 15 ) {
2871 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)" );
2872 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2873 if ( t7.getHeight() != 15 ) {
2876 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)" );
2877 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2878 if ( t8.getNumberOfExternalNodes() != 10 ) {
2881 if ( t8.getHeight() != 15 ) {
2884 final char[] a9 = new char[] { 'a' };
2885 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2886 if ( t9.getHeight() != 0 ) {
2889 final char[] a10 = new char[] { 'a', ':', '6' };
2890 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2891 if ( t10.getHeight() != 6 ) {
2895 catch ( final Exception e ) {
2896 e.printStackTrace( System.out );
2902 private static boolean testConfidenceAssessor() {
2904 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2905 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2906 final Phylogeny[] ev0 = factory
2907 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2909 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2910 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2913 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2916 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2917 final Phylogeny[] ev1 = factory
2918 .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)));",
2920 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2921 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2924 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2927 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2928 final Phylogeny[] ev_b = factory
2929 .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",
2931 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2932 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2935 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2939 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2940 final Phylogeny[] ev1x = factory
2941 .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)));",
2943 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2944 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2947 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2950 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2951 final Phylogeny[] ev_bx = factory
2952 .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",
2954 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2955 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2958 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2962 final Phylogeny[] t2 = factory
2963 .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);",
2965 final Phylogeny[] ev2 = factory
2966 .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);",
2968 for( final Phylogeny target : t2 ) {
2969 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2972 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2973 new NHXParser() )[ 0 ];
2974 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2975 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2976 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2979 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2982 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2986 catch ( final Exception e ) {
2987 e.printStackTrace();
2993 private static boolean testCopyOfNodeData() {
2995 final PhylogenyNode n1 = PhylogenyNode
2996 .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]" );
2997 final PhylogenyNode n2 = n1.copyNodeData();
2998 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3002 catch ( final Exception e ) {
3003 e.printStackTrace();
3009 private static boolean testCreateBalancedPhylogeny() {
3011 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3012 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3015 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3018 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3019 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3022 if ( p1.getNumberOfExternalNodes() != 100 ) {
3026 catch ( final Exception e ) {
3027 e.printStackTrace();
3033 private static boolean testCreateUriForSeqWeb() {
3035 final PhylogenyNode n = new PhylogenyNode();
3036 n.setName( "tr|B3RJ64" );
3037 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3040 n.setName( "B0LM41_HUMAN" );
3041 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3044 n.setName( "NP_001025424" );
3045 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3048 n.setName( "_NM_001030253-" );
3049 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3052 n.setName( "XM_002122186" );
3053 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3056 n.setName( "dgh_AAA34956_gdg" );
3057 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3060 n.setName( "AAA34956" );
3061 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3064 n.setName( "GI:394892" );
3065 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3066 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3069 n.setName( "gi_394892" );
3070 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3071 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3074 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3075 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3076 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3079 n.setName( "P12345" );
3080 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3081 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3084 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3085 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3086 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3090 catch ( final Exception e ) {
3091 e.printStackTrace( System.out );
3097 private static boolean testDataObjects() {
3099 final Confidence s0 = new Confidence();
3100 final Confidence s1 = new Confidence();
3101 if ( !s0.isEqual( s1 ) ) {
3104 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3105 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3106 if ( s2.isEqual( s1 ) ) {
3109 if ( !s2.isEqual( s3 ) ) {
3112 final Confidence s4 = ( Confidence ) s3.copy();
3113 if ( !s4.isEqual( s3 ) ) {
3120 final Taxonomy t1 = new Taxonomy();
3121 final Taxonomy t2 = new Taxonomy();
3122 final Taxonomy t3 = new Taxonomy();
3123 final Taxonomy t4 = new Taxonomy();
3124 final Taxonomy t5 = new Taxonomy();
3125 t1.setIdentifier( new Identifier( "ecoli" ) );
3126 t1.setTaxonomyCode( "ECOLI" );
3127 t1.setScientificName( "E. coli" );
3128 t1.setCommonName( "coli" );
3129 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3130 if ( !t1.isEqual( t0 ) ) {
3133 t2.setIdentifier( new Identifier( "ecoli" ) );
3134 t2.setTaxonomyCode( "OTHER" );
3135 t2.setScientificName( "what" );
3136 t2.setCommonName( "something" );
3137 if ( !t1.isEqual( t2 ) ) {
3140 t2.setIdentifier( new Identifier( "nemve" ) );
3141 if ( t1.isEqual( t2 ) ) {
3144 t1.setIdentifier( null );
3145 t3.setTaxonomyCode( "ECOLI" );
3146 t3.setScientificName( "what" );
3147 t3.setCommonName( "something" );
3148 if ( !t1.isEqual( t3 ) ) {
3151 t1.setIdentifier( null );
3152 t1.setTaxonomyCode( "" );
3153 t4.setScientificName( "E. ColI" );
3154 t4.setCommonName( "something" );
3155 if ( !t1.isEqual( t4 ) ) {
3158 t4.setScientificName( "B. subtilis" );
3159 t4.setCommonName( "something" );
3160 if ( t1.isEqual( t4 ) ) {
3163 t1.setIdentifier( null );
3164 t1.setTaxonomyCode( "" );
3165 t1.setScientificName( "" );
3166 t5.setCommonName( "COLI" );
3167 if ( !t1.isEqual( t5 ) ) {
3170 t5.setCommonName( "vibrio" );
3171 if ( t1.isEqual( t5 ) ) {
3176 final Identifier id0 = new Identifier( "123", "pfam" );
3177 final Identifier id1 = ( Identifier ) id0.copy();
3178 if ( !id1.isEqual( id1 ) ) {
3181 if ( !id1.isEqual( id0 ) ) {
3184 if ( !id0.isEqual( id1 ) ) {
3191 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3192 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3193 if ( !pd1.isEqual( pd1 ) ) {
3196 if ( !pd1.isEqual( pd0 ) ) {
3201 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3202 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3203 if ( !pd3.isEqual( pd3 ) ) {
3206 if ( !pd2.isEqual( pd3 ) ) {
3209 if ( !pd0.isEqual( pd3 ) ) {
3214 // DomainArchitecture
3215 // ------------------
3216 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3217 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3218 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3219 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3220 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3221 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3226 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3227 if ( ds0.getNumberOfDomains() != 4 ) {
3230 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3231 if ( !ds0.isEqual( ds0 ) ) {
3234 if ( !ds0.isEqual( ds1 ) ) {
3237 if ( ds1.getNumberOfDomains() != 4 ) {
3240 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3245 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3246 if ( ds0.isEqual( ds2 ) ) {
3252 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3253 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3254 System.out.println( ds3.toNHX() );
3257 if ( ds3.getNumberOfDomains() != 3 ) {
3262 final Event e1 = new Event( Event.EventType.fusion );
3263 if ( e1.isDuplication() ) {
3266 if ( !e1.isFusion() ) {
3269 if ( !e1.asText().toString().equals( "fusion" ) ) {
3272 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3275 final Event e11 = new Event( Event.EventType.fusion );
3276 if ( !e11.isEqual( e1 ) ) {
3279 if ( !e11.toNHX().toString().equals( "" ) ) {
3282 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3283 if ( e2.isDuplication() ) {
3286 if ( !e2.isSpeciationOrDuplication() ) {
3289 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3292 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3295 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3298 if ( e11.isEqual( e2 ) ) {
3301 final Event e2c = ( Event ) e2.copy();
3302 if ( !e2c.isEqual( e2 ) ) {
3305 Event e3 = new Event( 1, 2, 3 );
3306 if ( e3.isDuplication() ) {
3309 if ( e3.isSpeciation() ) {
3312 if ( e3.isGeneLoss() ) {
3315 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3318 final Event e3c = ( Event ) e3.copy();
3319 final Event e3cc = ( Event ) e3c.copy();
3320 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3324 if ( !e3c.isEqual( e3cc ) ) {
3327 Event e4 = new Event( 1, 2, 3 );
3328 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3331 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3334 final Event e4c = ( Event ) e4.copy();
3336 final Event e4cc = ( Event ) e4c.copy();
3337 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3340 if ( !e4c.isEqual( e4cc ) ) {
3343 final Event e5 = new Event();
3344 if ( !e5.isUnassigned() ) {
3347 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3350 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3353 final Event e6 = new Event( 1, 0, 0 );
3354 if ( !e6.asText().toString().equals( "duplication" ) ) {
3357 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3360 final Event e7 = new Event( 0, 1, 0 );
3361 if ( !e7.asText().toString().equals( "speciation" ) ) {
3364 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3367 final Event e8 = new Event( 0, 0, 1 );
3368 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3371 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3375 catch ( final Exception e ) {
3376 e.printStackTrace( System.out );
3382 private static boolean testDeletionOfExternalNodes() {
3384 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3385 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3386 final PhylogenyWriter w = new PhylogenyWriter();
3387 if ( t0.isEmpty() ) {
3390 if ( t0.getNumberOfExternalNodes() != 1 ) {
3393 t0.deleteSubtree( t0.getNode( "A" ), false );
3394 if ( t0.getNumberOfExternalNodes() != 0 ) {
3397 if ( !t0.isEmpty() ) {
3400 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3401 if ( t1.getNumberOfExternalNodes() != 2 ) {
3404 t1.deleteSubtree( t1.getNode( "A" ), false );
3405 if ( t1.getNumberOfExternalNodes() != 1 ) {
3408 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3411 t1.deleteSubtree( t1.getNode( "B" ), false );
3412 if ( t1.getNumberOfExternalNodes() != 1 ) {
3415 t1.deleteSubtree( t1.getNode( "r" ), false );
3416 if ( !t1.isEmpty() ) {
3419 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3420 if ( t2.getNumberOfExternalNodes() != 3 ) {
3423 t2.deleteSubtree( t2.getNode( "B" ), false );
3424 if ( t2.getNumberOfExternalNodes() != 2 ) {
3427 t2.toNewHampshireX();
3428 PhylogenyNode n = t2.getNode( "A" );
3429 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3432 t2.deleteSubtree( t2.getNode( "A" ), false );
3433 if ( t2.getNumberOfExternalNodes() != 2 ) {
3436 t2.deleteSubtree( t2.getNode( "C" ), true );
3437 if ( t2.getNumberOfExternalNodes() != 1 ) {
3440 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3441 if ( t3.getNumberOfExternalNodes() != 4 ) {
3444 t3.deleteSubtree( t3.getNode( "B" ), true );
3445 if ( t3.getNumberOfExternalNodes() != 3 ) {
3448 n = t3.getNode( "A" );
3449 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3452 n = n.getNextExternalNode();
3453 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3456 t3.deleteSubtree( t3.getNode( "A" ), true );
3457 if ( t3.getNumberOfExternalNodes() != 2 ) {
3460 n = t3.getNode( "C" );
3461 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3464 t3.deleteSubtree( t3.getNode( "C" ), true );
3465 if ( t3.getNumberOfExternalNodes() != 1 ) {
3468 t3.deleteSubtree( t3.getNode( "D" ), true );
3469 if ( t3.getNumberOfExternalNodes() != 0 ) {
3472 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3473 if ( t4.getNumberOfExternalNodes() != 6 ) {
3476 t4.deleteSubtree( t4.getNode( "B2" ), true );
3477 if ( t4.getNumberOfExternalNodes() != 5 ) {
3480 String s = w.toNewHampshire( t4, true ).toString();
3481 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3484 t4.deleteSubtree( t4.getNode( "B11" ), true );
3485 if ( t4.getNumberOfExternalNodes() != 4 ) {
3488 t4.deleteSubtree( t4.getNode( "C" ), true );
3489 if ( t4.getNumberOfExternalNodes() != 3 ) {
3492 n = t4.getNode( "A" );
3493 n = n.getNextExternalNode();
3494 if ( !n.getName().equals( "B12" ) ) {
3497 n = n.getNextExternalNode();
3498 if ( !n.getName().equals( "D" ) ) {
3501 s = w.toNewHampshire( t4, true ).toString();
3502 if ( !s.equals( "((A,B12),D);" ) ) {
3505 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3506 t5.deleteSubtree( t5.getNode( "A" ), true );
3507 if ( t5.getNumberOfExternalNodes() != 5 ) {
3510 s = w.toNewHampshire( t5, true ).toString();
3511 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3514 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3515 t6.deleteSubtree( t6.getNode( "B11" ), true );
3516 if ( t6.getNumberOfExternalNodes() != 5 ) {
3519 s = w.toNewHampshire( t6, false ).toString();
3520 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3523 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3524 t7.deleteSubtree( t7.getNode( "B12" ), true );
3525 if ( t7.getNumberOfExternalNodes() != 5 ) {
3528 s = w.toNewHampshire( t7, true ).toString();
3529 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3532 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3533 t8.deleteSubtree( t8.getNode( "B2" ), true );
3534 if ( t8.getNumberOfExternalNodes() != 5 ) {
3537 s = w.toNewHampshire( t8, false ).toString();
3538 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3541 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3542 t9.deleteSubtree( t9.getNode( "C" ), true );
3543 if ( t9.getNumberOfExternalNodes() != 5 ) {
3546 s = w.toNewHampshire( t9, true ).toString();
3547 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3550 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3551 t10.deleteSubtree( t10.getNode( "D" ), true );
3552 if ( t10.getNumberOfExternalNodes() != 5 ) {
3555 s = w.toNewHampshire( t10, true ).toString();
3556 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3559 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3560 t11.deleteSubtree( t11.getNode( "A" ), true );
3561 if ( t11.getNumberOfExternalNodes() != 2 ) {
3564 s = w.toNewHampshire( t11, true ).toString();
3565 if ( !s.equals( "(B,C);" ) ) {
3568 t11.deleteSubtree( t11.getNode( "C" ), true );
3569 if ( t11.getNumberOfExternalNodes() != 1 ) {
3572 s = w.toNewHampshire( t11, false ).toString();
3573 if ( !s.equals( "B;" ) ) {
3576 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3577 t12.deleteSubtree( t12.getNode( "B2" ), true );
3578 if ( t12.getNumberOfExternalNodes() != 8 ) {
3581 s = w.toNewHampshire( t12, true ).toString();
3582 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3585 t12.deleteSubtree( t12.getNode( "B3" ), true );
3586 if ( t12.getNumberOfExternalNodes() != 7 ) {
3589 s = w.toNewHampshire( t12, true ).toString();
3590 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3593 t12.deleteSubtree( t12.getNode( "C3" ), true );
3594 if ( t12.getNumberOfExternalNodes() != 6 ) {
3597 s = w.toNewHampshire( t12, true ).toString();
3598 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3601 t12.deleteSubtree( t12.getNode( "A1" ), true );
3602 if ( t12.getNumberOfExternalNodes() != 5 ) {
3605 s = w.toNewHampshire( t12, true ).toString();
3606 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3609 t12.deleteSubtree( t12.getNode( "B1" ), true );
3610 if ( t12.getNumberOfExternalNodes() != 4 ) {
3613 s = w.toNewHampshire( t12, true ).toString();
3614 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3617 t12.deleteSubtree( t12.getNode( "A3" ), true );
3618 if ( t12.getNumberOfExternalNodes() != 3 ) {
3621 s = w.toNewHampshire( t12, true ).toString();
3622 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3625 t12.deleteSubtree( t12.getNode( "A2" ), true );
3626 if ( t12.getNumberOfExternalNodes() != 2 ) {
3629 s = w.toNewHampshire( t12, true ).toString();
3630 if ( !s.equals( "(C1,C2);" ) ) {
3633 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3634 t13.deleteSubtree( t13.getNode( "D" ), true );
3635 if ( t13.getNumberOfExternalNodes() != 4 ) {
3638 s = w.toNewHampshire( t13, true ).toString();
3639 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3642 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3643 t14.deleteSubtree( t14.getNode( "E" ), true );
3644 if ( t14.getNumberOfExternalNodes() != 5 ) {
3647 s = w.toNewHampshire( t14, true ).toString();
3648 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3651 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3652 t15.deleteSubtree( t15.getNode( "B2" ), true );
3653 if ( t15.getNumberOfExternalNodes() != 11 ) {
3656 t15.deleteSubtree( t15.getNode( "B1" ), true );
3657 if ( t15.getNumberOfExternalNodes() != 10 ) {
3660 t15.deleteSubtree( t15.getNode( "B3" ), true );
3661 if ( t15.getNumberOfExternalNodes() != 9 ) {
3664 t15.deleteSubtree( t15.getNode( "B4" ), true );
3665 if ( t15.getNumberOfExternalNodes() != 8 ) {
3668 t15.deleteSubtree( t15.getNode( "A1" ), true );
3669 if ( t15.getNumberOfExternalNodes() != 7 ) {
3672 t15.deleteSubtree( t15.getNode( "C4" ), true );
3673 if ( t15.getNumberOfExternalNodes() != 6 ) {
3677 catch ( final Exception e ) {
3678 e.printStackTrace( System.out );
3684 private static boolean testDescriptiveStatistics() {
3686 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3687 dss1.addValue( 82 );
3688 dss1.addValue( 78 );
3689 dss1.addValue( 70 );
3690 dss1.addValue( 58 );
3691 dss1.addValue( 42 );
3692 if ( dss1.getN() != 5 ) {
3695 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3698 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3701 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3704 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3707 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3710 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3713 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3716 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3719 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3722 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3725 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3728 dss1.addValue( 123 );
3729 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3732 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3735 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3738 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3739 dss2.addValue( -1.85 );
3740 dss2.addValue( 57.5 );
3741 dss2.addValue( 92.78 );
3742 dss2.addValue( 57.78 );
3743 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3746 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3749 final double[] a = dss2.getDataAsDoubleArray();
3750 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3753 dss2.addValue( -100 );
3754 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3757 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3760 final double[] ds = new double[ 14 ];
3775 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3776 if ( bins.length != 4 ) {
3779 if ( bins[ 0 ] != 2 ) {
3782 if ( bins[ 1 ] != 3 ) {
3785 if ( bins[ 2 ] != 4 ) {
3788 if ( bins[ 3 ] != 5 ) {
3791 final double[] ds1 = new double[ 9 ];
3801 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3802 if ( bins1.length != 4 ) {
3805 if ( bins1[ 0 ] != 2 ) {
3808 if ( bins1[ 1 ] != 3 ) {
3811 if ( bins1[ 2 ] != 0 ) {
3814 if ( bins1[ 3 ] != 4 ) {
3817 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3818 if ( bins1_1.length != 3 ) {
3821 if ( bins1_1[ 0 ] != 3 ) {
3824 if ( bins1_1[ 1 ] != 2 ) {
3827 if ( bins1_1[ 2 ] != 4 ) {
3830 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3831 if ( bins1_2.length != 3 ) {
3834 if ( bins1_2[ 0 ] != 2 ) {
3837 if ( bins1_2[ 1 ] != 2 ) {
3840 if ( bins1_2[ 2 ] != 2 ) {
3843 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3857 dss3.addValue( 10 );
3858 dss3.addValue( 10 );
3859 dss3.addValue( 10 );
3860 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3861 histo.toStringBuffer( 10, '=', 40, 5 );
3862 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3864 catch ( final Exception e ) {
3865 e.printStackTrace( System.out );
3871 private static boolean testDir( final String file ) {
3873 final File f = new File( file );
3874 if ( !f.exists() ) {
3877 if ( !f.isDirectory() ) {
3880 if ( !f.canRead() ) {
3884 catch ( final Exception e ) {
3890 private static boolean testEbiEntryRetrieval() {
3892 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3893 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3894 System.out.println( entry.getAccession() );
3897 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3898 System.out.println( entry.getTaxonomyScientificName() );
3901 if ( !entry.getSequenceName()
3902 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3903 System.out.println( entry.getSequenceName() );
3906 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3907 // System.out.println( entry.getSequenceSymbol() );
3910 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3911 System.out.println( entry.getGeneName() );
3914 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
3915 System.out.println( entry.getTaxonomyIdentifier() );
3918 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
3919 System.out.println( entry.getAnnotations().first().getRefValue() );
3922 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
3923 System.out.println( entry.getAnnotations().first().getRefSource() );
3926 if ( entry.getCrossReferences().size() != 5 ) {
3930 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
3931 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
3934 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
3935 System.out.println( entry1.getTaxonomyScientificName() );
3938 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
3939 System.out.println( entry1.getSequenceName() );
3942 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
3943 System.out.println( entry1.getTaxonomyIdentifier() );
3946 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
3947 System.out.println( entry1.getGeneName() );
3950 if ( entry1.getCrossReferences().size() != 6 ) {
3954 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
3955 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
3958 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3959 System.out.println( entry2.getTaxonomyScientificName() );
3962 if ( !entry2.getSequenceName()
3963 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
3964 System.out.println( entry2.getSequenceName() );
3967 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
3968 System.out.println( entry2.getTaxonomyIdentifier() );
3971 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
3972 System.out.println( entry2.getGeneName() );
3975 if ( entry2.getCrossReferences().size() != 3 ) {
3979 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
3980 if ( !entry3.getAccession().equals( "HM043801" ) ) {
3983 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
3984 System.out.println( entry3.getTaxonomyScientificName() );
3987 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
3988 System.out.println( entry3.getSequenceName() );
3991 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
3992 System.out.println( entry3.getTaxonomyIdentifier() );
3995 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
3996 System.out.println( entry3.getSequenceSymbol() );
3999 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4002 if ( entry3.getCrossReferences().size() != 8 ) {
4007 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4008 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4011 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4012 System.out.println( entry4.getTaxonomyScientificName() );
4015 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4016 System.out.println( entry4.getSequenceName() );
4019 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4020 System.out.println( entry4.getTaxonomyIdentifier() );
4023 if ( !entry4.getGeneName().equals( "ras" ) ) {
4024 System.out.println( entry4.getGeneName() );
4027 // if ( !entry4.getChromosome().equals( "ras" ) ) {
4028 // System.out.println( entry4.getChromosome() );
4031 // if ( !entry4.getMap().equals( "ras" ) ) {
4032 // System.out.println( entry4.getMap() );
4038 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
4039 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
4042 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4043 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4046 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4047 System.out.println( entry5.getTaxonomyScientificName() );
4050 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4051 System.out.println( entry5.getSequenceName() );
4054 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4055 System.out.println( entry5.getTaxonomyIdentifier() );
4059 catch ( final IOException e ) {
4060 System.out.println();
4061 System.out.println( "the following might be due to absence internet connection:" );
4062 e.printStackTrace( System.out );
4065 catch ( final Exception e ) {
4066 e.printStackTrace();
4072 private static boolean testExternalNodeRelatedMethods() {
4074 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4075 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4076 PhylogenyNode n = t1.getNode( "A" );
4077 n = n.getNextExternalNode();
4078 if ( !n.getName().equals( "B" ) ) {
4081 n = n.getNextExternalNode();
4082 if ( !n.getName().equals( "C" ) ) {
4085 n = n.getNextExternalNode();
4086 if ( !n.getName().equals( "D" ) ) {
4089 n = t1.getNode( "B" );
4090 while ( !n.isLastExternalNode() ) {
4091 n = n.getNextExternalNode();
4093 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4094 n = t2.getNode( "A" );
4095 n = n.getNextExternalNode();
4096 if ( !n.getName().equals( "B" ) ) {
4099 n = n.getNextExternalNode();
4100 if ( !n.getName().equals( "C" ) ) {
4103 n = n.getNextExternalNode();
4104 if ( !n.getName().equals( "D" ) ) {
4107 n = t2.getNode( "B" );
4108 while ( !n.isLastExternalNode() ) {
4109 n = n.getNextExternalNode();
4111 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4112 n = t3.getNode( "A" );
4113 n = n.getNextExternalNode();
4114 if ( !n.getName().equals( "B" ) ) {
4117 n = n.getNextExternalNode();
4118 if ( !n.getName().equals( "C" ) ) {
4121 n = n.getNextExternalNode();
4122 if ( !n.getName().equals( "D" ) ) {
4125 n = n.getNextExternalNode();
4126 if ( !n.getName().equals( "E" ) ) {
4129 n = n.getNextExternalNode();
4130 if ( !n.getName().equals( "F" ) ) {
4133 n = n.getNextExternalNode();
4134 if ( !n.getName().equals( "G" ) ) {
4137 n = n.getNextExternalNode();
4138 if ( !n.getName().equals( "H" ) ) {
4141 n = t3.getNode( "B" );
4142 while ( !n.isLastExternalNode() ) {
4143 n = n.getNextExternalNode();
4145 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4146 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4147 final PhylogenyNode node = iter.next();
4149 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4150 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4151 final PhylogenyNode node = iter.next();
4153 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4154 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4155 if ( !iter.next().getName().equals( "A" ) ) {
4158 if ( !iter.next().getName().equals( "B" ) ) {
4161 if ( !iter.next().getName().equals( "C" ) ) {
4164 if ( !iter.next().getName().equals( "D" ) ) {
4167 if ( !iter.next().getName().equals( "E" ) ) {
4170 if ( !iter.next().getName().equals( "F" ) ) {
4173 if ( iter.hasNext() ) {
4177 catch ( final Exception e ) {
4178 e.printStackTrace( System.out );
4184 private static boolean testExtractSNFromNodeName() {
4186 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4189 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4192 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4195 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4196 .equals( "Mus musculus musculus" ) ) {
4199 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4200 .equals( "Mus musculus musculus" ) ) {
4203 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4204 .equals( "Mus musculus musculus" ) ) {
4207 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4208 .equals( "Mus musculus musculus" ) ) {
4211 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4214 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4215 .equals( "Mus musculus musculus" ) ) {
4218 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4219 .equals( "Mus musculus musculus" ) ) {
4222 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4225 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4228 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4231 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4234 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4235 .equals( "Mus musculus musculus" ) ) {
4238 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4241 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4244 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4247 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4250 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4253 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4256 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4259 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4262 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4263 .equals( "Mus musculus" ) ) {
4266 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4267 .equals( "Mus musculus" ) ) {
4270 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4273 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4274 .equals( "Mus musculus musculus" ) ) {
4277 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4278 .equals( "Mus musculus musculus" ) ) {
4281 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4282 .equals( "Mus musculus musculus" ) ) {
4285 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4288 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4289 .equals( "Pilostyles mexicana" ) ) {
4292 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4293 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4296 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4297 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4300 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4301 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4304 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4305 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4308 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4309 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4312 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4313 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4316 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4317 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4320 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4321 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4324 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4325 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4328 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4329 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4332 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4333 .equals( "Escherichia coli (strain K12)" ) ) {
4336 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4337 .equals( "Escherichia coli (strain K12)" ) ) {
4340 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4341 .equals( "Escherichia coli (str. K12)" ) ) {
4344 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4345 .equals( "Escherichia coli (str. K12)" ) ) {
4348 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4349 .equals( "Escherichia coli (str. K12)" ) ) {
4352 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4353 .equals( "Escherichia coli (var. K12)" ) ) {
4356 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4357 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4360 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4361 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4365 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4366 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4369 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4370 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4374 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4375 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4378 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4379 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4382 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4383 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4386 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4389 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4392 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4395 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4396 .equals( "Macrocera sp." ) ) {
4399 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4402 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4403 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4406 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4407 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4410 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4411 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4414 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4415 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4419 catch ( final Exception e ) {
4420 e.printStackTrace( System.out );
4426 private static boolean testExtractTaxonomyCodeFromNodeName() {
4428 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4431 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4432 .equals( "SOYBN" ) ) {
4435 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4436 .equals( "ARATH" ) ) {
4439 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4440 .equals( "ARATH" ) ) {
4443 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4446 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4449 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4452 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4453 .equals( "SOYBN" ) ) {
4456 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4457 .equals( "SOYBN" ) ) {
4460 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4461 .equals( "SOYBN" ) ) {
4464 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4465 .equals( "SOYBN" ) ) {
4468 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4469 .equals( "SOYBN" ) ) {
4472 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4473 .equals( "SOYBN" ) ) {
4476 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4477 .equals( "SOYBN" ) ) {
4480 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4481 .equals( "SOYBN" ) ) {
4484 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4487 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4488 .equals( "SOYBN" ) ) {
4491 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4492 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4495 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4496 .equals( "9YX45" ) ) {
4499 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4500 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4501 .equals( "MOUSE" ) ) {
4504 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4505 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4506 .equals( "MOUSE" ) ) {
4509 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4510 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4511 .equals( "MOUSE" ) ) {
4514 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4515 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4518 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4519 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4522 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4523 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4526 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4527 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4530 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4531 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4534 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4535 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4538 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4539 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4542 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4543 .equals( "RAT" ) ) {
4546 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4547 .equals( "PIG" ) ) {
4551 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4552 .equals( "MOUSE" ) ) {
4555 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4556 .equals( "MOUSE" ) ) {
4559 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4563 catch ( final Exception e ) {
4564 e.printStackTrace( System.out );
4570 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4572 PhylogenyNode n = new PhylogenyNode();
4573 n.setName( "tr|B3RJ64" );
4574 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4577 n.setName( "tr.B3RJ64" );
4578 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4581 n.setName( "tr=B3RJ64" );
4582 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4585 n.setName( "tr-B3RJ64" );
4586 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4589 n.setName( "tr/B3RJ64" );
4590 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4593 n.setName( "tr\\B3RJ64" );
4594 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4597 n.setName( "tr_B3RJ64" );
4598 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4601 n.setName( " tr|B3RJ64 " );
4602 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4605 n.setName( "-tr|B3RJ64-" );
4606 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4609 n.setName( "-tr=B3RJ64-" );
4610 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4613 n.setName( "_tr=B3RJ64_" );
4614 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4617 n.setName( " tr_tr|B3RJ64_sp|123 " );
4618 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4621 n.setName( "B3RJ64" );
4622 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4625 n.setName( "sp|B3RJ64" );
4626 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4629 n.setName( "sp|B3RJ64C" );
4630 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4633 n.setName( "sp B3RJ64" );
4634 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4637 n.setName( "sp|B3RJ6X" );
4638 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4641 n.setName( "sp|B3RJ6" );
4642 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4645 n.setName( "K1PYK7_CRAGI" );
4646 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4649 n.setName( "K1PYK7_PEA" );
4650 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4653 n.setName( "K1PYK7_RAT" );
4654 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4657 n.setName( "K1PYK7_PIG" );
4658 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4661 n.setName( "~K1PYK7_PIG~" );
4662 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4665 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4666 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4669 n.setName( "K1PYKX_CRAGI" );
4670 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4673 n.setName( "XXXXX_CRAGI" );
4674 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4677 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4678 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4681 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4682 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4685 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4686 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4689 n = new PhylogenyNode();
4690 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4691 seq.setSymbol( "K1PYK7_CRAGI" );
4692 n.getNodeData().addSequence( seq );
4693 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4696 seq.setSymbol( "tr|B3RJ64" );
4697 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4700 n = new PhylogenyNode();
4701 seq = new org.forester.phylogeny.data.Sequence();
4702 seq.setName( "K1PYK7_CRAGI" );
4703 n.getNodeData().addSequence( seq );
4704 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4707 seq.setName( "tr|B3RJ64" );
4708 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4711 n = new PhylogenyNode();
4712 seq = new org.forester.phylogeny.data.Sequence();
4713 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4714 n.getNodeData().addSequence( seq );
4715 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4718 n = new PhylogenyNode();
4719 seq = new org.forester.phylogeny.data.Sequence();
4720 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4721 n.getNodeData().addSequence( seq );
4722 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4726 n = new PhylogenyNode();
4727 n.setName( "ACP19736" );
4728 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4731 n = new PhylogenyNode();
4732 n.setName( "|ACP19736|" );
4733 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4737 catch ( final Exception e ) {
4738 e.printStackTrace( System.out );
4744 private static boolean testFastaParser() {
4746 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4749 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4752 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4753 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4756 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4759 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4762 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4765 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4768 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4772 catch ( final Exception e ) {
4773 e.printStackTrace();
4779 private static boolean testGenbankAccessorParsing() {
4780 //The format for GenBank Accession numbers are:
4781 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4782 //Protein: 3 letters + 5 numerals
4783 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4784 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4787 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4790 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4793 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4796 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4799 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4802 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4805 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4808 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4811 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4814 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4817 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4820 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4823 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4829 private static boolean testGeneralMsaParser() {
4831 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4832 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4833 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4834 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4835 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4836 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4837 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4838 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4839 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4842 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4845 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4848 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4851 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4854 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4857 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4860 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4863 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4866 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4869 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4872 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4875 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4876 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4879 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4882 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4885 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4886 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4889 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4892 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4895 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4896 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4899 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4902 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4906 catch ( final Exception e ) {
4907 e.printStackTrace();
4913 private static boolean testGeneralTable() {
4915 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4916 t0.setValue( 3, 2, "23" );
4917 t0.setValue( 10, 1, "error" );
4918 t0.setValue( 10, 1, "110" );
4919 t0.setValue( 9, 1, "19" );
4920 t0.setValue( 1, 10, "101" );
4921 t0.setValue( 10, 10, "1010" );
4922 t0.setValue( 100, 10, "10100" );
4923 t0.setValue( 0, 0, "00" );
4924 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4927 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4930 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4933 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4936 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4939 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4942 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4945 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4948 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4951 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4952 t1.setValue( "3", "2", "23" );
4953 t1.setValue( "10", "1", "error" );
4954 t1.setValue( "10", "1", "110" );
4955 t1.setValue( "9", "1", "19" );
4956 t1.setValue( "1", "10", "101" );
4957 t1.setValue( "10", "10", "1010" );
4958 t1.setValue( "100", "10", "10100" );
4959 t1.setValue( "0", "0", "00" );
4960 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4961 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4964 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4967 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4970 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4973 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4976 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4979 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4982 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4985 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4988 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4992 catch ( final Exception e ) {
4993 e.printStackTrace( System.out );
4999 private static boolean testGetDistance() {
5001 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5002 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",
5003 new NHXParser() )[ 0 ];
5004 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5007 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5010 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5013 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5016 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5019 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5022 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5025 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5028 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5031 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5034 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5037 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5040 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5043 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5046 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5049 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5052 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5055 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5058 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5061 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5064 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5067 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5070 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5073 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5076 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5079 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5082 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5085 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5088 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5091 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5094 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5097 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",
5098 new NHXParser() )[ 0 ];
5099 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5102 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5105 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5108 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5111 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5114 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5117 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5120 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5123 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5126 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5129 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5133 catch ( final Exception e ) {
5134 e.printStackTrace( System.out );
5140 private static boolean testGetLCA() {
5142 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5143 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5144 new NHXParser() )[ 0 ];
5145 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5146 if ( !A.getName().equals( "A" ) ) {
5149 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5150 if ( !gh.getName().equals( "gh" ) ) {
5153 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5154 if ( !ab.getName().equals( "ab" ) ) {
5157 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5158 if ( !ab2.getName().equals( "ab" ) ) {
5161 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5162 if ( !gh2.getName().equals( "gh" ) ) {
5165 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5166 if ( !gh3.getName().equals( "gh" ) ) {
5169 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5170 if ( !abc.getName().equals( "abc" ) ) {
5173 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5174 if ( !abc2.getName().equals( "abc" ) ) {
5177 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5178 if ( !abcd.getName().equals( "abcd" ) ) {
5181 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5182 if ( !abcd2.getName().equals( "abcd" ) ) {
5185 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5186 if ( !abcdef.getName().equals( "abcdef" ) ) {
5189 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5190 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5193 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5194 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5197 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5198 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5201 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5202 if ( !abcde.getName().equals( "abcde" ) ) {
5205 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5206 if ( !abcde2.getName().equals( "abcde" ) ) {
5209 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5210 if ( !r.getName().equals( "abcdefgh" ) ) {
5213 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5214 if ( !r2.getName().equals( "abcdefgh" ) ) {
5217 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5218 if ( !r3.getName().equals( "abcdefgh" ) ) {
5221 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5222 if ( !abcde3.getName().equals( "abcde" ) ) {
5225 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5226 if ( !abcde4.getName().equals( "abcde" ) ) {
5229 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5230 if ( !ab3.getName().equals( "ab" ) ) {
5233 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5234 if ( !ab4.getName().equals( "ab" ) ) {
5237 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5238 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5239 if ( !cd.getName().equals( "cd" ) ) {
5242 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5243 if ( !cd2.getName().equals( "cd" ) ) {
5246 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5247 if ( !cde.getName().equals( "cde" ) ) {
5250 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5251 if ( !cde2.getName().equals( "cde" ) ) {
5254 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5255 if ( !cdef.getName().equals( "cdef" ) ) {
5258 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5259 if ( !cdef2.getName().equals( "cdef" ) ) {
5262 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5263 if ( !cdef3.getName().equals( "cdef" ) ) {
5266 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5267 if ( !rt.getName().equals( "r" ) ) {
5270 final Phylogeny p3 = factory
5271 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5272 new NHXParser() )[ 0 ];
5273 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5274 if ( !bc_3.getName().equals( "bc" ) ) {
5277 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5278 if ( !ac_3.getName().equals( "abc" ) ) {
5281 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5282 if ( !ad_3.getName().equals( "abcde" ) ) {
5285 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5286 if ( !af_3.getName().equals( "abcdef" ) ) {
5289 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5290 if ( !ag_3.getName().equals( "" ) ) {
5293 if ( !ag_3.isRoot() ) {
5296 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5297 if ( !al_3.getName().equals( "" ) ) {
5300 if ( !al_3.isRoot() ) {
5303 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5304 if ( !kl_3.getName().equals( "" ) ) {
5307 if ( !kl_3.isRoot() ) {
5310 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5311 if ( !fl_3.getName().equals( "" ) ) {
5314 if ( !fl_3.isRoot() ) {
5317 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5318 if ( !gk_3.getName().equals( "ghijk" ) ) {
5321 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5322 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5323 if ( !r_4.getName().equals( "r" ) ) {
5326 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5327 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5328 if ( !r_5.getName().equals( "root" ) ) {
5331 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5332 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5333 if ( !r_6.getName().equals( "rot" ) ) {
5336 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5337 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5338 if ( !r_7.getName().equals( "rott" ) ) {
5342 catch ( final Exception e ) {
5343 e.printStackTrace( System.out );
5349 private static boolean testGetLCA2() {
5351 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5352 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5353 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5354 PhylogenyMethods.preOrderReId( p_a );
5355 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5356 p_a.getNode( "a" ) );
5357 if ( !p_a_1.getName().equals( "a" ) ) {
5360 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5361 PhylogenyMethods.preOrderReId( p_b );
5362 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5363 p_b.getNode( "a" ) );
5364 if ( !p_b_1.getName().equals( "b" ) ) {
5367 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5368 p_b.getNode( "b" ) );
5369 if ( !p_b_2.getName().equals( "b" ) ) {
5372 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5373 PhylogenyMethods.preOrderReId( p_c );
5374 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5375 p_c.getNode( "a" ) );
5376 if ( !p_c_1.getName().equals( "b" ) ) {
5379 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5380 p_c.getNode( "c" ) );
5381 if ( !p_c_2.getName().equals( "c" ) ) {
5382 System.out.println( p_c_2.getName() );
5386 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5387 p_c.getNode( "b" ) );
5388 if ( !p_c_3.getName().equals( "b" ) ) {
5391 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5392 p_c.getNode( "a" ) );
5393 if ( !p_c_4.getName().equals( "c" ) ) {
5396 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5397 new NHXParser() )[ 0 ];
5398 PhylogenyMethods.preOrderReId( p1 );
5399 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5400 p1.getNode( "A" ) );
5401 if ( !A.getName().equals( "A" ) ) {
5404 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5405 p1.getNode( "gh" ) );
5406 if ( !gh.getName().equals( "gh" ) ) {
5409 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5410 p1.getNode( "B" ) );
5411 if ( !ab.getName().equals( "ab" ) ) {
5414 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5415 p1.getNode( "A" ) );
5416 if ( !ab2.getName().equals( "ab" ) ) {
5419 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5420 p1.getNode( "G" ) );
5421 if ( !gh2.getName().equals( "gh" ) ) {
5424 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5425 p1.getNode( "H" ) );
5426 if ( !gh3.getName().equals( "gh" ) ) {
5429 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5430 p1.getNode( "A" ) );
5431 if ( !abc.getName().equals( "abc" ) ) {
5434 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5435 p1.getNode( "C" ) );
5436 if ( !abc2.getName().equals( "abc" ) ) {
5439 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5440 p1.getNode( "D" ) );
5441 if ( !abcd.getName().equals( "abcd" ) ) {
5444 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5445 p1.getNode( "A" ) );
5446 if ( !abcd2.getName().equals( "abcd" ) ) {
5449 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5450 p1.getNode( "F" ) );
5451 if ( !abcdef.getName().equals( "abcdef" ) ) {
5454 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5455 p1.getNode( "A" ) );
5456 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5459 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5460 p1.getNode( "F" ) );
5461 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5464 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5465 p1.getNode( "ab" ) );
5466 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5469 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5470 p1.getNode( "E" ) );
5471 if ( !abcde.getName().equals( "abcde" ) ) {
5474 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5475 p1.getNode( "A" ) );
5476 if ( !abcde2.getName().equals( "abcde" ) ) {
5479 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5480 p1.getNode( "abcdefgh" ) );
5481 if ( !r.getName().equals( "abcdefgh" ) ) {
5484 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5485 p1.getNode( "H" ) );
5486 if ( !r2.getName().equals( "abcdefgh" ) ) {
5489 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5490 p1.getNode( "A" ) );
5491 if ( !r3.getName().equals( "abcdefgh" ) ) {
5494 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5495 p1.getNode( "abcde" ) );
5496 if ( !abcde3.getName().equals( "abcde" ) ) {
5499 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5500 p1.getNode( "E" ) );
5501 if ( !abcde4.getName().equals( "abcde" ) ) {
5504 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5505 p1.getNode( "B" ) );
5506 if ( !ab3.getName().equals( "ab" ) ) {
5509 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5510 p1.getNode( "ab" ) );
5511 if ( !ab4.getName().equals( "ab" ) ) {
5514 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5515 PhylogenyMethods.preOrderReId( p2 );
5516 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5517 p2.getNode( "d" ) );
5518 if ( !cd.getName().equals( "cd" ) ) {
5521 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5522 p2.getNode( "c" ) );
5523 if ( !cd2.getName().equals( "cd" ) ) {
5526 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5527 p2.getNode( "e" ) );
5528 if ( !cde.getName().equals( "cde" ) ) {
5531 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5532 p2.getNode( "c" ) );
5533 if ( !cde2.getName().equals( "cde" ) ) {
5536 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5537 p2.getNode( "f" ) );
5538 if ( !cdef.getName().equals( "cdef" ) ) {
5541 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5542 p2.getNode( "f" ) );
5543 if ( !cdef2.getName().equals( "cdef" ) ) {
5546 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5547 p2.getNode( "d" ) );
5548 if ( !cdef3.getName().equals( "cdef" ) ) {
5551 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5552 p2.getNode( "a" ) );
5553 if ( !rt.getName().equals( "r" ) ) {
5556 final Phylogeny p3 = factory
5557 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5558 new NHXParser() )[ 0 ];
5559 PhylogenyMethods.preOrderReId( p3 );
5560 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5561 p3.getNode( "c" ) );
5562 if ( !bc_3.getName().equals( "bc" ) ) {
5565 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5566 p3.getNode( "c" ) );
5567 if ( !ac_3.getName().equals( "abc" ) ) {
5570 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5571 p3.getNode( "d" ) );
5572 if ( !ad_3.getName().equals( "abcde" ) ) {
5575 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5576 p3.getNode( "f" ) );
5577 if ( !af_3.getName().equals( "abcdef" ) ) {
5580 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5581 p3.getNode( "g" ) );
5582 if ( !ag_3.getName().equals( "" ) ) {
5585 if ( !ag_3.isRoot() ) {
5588 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5589 p3.getNode( "l" ) );
5590 if ( !al_3.getName().equals( "" ) ) {
5593 if ( !al_3.isRoot() ) {
5596 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5597 p3.getNode( "l" ) );
5598 if ( !kl_3.getName().equals( "" ) ) {
5601 if ( !kl_3.isRoot() ) {
5604 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5605 p3.getNode( "l" ) );
5606 if ( !fl_3.getName().equals( "" ) ) {
5609 if ( !fl_3.isRoot() ) {
5612 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5613 p3.getNode( "k" ) );
5614 if ( !gk_3.getName().equals( "ghijk" ) ) {
5617 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5618 PhylogenyMethods.preOrderReId( p4 );
5619 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5620 p4.getNode( "c" ) );
5621 if ( !r_4.getName().equals( "r" ) ) {
5624 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5625 PhylogenyMethods.preOrderReId( p5 );
5626 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5627 p5.getNode( "c" ) );
5628 if ( !r_5.getName().equals( "root" ) ) {
5631 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5632 PhylogenyMethods.preOrderReId( p6 );
5633 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5634 p6.getNode( "a" ) );
5635 if ( !r_6.getName().equals( "rot" ) ) {
5638 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5639 PhylogenyMethods.preOrderReId( p7 );
5640 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5641 p7.getNode( "e" ) );
5642 if ( !r_7.getName().equals( "rott" ) ) {
5645 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5646 p7.getNode( "a" ) );
5647 if ( !r_71.getName().equals( "rott" ) ) {
5650 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5651 p7.getNode( "rott" ) );
5652 if ( !r_72.getName().equals( "rott" ) ) {
5655 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5656 p7.getNode( "a" ) );
5657 if ( !r_73.getName().equals( "rott" ) ) {
5660 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5661 p7.getNode( "rott" ) );
5662 if ( !r_74.getName().equals( "rott" ) ) {
5665 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5666 p7.getNode( "e" ) );
5667 if ( !r_75.getName().equals( "e" ) ) {
5671 catch ( final Exception e ) {
5672 e.printStackTrace( System.out );
5678 private static boolean testHmmscanOutputParser() {
5679 final String test_dir = Test.PATH_TO_TEST_DATA;
5681 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5682 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5684 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5685 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5686 final List<Protein> proteins = parser2.parse();
5687 if ( parser2.getProteinsEncountered() != 4 ) {
5690 if ( proteins.size() != 4 ) {
5693 if ( parser2.getDomainsEncountered() != 69 ) {
5696 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5699 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5702 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5705 final Protein p1 = proteins.get( 0 );
5706 if ( p1.getNumberOfProteinDomains() != 15 ) {
5709 if ( p1.getLength() != 850 ) {
5712 final Protein p2 = proteins.get( 1 );
5713 if ( p2.getNumberOfProteinDomains() != 51 ) {
5716 if ( p2.getLength() != 1291 ) {
5719 final Protein p3 = proteins.get( 2 );
5720 if ( p3.getNumberOfProteinDomains() != 2 ) {
5723 final Protein p4 = proteins.get( 3 );
5724 if ( p4.getNumberOfProteinDomains() != 1 ) {
5727 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5730 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5733 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5736 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5739 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5742 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5745 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5749 catch ( final Exception e ) {
5750 e.printStackTrace( System.out );
5756 private static boolean testLastExternalNodeMethods() {
5758 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5759 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5760 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5761 final PhylogenyNode n1 = t0.getNode( "A" );
5762 if ( n1.isLastExternalNode() ) {
5765 final PhylogenyNode n2 = t0.getNode( "B" );
5766 if ( n2.isLastExternalNode() ) {
5769 final PhylogenyNode n3 = t0.getNode( "C" );
5770 if ( n3.isLastExternalNode() ) {
5773 final PhylogenyNode n4 = t0.getNode( "D" );
5774 if ( !n4.isLastExternalNode() ) {
5778 catch ( final Exception e ) {
5779 e.printStackTrace( System.out );
5785 private static boolean testLevelOrderIterator() {
5787 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5788 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5789 PhylogenyNodeIterator it0;
5790 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5793 for( it0.reset(); it0.hasNext(); ) {
5796 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5797 if ( !it.next().getName().equals( "r" ) ) {
5800 if ( !it.next().getName().equals( "ab" ) ) {
5803 if ( !it.next().getName().equals( "cd" ) ) {
5806 if ( !it.next().getName().equals( "A" ) ) {
5809 if ( !it.next().getName().equals( "B" ) ) {
5812 if ( !it.next().getName().equals( "C" ) ) {
5815 if ( !it.next().getName().equals( "D" ) ) {
5818 if ( it.hasNext() ) {
5821 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",
5822 new NHXParser() )[ 0 ];
5823 PhylogenyNodeIterator it2;
5824 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5827 for( it2.reset(); it2.hasNext(); ) {
5830 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5831 if ( !it3.next().getName().equals( "r" ) ) {
5834 if ( !it3.next().getName().equals( "abc" ) ) {
5837 if ( !it3.next().getName().equals( "defg" ) ) {
5840 if ( !it3.next().getName().equals( "A" ) ) {
5843 if ( !it3.next().getName().equals( "B" ) ) {
5846 if ( !it3.next().getName().equals( "C" ) ) {
5849 if ( !it3.next().getName().equals( "D" ) ) {
5852 if ( !it3.next().getName().equals( "E" ) ) {
5855 if ( !it3.next().getName().equals( "F" ) ) {
5858 if ( !it3.next().getName().equals( "G" ) ) {
5861 if ( !it3.next().getName().equals( "1" ) ) {
5864 if ( !it3.next().getName().equals( "2" ) ) {
5867 if ( !it3.next().getName().equals( "3" ) ) {
5870 if ( !it3.next().getName().equals( "4" ) ) {
5873 if ( !it3.next().getName().equals( "5" ) ) {
5876 if ( !it3.next().getName().equals( "6" ) ) {
5879 if ( !it3.next().getName().equals( "f1" ) ) {
5882 if ( !it3.next().getName().equals( "f2" ) ) {
5885 if ( !it3.next().getName().equals( "f3" ) ) {
5888 if ( !it3.next().getName().equals( "a" ) ) {
5891 if ( !it3.next().getName().equals( "b" ) ) {
5894 if ( !it3.next().getName().equals( "f21" ) ) {
5897 if ( !it3.next().getName().equals( "X" ) ) {
5900 if ( !it3.next().getName().equals( "Y" ) ) {
5903 if ( !it3.next().getName().equals( "Z" ) ) {
5906 if ( it3.hasNext() ) {
5909 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5910 PhylogenyNodeIterator it4;
5911 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5914 for( it4.reset(); it4.hasNext(); ) {
5917 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5918 if ( !it5.next().getName().equals( "r" ) ) {
5921 if ( !it5.next().getName().equals( "A" ) ) {
5924 if ( !it5.next().getName().equals( "B" ) ) {
5927 if ( !it5.next().getName().equals( "C" ) ) {
5930 if ( !it5.next().getName().equals( "D" ) ) {
5933 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5934 PhylogenyNodeIterator it6;
5935 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5938 for( it6.reset(); it6.hasNext(); ) {
5941 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5942 if ( !it7.next().getName().equals( "A" ) ) {
5945 if ( it.hasNext() ) {
5949 catch ( final Exception e ) {
5950 e.printStackTrace( System.out );
5956 private static boolean testMafft( final String path ) {
5958 final List<String> opts = new ArrayList<String>();
5959 opts.add( "--maxiterate" );
5961 opts.add( "--localpair" );
5962 opts.add( "--quiet" );
5964 final MsaInferrer mafft = Mafft.createInstance( path );
5965 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5966 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5969 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5973 catch ( final Exception e ) {
5974 e.printStackTrace( System.out );
5980 private static boolean testMidpointrooting() {
5982 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5983 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5984 PhylogenyMethods.midpointRoot( t0 );
5985 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5988 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5991 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5995 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",
5996 new NHXParser() )[ 0 ];
5997 if ( !t1.isRooted() ) {
6000 PhylogenyMethods.midpointRoot( t1 );
6001 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6004 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6007 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6010 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6013 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6016 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6019 t1.reRoot( t1.getNode( "A" ) );
6020 PhylogenyMethods.midpointRoot( t1 );
6021 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6024 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6027 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6030 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6033 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6037 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6041 catch ( final Exception e ) {
6042 e.printStackTrace( System.out );
6048 private static boolean testMsaQualityMethod() {
6050 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6051 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6052 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6053 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6054 final List<Sequence> l = new ArrayList<Sequence>();
6059 final Msa msa = BasicMsa.createInstance( l );
6060 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6063 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6066 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6069 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6072 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6075 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6078 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6082 catch ( final Exception e ) {
6083 e.printStackTrace( System.out );
6089 private static boolean testDeleteableMsa() {
6091 final Sequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6092 final Sequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6093 final Sequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6094 final Sequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6095 final Sequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6096 final Sequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6097 final List<Sequence> l0 = new ArrayList<Sequence>();
6104 final Msa msa0 = BasicMsa.createInstance( l0 );
6105 final DeleteableMsa dmsa0 = new DeleteableMsa( ( BasicMsa ) msa0 );
6106 dmsa0.deleteRow( "b" );
6107 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6110 System.out.println();
6111 System.out.println( dmsa0.toString() );
6112 dmsa0.deleteRow( "e" );
6113 System.out.println();
6114 System.out.println( dmsa0.toString() );
6115 dmsa0.deleteRow( "a" );
6116 System.out.println();
6117 System.out.println( dmsa0.toString() );
6118 dmsa0.deleteRow( "f" );
6119 System.out.println();
6120 System.out.println( dmsa0.toString() );
6122 if ( dmsa0.getLength() != 4 ) {
6125 if ( dmsa0.getNumberOfSequences() != 2 ) {
6129 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6132 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6135 if ( dmsa0.getResidueAt( 0, 0 ) != 'C') {
6138 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" )) {
6141 if ( dmsa0.getColumnAt( 0 ).size() !=2 ) {
6144 dmsa0.deleteRow( "c" );
6145 dmsa0.deleteRow( "d" );
6146 if ( dmsa0.getNumberOfSequences() != 0 ) {
6150 final Sequence s_0 = BasicSequence.createAaSequence( "a", "--A---A-A---" );
6151 final Sequence s_1 = BasicSequence.createAaSequence( "b", "--B-----A---" );
6152 final Sequence s_2 = BasicSequence.createAaSequence( "c", "--C--AA-A---" );
6153 final Sequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-A---" );
6154 final Sequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-A---" );
6155 final Sequence s_5 = BasicSequence.createAaSequence( "f", "--F--AA-AA--" );
6156 final List<Sequence> l1 = new ArrayList<Sequence>();
6163 final Msa msa1 = BasicMsa.createInstance( l1 );
6164 final DeleteableMsa dmsa1 = new DeleteableMsa( ( BasicMsa ) msa1 );
6165 System.out.println( dmsa1.toString() );
6166 MsaMethods.removeGapColumns( 1, dmsa1 );
6167 System.out.println( dmsa1.toString() );
6170 catch ( final Exception e ) {
6171 e.printStackTrace( System.out );
6177 private static boolean testNextNodeWithCollapsing() {
6179 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6181 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6182 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6183 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6184 t0.getNode( "cd" ).setCollapse( true );
6185 t0.getNode( "cde" ).setCollapse( true );
6186 n = t0.getFirstExternalNode();
6187 while ( n != null ) {
6189 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6191 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6194 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6197 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6200 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6203 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6206 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6210 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6211 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6212 t1.getNode( "ab" ).setCollapse( true );
6213 t1.getNode( "cd" ).setCollapse( true );
6214 t1.getNode( "cde" ).setCollapse( true );
6215 n = t1.getNode( "ab" );
6216 ext = new ArrayList<PhylogenyNode>();
6217 while ( n != null ) {
6219 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6221 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6224 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6227 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6230 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6233 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6239 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6240 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6241 t2.getNode( "ab" ).setCollapse( true );
6242 t2.getNode( "cd" ).setCollapse( true );
6243 t2.getNode( "cde" ).setCollapse( true );
6244 t2.getNode( "c" ).setCollapse( true );
6245 t2.getNode( "d" ).setCollapse( true );
6246 t2.getNode( "e" ).setCollapse( true );
6247 t2.getNode( "gh" ).setCollapse( true );
6248 n = t2.getNode( "ab" );
6249 ext = new ArrayList<PhylogenyNode>();
6250 while ( n != null ) {
6252 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6254 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6257 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6260 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6263 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6269 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6270 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6271 t3.getNode( "ab" ).setCollapse( true );
6272 t3.getNode( "cd" ).setCollapse( true );
6273 t3.getNode( "cde" ).setCollapse( true );
6274 t3.getNode( "c" ).setCollapse( true );
6275 t3.getNode( "d" ).setCollapse( true );
6276 t3.getNode( "e" ).setCollapse( true );
6277 t3.getNode( "gh" ).setCollapse( true );
6278 t3.getNode( "fgh" ).setCollapse( true );
6279 n = t3.getNode( "ab" );
6280 ext = new ArrayList<PhylogenyNode>();
6281 while ( n != null ) {
6283 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6285 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6288 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6291 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6297 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6298 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6299 t4.getNode( "ab" ).setCollapse( true );
6300 t4.getNode( "cd" ).setCollapse( true );
6301 t4.getNode( "cde" ).setCollapse( true );
6302 t4.getNode( "c" ).setCollapse( true );
6303 t4.getNode( "d" ).setCollapse( true );
6304 t4.getNode( "e" ).setCollapse( true );
6305 t4.getNode( "gh" ).setCollapse( true );
6306 t4.getNode( "fgh" ).setCollapse( true );
6307 t4.getNode( "abcdefgh" ).setCollapse( true );
6308 n = t4.getNode( "abcdefgh" );
6309 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6314 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6315 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6317 n = t5.getFirstExternalNode();
6318 while ( n != null ) {
6320 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6322 if ( ext.size() != 8 ) {
6325 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6328 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6331 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6334 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6337 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6340 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6343 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6346 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6351 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6352 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6354 t6.getNode( "ab" ).setCollapse( true );
6355 n = t6.getNode( "ab" );
6356 while ( n != null ) {
6358 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6360 if ( ext.size() != 7 ) {
6363 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6366 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6369 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6372 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6375 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6378 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6381 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6386 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6387 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6389 t7.getNode( "cd" ).setCollapse( true );
6390 n = t7.getNode( "a" );
6391 while ( n != null ) {
6393 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6395 if ( ext.size() != 7 ) {
6398 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6401 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6404 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6407 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6410 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6413 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6416 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6421 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6422 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6424 t8.getNode( "cd" ).setCollapse( true );
6425 t8.getNode( "c" ).setCollapse( true );
6426 t8.getNode( "d" ).setCollapse( true );
6427 n = t8.getNode( "a" );
6428 while ( n != null ) {
6430 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6432 if ( ext.size() != 7 ) {
6435 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6438 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6441 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6442 System.out.println( "2 fail" );
6445 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6448 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6451 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6454 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6459 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6460 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6462 t9.getNode( "gh" ).setCollapse( true );
6463 n = t9.getNode( "a" );
6464 while ( n != null ) {
6466 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6468 if ( ext.size() != 7 ) {
6471 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6474 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6477 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6480 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6483 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6486 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6489 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6494 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6495 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6497 t10.getNode( "gh" ).setCollapse( true );
6498 t10.getNode( "g" ).setCollapse( true );
6499 t10.getNode( "h" ).setCollapse( true );
6500 n = t10.getNode( "a" );
6501 while ( n != null ) {
6503 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6505 if ( ext.size() != 7 ) {
6508 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6511 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6514 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6517 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6520 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6523 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6526 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6531 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6532 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6534 t11.getNode( "gh" ).setCollapse( true );
6535 t11.getNode( "fgh" ).setCollapse( true );
6536 n = t11.getNode( "a" );
6537 while ( n != null ) {
6539 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6541 if ( ext.size() != 6 ) {
6544 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6547 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6550 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6553 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6556 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6559 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6564 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6565 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6567 t12.getNode( "gh" ).setCollapse( true );
6568 t12.getNode( "fgh" ).setCollapse( true );
6569 t12.getNode( "g" ).setCollapse( true );
6570 t12.getNode( "h" ).setCollapse( true );
6571 t12.getNode( "f" ).setCollapse( true );
6572 n = t12.getNode( "a" );
6573 while ( n != null ) {
6575 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6577 if ( ext.size() != 6 ) {
6580 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6583 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6586 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6589 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6592 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6595 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6600 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6601 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6603 t13.getNode( "ab" ).setCollapse( true );
6604 t13.getNode( "b" ).setCollapse( true );
6605 t13.getNode( "fgh" ).setCollapse( true );
6606 t13.getNode( "gh" ).setCollapse( true );
6607 n = t13.getNode( "ab" );
6608 while ( n != null ) {
6610 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6612 if ( ext.size() != 5 ) {
6615 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6618 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6621 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6624 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6627 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6632 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6633 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6635 t14.getNode( "ab" ).setCollapse( true );
6636 t14.getNode( "a" ).setCollapse( true );
6637 t14.getNode( "fgh" ).setCollapse( true );
6638 t14.getNode( "gh" ).setCollapse( true );
6639 n = t14.getNode( "ab" );
6640 while ( n != null ) {
6642 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6644 if ( ext.size() != 5 ) {
6647 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6650 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6653 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6656 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6659 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6664 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" );
6665 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6667 t15.getNode( "ab" ).setCollapse( true );
6668 t15.getNode( "a" ).setCollapse( true );
6669 t15.getNode( "fgh" ).setCollapse( true );
6670 t15.getNode( "gh" ).setCollapse( true );
6671 n = t15.getNode( "ab" );
6672 while ( n != null ) {
6674 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6676 if ( ext.size() != 6 ) {
6679 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6682 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6685 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6688 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6691 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6694 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6699 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" );
6700 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6702 t16.getNode( "ab" ).setCollapse( true );
6703 t16.getNode( "a" ).setCollapse( true );
6704 t16.getNode( "fgh" ).setCollapse( true );
6705 t16.getNode( "gh" ).setCollapse( true );
6706 t16.getNode( "cd" ).setCollapse( true );
6707 t16.getNode( "cde" ).setCollapse( true );
6708 t16.getNode( "d" ).setCollapse( true );
6709 t16.getNode( "x" ).setCollapse( true );
6710 n = t16.getNode( "ab" );
6711 while ( n != null ) {
6713 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6715 if ( ext.size() != 4 ) {
6718 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6721 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6724 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6727 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6731 catch ( final Exception e ) {
6732 e.printStackTrace( System.out );
6738 private static boolean testNexusCharactersParsing() {
6740 final NexusCharactersParser parser = new NexusCharactersParser();
6741 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6743 String[] labels = parser.getCharStateLabels();
6744 if ( labels.length != 7 ) {
6747 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6750 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6753 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6756 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6759 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6762 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6765 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6768 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6770 labels = parser.getCharStateLabels();
6771 if ( labels.length != 7 ) {
6774 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6777 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6780 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6783 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6786 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6789 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6792 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6796 catch ( final Exception e ) {
6797 e.printStackTrace( System.out );
6803 private static boolean testNexusMatrixParsing() {
6805 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6806 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6808 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6809 if ( m.getNumberOfCharacters() != 9 ) {
6812 if ( m.getNumberOfIdentifiers() != 5 ) {
6815 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6818 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6821 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6824 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6827 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6830 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6833 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6836 // if ( labels.length != 7 ) {
6839 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6842 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6845 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6848 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6851 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6854 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6857 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6860 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6862 // labels = parser.getCharStateLabels();
6863 // if ( labels.length != 7 ) {
6866 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6869 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6872 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6875 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6878 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6881 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6884 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6888 catch ( final Exception e ) {
6889 e.printStackTrace( System.out );
6895 private static boolean testNexusTreeParsing() {
6897 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6898 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6899 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6900 if ( phylogenies.length != 1 ) {
6903 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6906 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6910 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6911 if ( phylogenies.length != 1 ) {
6914 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6917 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6921 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6922 if ( phylogenies.length != 1 ) {
6925 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6928 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6931 if ( phylogenies[ 0 ].isRooted() ) {
6935 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
6936 if ( phylogenies.length != 18 ) {
6939 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6942 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
6945 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
6948 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
6951 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6954 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
6957 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
6960 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
6963 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
6966 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
6969 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
6972 if ( phylogenies[ 8 ].isRooted() ) {
6975 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
6978 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
6981 if ( !phylogenies[ 9 ].isRooted() ) {
6984 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
6987 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
6990 if ( !phylogenies[ 10 ].isRooted() ) {
6993 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
6996 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
6999 if ( phylogenies[ 11 ].isRooted() ) {
7002 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7005 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7008 if ( !phylogenies[ 12 ].isRooted() ) {
7011 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7014 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7017 if ( !phylogenies[ 13 ].isRooted() ) {
7020 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7023 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7026 if ( !phylogenies[ 14 ].isRooted() ) {
7029 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7032 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7035 if ( phylogenies[ 15 ].isRooted() ) {
7038 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7041 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7044 if ( !phylogenies[ 16 ].isRooted() ) {
7047 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7050 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7053 if ( phylogenies[ 17 ].isRooted() ) {
7056 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7059 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7061 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7062 if ( phylogenies.length != 9 ) {
7065 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7066 .getDistanceToParent() ) ) {
7069 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7070 .getDistanceToParent() ) ) {
7073 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7076 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7079 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7082 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7085 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7089 catch ( final Exception e ) {
7090 e.printStackTrace( System.out );
7096 private static boolean testNexusTreeParsingIterating() {
7098 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7099 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7100 if ( !p.hasNext() ) {
7103 Phylogeny phy = p.next();
7104 if ( phy == null ) {
7107 if ( phy.getNumberOfExternalNodes() != 25 ) {
7110 if ( !phy.getName().equals( "" ) ) {
7113 if ( p.hasNext() ) {
7117 if ( phy != null ) {
7122 if ( !p.hasNext() ) {
7126 if ( phy == null ) {
7129 if ( phy.getNumberOfExternalNodes() != 25 ) {
7132 if ( !phy.getName().equals( "" ) ) {
7135 if ( p.hasNext() ) {
7139 if ( phy != null ) {
7143 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7144 if ( !p.hasNext() ) {
7148 if ( phy == null ) {
7151 if ( phy.getNumberOfExternalNodes() != 10 ) {
7154 if ( !phy.getName().equals( "name" ) ) {
7157 if ( p.hasNext() ) {
7161 if ( phy != null ) {
7166 if ( !p.hasNext() ) {
7170 if ( phy == null ) {
7173 if ( phy.getNumberOfExternalNodes() != 10 ) {
7176 if ( !phy.getName().equals( "name" ) ) {
7179 if ( p.hasNext() ) {
7183 if ( phy != null ) {
7187 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7188 if ( !p.hasNext() ) {
7192 if ( phy == null ) {
7195 if ( phy.getNumberOfExternalNodes() != 3 ) {
7198 if ( !phy.getName().equals( "" ) ) {
7201 if ( phy.isRooted() ) {
7204 if ( p.hasNext() ) {
7208 if ( phy != null ) {
7213 if ( !p.hasNext() ) {
7217 if ( phy == null ) {
7220 if ( phy.getNumberOfExternalNodes() != 3 ) {
7223 if ( !phy.getName().equals( "" ) ) {
7226 if ( p.hasNext() ) {
7230 if ( phy != null ) {
7234 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7235 if ( !p.hasNext() ) {
7240 if ( phy == null ) {
7243 if ( phy.getNumberOfExternalNodes() != 10 ) {
7246 if ( !phy.getName().equals( "tree 0" ) ) {
7250 if ( !p.hasNext() ) {
7254 if ( phy == null ) {
7257 if ( phy.getNumberOfExternalNodes() != 10 ) {
7260 if ( !phy.getName().equals( "tree 1" ) ) {
7264 if ( !p.hasNext() ) {
7268 if ( phy == null ) {
7271 if ( phy.getNumberOfExternalNodes() != 3 ) {
7272 System.out.println( phy.toString() );
7275 if ( !phy.getName().equals( "" ) ) {
7278 if ( phy.isRooted() ) {
7282 if ( !p.hasNext() ) {
7286 if ( phy == null ) {
7289 if ( phy.getNumberOfExternalNodes() != 4 ) {
7292 if ( !phy.getName().equals( "" ) ) {
7295 if ( !phy.isRooted() ) {
7299 if ( !p.hasNext() ) {
7303 if ( phy == null ) {
7306 if ( phy.getNumberOfExternalNodes() != 5 ) {
7307 System.out.println( phy.getNumberOfExternalNodes() );
7310 if ( !phy.getName().equals( "" ) ) {
7313 if ( !phy.isRooted() ) {
7317 if ( !p.hasNext() ) {
7321 if ( phy == null ) {
7324 if ( phy.getNumberOfExternalNodes() != 3 ) {
7327 if ( !phy.getName().equals( "" ) ) {
7330 if ( phy.isRooted() ) {
7334 if ( !p.hasNext() ) {
7338 if ( phy == null ) {
7341 if ( phy.getNumberOfExternalNodes() != 2 ) {
7344 if ( !phy.getName().equals( "" ) ) {
7347 if ( !phy.isRooted() ) {
7351 if ( !p.hasNext() ) {
7355 if ( phy.getNumberOfExternalNodes() != 3 ) {
7358 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7361 if ( !phy.isRooted() ) {
7365 if ( !p.hasNext() ) {
7369 if ( phy.getNumberOfExternalNodes() != 3 ) {
7372 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7375 if ( !phy.getName().equals( "tree 8" ) ) {
7379 if ( !p.hasNext() ) {
7383 if ( phy.getNumberOfExternalNodes() != 3 ) {
7386 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7389 if ( !phy.getName().equals( "tree 9" ) ) {
7393 if ( !p.hasNext() ) {
7397 if ( phy.getNumberOfExternalNodes() != 3 ) {
7400 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7403 if ( !phy.getName().equals( "tree 10" ) ) {
7406 if ( !phy.isRooted() ) {
7410 if ( !p.hasNext() ) {
7414 if ( phy.getNumberOfExternalNodes() != 3 ) {
7417 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7420 if ( !phy.getName().equals( "tree 11" ) ) {
7423 if ( phy.isRooted() ) {
7427 if ( !p.hasNext() ) {
7431 if ( phy.getNumberOfExternalNodes() != 3 ) {
7434 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7437 if ( !phy.getName().equals( "tree 12" ) ) {
7440 if ( !phy.isRooted() ) {
7444 if ( !p.hasNext() ) {
7448 if ( phy.getNumberOfExternalNodes() != 3 ) {
7451 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7454 if ( !phy.getName().equals( "tree 13" ) ) {
7457 if ( !phy.isRooted() ) {
7461 if ( !p.hasNext() ) {
7465 if ( phy.getNumberOfExternalNodes() != 10 ) {
7466 System.out.println( phy.getNumberOfExternalNodes() );
7471 .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;" ) ) {
7472 System.out.println( phy.toNewHampshire() );
7475 if ( !phy.getName().equals( "tree 14" ) ) {
7478 if ( !phy.isRooted() ) {
7482 if ( !p.hasNext() ) {
7486 if ( phy.getNumberOfExternalNodes() != 10 ) {
7487 System.out.println( phy.getNumberOfExternalNodes() );
7492 .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;" ) ) {
7493 System.out.println( phy.toNewHampshire() );
7496 if ( !phy.getName().equals( "tree 15" ) ) {
7499 if ( phy.isRooted() ) {
7503 if ( !p.hasNext() ) {
7507 if ( phy.getNumberOfExternalNodes() != 10 ) {
7508 System.out.println( phy.getNumberOfExternalNodes() );
7513 .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;" ) ) {
7514 System.out.println( phy.toNewHampshire() );
7517 if ( !phy.getName().equals( "tree 16" ) ) {
7520 if ( !phy.isRooted() ) {
7524 if ( !p.hasNext() ) {
7528 if ( phy.getNumberOfExternalNodes() != 10 ) {
7529 System.out.println( phy.getNumberOfExternalNodes() );
7534 .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;" ) ) {
7535 System.out.println( phy.toNewHampshire() );
7538 if ( !phy.getName().equals( "tree 17" ) ) {
7541 if ( phy.isRooted() ) {
7545 if ( p.hasNext() ) {
7549 if ( phy != null ) {
7554 if ( !p.hasNext() ) {
7558 if ( phy == null ) {
7561 if ( phy.getNumberOfExternalNodes() != 10 ) {
7564 if ( !phy.getName().equals( "tree 0" ) ) {
7568 if ( !p.hasNext() ) {
7572 if ( phy == null ) {
7575 if ( phy.getNumberOfExternalNodes() != 10 ) {
7578 if ( !phy.getName().equals( "tree 1" ) ) {
7582 if ( !p.hasNext() ) {
7586 if ( phy == null ) {
7589 if ( phy.getNumberOfExternalNodes() != 3 ) {
7592 if ( !phy.getName().equals( "" ) ) {
7595 if ( phy.isRooted() ) {
7599 if ( !p.hasNext() ) {
7603 if ( phy == null ) {
7606 if ( phy.getNumberOfExternalNodes() != 4 ) {
7609 if ( !phy.getName().equals( "" ) ) {
7612 if ( !phy.isRooted() ) {
7616 if ( !p.hasNext() ) {
7620 if ( phy == null ) {
7623 if ( phy.getNumberOfExternalNodes() != 5 ) {
7624 System.out.println( phy.getNumberOfExternalNodes() );
7627 if ( !phy.getName().equals( "" ) ) {
7630 if ( !phy.isRooted() ) {
7634 if ( !p.hasNext() ) {
7638 if ( phy == null ) {
7641 if ( phy.getNumberOfExternalNodes() != 3 ) {
7644 if ( !phy.getName().equals( "" ) ) {
7647 if ( phy.isRooted() ) {
7651 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7652 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7654 if ( !p2.hasNext() ) {
7658 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7661 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7665 if ( !p2.hasNext() ) {
7670 if ( !p2.hasNext() ) {
7675 if ( !p2.hasNext() ) {
7680 if ( !p2.hasNext() ) {
7685 if ( !p2.hasNext() ) {
7690 if ( !p2.hasNext() ) {
7695 if ( !p2.hasNext() ) {
7700 if ( !p2.hasNext() ) {
7704 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7707 if ( p2.hasNext() ) {
7711 if ( phy != null ) {
7716 if ( !p2.hasNext() ) {
7720 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7723 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7727 catch ( final Exception e ) {
7728 e.printStackTrace( System.out );
7734 private static boolean testNexusTreeParsingTranslating() {
7736 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7737 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7738 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7739 if ( phylogenies.length != 1 ) {
7742 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7745 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7748 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7751 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7754 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7755 .equals( "Aranaeus" ) ) {
7759 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7760 if ( phylogenies.length != 3 ) {
7763 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7766 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7769 if ( phylogenies[ 0 ].isRooted() ) {
7772 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7775 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7778 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7779 .equals( "Aranaeus" ) ) {
7782 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7785 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7788 if ( phylogenies[ 1 ].isRooted() ) {
7791 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7794 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7797 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7798 .equals( "Aranaeus" ) ) {
7801 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7804 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7807 if ( !phylogenies[ 2 ].isRooted() ) {
7810 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7813 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7816 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7817 .equals( "Aranaeus" ) ) {
7821 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7822 if ( phylogenies.length != 3 ) {
7825 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7828 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7831 if ( phylogenies[ 0 ].isRooted() ) {
7834 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7837 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7840 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7841 .equals( "Aranaeus" ) ) {
7844 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7847 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7850 if ( phylogenies[ 1 ].isRooted() ) {
7853 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7856 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7859 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7860 .equals( "Aranaeus" ) ) {
7863 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7866 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7869 if ( !phylogenies[ 2 ].isRooted() ) {
7872 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7875 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7878 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7879 .equals( "Aranaeus" ) ) {
7882 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
7883 if ( phylogenies.length != 3 ) {
7886 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
7891 catch ( final Exception e ) {
7892 e.printStackTrace( System.out );
7898 private static boolean testNHParsing() {
7900 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7901 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7902 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7905 final NHXParser nhxp = new NHXParser();
7906 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7907 nhxp.setReplaceUnderscores( true );
7908 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7909 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
7912 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
7915 final Phylogeny p1b = factory
7916 .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 ",
7917 new NHXParser() )[ 0 ];
7918 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7921 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7924 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7925 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7926 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7927 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7928 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7929 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7930 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7931 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
7932 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
7933 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
7934 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
7935 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
7936 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
7938 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
7941 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
7944 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
7947 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
7950 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
7951 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
7952 final String p16_S = "((A,B),C)";
7953 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
7954 if ( p16.length != 1 ) {
7957 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
7960 final String p17_S = "(C,(A,B))";
7961 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
7962 if ( p17.length != 1 ) {
7965 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
7968 final String p18_S = "((A,B),(C,D))";
7969 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
7970 if ( p18.length != 1 ) {
7973 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
7976 final String p19_S = "(((A,B),C),D)";
7977 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
7978 if ( p19.length != 1 ) {
7981 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
7984 final String p20_S = "(A,(B,(C,D)))";
7985 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
7986 if ( p20.length != 1 ) {
7989 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
7992 final String p21_S = "(A,(B,(C,(D,E))))";
7993 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
7994 if ( p21.length != 1 ) {
7997 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8000 final String p22_S = "((((A,B),C),D),E)";
8001 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8002 if ( p22.length != 1 ) {
8005 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8008 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8009 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8010 if ( p23.length != 1 ) {
8011 System.out.println( "xl=" + p23.length );
8015 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8018 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8019 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8020 if ( p24.length != 1 ) {
8023 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8026 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8027 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8028 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8029 if ( p241.length != 2 ) {
8032 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8035 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8038 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8039 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8040 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8041 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8042 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8043 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8044 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8045 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8046 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8047 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8050 final String p26_S = "(A,B)ab";
8051 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8052 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8055 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8056 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8057 if ( p27s.length != 1 ) {
8058 System.out.println( "xxl=" + p27s.length );
8062 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8063 System.out.println( p27s[ 0 ].toNewHampshireX() );
8067 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8069 if ( p27.length != 1 ) {
8070 System.out.println( "yl=" + p27.length );
8074 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8075 System.out.println( p27[ 0 ].toNewHampshireX() );
8079 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8080 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8081 final String p28_S3 = "(A,B)ab";
8082 final String p28_S4 = "((((A,B),C),D),;E;)";
8083 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8085 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8088 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8091 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8094 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8097 if ( p28.length != 4 ) {
8100 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";
8101 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8102 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8105 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";
8106 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8107 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8110 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8111 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8112 if ( ( p32.length != 0 ) ) {
8115 final String p33_S = "A";
8116 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8117 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8120 final String p34_S = "B;";
8121 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8122 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8125 final String p35_S = "B:0.2";
8126 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8127 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8130 final String p36_S = "(A)";
8131 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8132 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8135 final String p37_S = "((A))";
8136 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8137 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8140 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8141 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8142 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8145 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8146 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8147 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8150 final String p40_S = "(A,B,C)";
8151 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8152 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8155 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8156 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8157 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8160 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8161 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8162 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8165 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)";
8166 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8167 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8170 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)))";
8171 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8172 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8175 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8176 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8177 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8180 final String p46_S = "";
8181 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8182 if ( p46.length != 0 ) {
8185 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8186 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8189 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8190 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8193 final Phylogeny p49 = factory
8194 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8195 new NHXParser() )[ 0 ];
8196 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8199 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8200 if ( p50.getNode( "A" ) == null ) {
8203 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8204 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8207 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8210 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8211 .equals( "((A,B)88:2.0,C);" ) ) {
8214 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8215 if ( p51.getNode( "A(A" ) == null ) {
8218 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8219 if ( p52.getNode( "A(A" ) == null ) {
8222 final Phylogeny p53 = factory
8223 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8224 new NHXParser() )[ 0 ];
8225 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8228 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8229 if ( p54.getNode( "A" ) == null ) {
8232 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8235 final Phylogeny p55 = factory
8236 .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);" ),
8237 new NHXParser() )[ 0 ];
8240 .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);" ) ) {
8241 System.out.println( p55.toNewHampshire() );
8244 final Phylogeny p56 = factory
8245 .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);" ),
8246 new NHXParser() )[ 0 ];
8249 .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);" ) ) {
8250 System.out.println( p56.toNewHampshire() );
8253 final Phylogeny p57 = factory
8254 .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);" ),
8255 new NHXParser() )[ 0 ];
8258 .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);" ) ) {
8259 System.out.println( p56.toNewHampshire() );
8262 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8263 final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ];
8264 if ( !p58.toNewHampshire().equals( s58 ) ) {
8265 System.out.println( p58.toNewHampshire() );
8268 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8269 final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ];
8270 if ( !p59.toNewHampshire().equals( s59 ) ) {
8271 System.out.println( p59.toNewHampshire() );
8274 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8275 final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ];
8276 if ( !p60.toNewHampshire().equals( s60 ) ) {
8277 System.out.println( p60.toNewHampshire() );
8280 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8281 final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ];
8282 if ( !p61.toNewHampshire()
8283 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8284 System.out.println( p61.toNewHampshire() );
8288 catch ( final Exception e ) {
8289 e.printStackTrace( System.out );
8295 private static boolean testNHParsingIter() {
8297 final String p0_str = "(A,B);";
8298 final NHXParser p = new NHXParser();
8299 p.setSource( p0_str );
8300 if ( !p.hasNext() ) {
8303 final Phylogeny p0 = p.next();
8304 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8305 System.out.println( p0.toNewHampshire() );
8308 if ( p.hasNext() ) {
8311 if ( p.next() != null ) {
8315 final String p00_str = "(A,B)root;";
8316 p.setSource( p00_str );
8317 final Phylogeny p00 = p.next();
8318 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8319 System.out.println( p00.toNewHampshire() );
8323 final String p000_str = "A;";
8324 p.setSource( p000_str );
8325 final Phylogeny p000 = p.next();
8326 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8327 System.out.println( p000.toNewHampshire() );
8331 final String p0000_str = "A";
8332 p.setSource( p0000_str );
8333 final Phylogeny p0000 = p.next();
8334 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8335 System.out.println( p0000.toNewHampshire() );
8339 p.setSource( "(A)" );
8340 final Phylogeny p00000 = p.next();
8341 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8342 System.out.println( p00000.toNewHampshire() );
8346 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8347 p.setSource( p1_str );
8348 if ( !p.hasNext() ) {
8351 final Phylogeny p1_0 = p.next();
8352 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8353 System.out.println( p1_0.toNewHampshire() );
8356 if ( !p.hasNext() ) {
8359 final Phylogeny p1_1 = p.next();
8360 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8361 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8364 if ( !p.hasNext() ) {
8367 final Phylogeny p1_2 = p.next();
8368 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8369 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8372 if ( !p.hasNext() ) {
8375 final Phylogeny p1_3 = p.next();
8376 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8377 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8380 if ( p.hasNext() ) {
8383 if ( p.next() != null ) {
8387 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8388 p.setSource( p2_str );
8389 if ( !p.hasNext() ) {
8392 Phylogeny p2_0 = p.next();
8393 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8394 System.out.println( p2_0.toNewHampshire() );
8397 if ( !p.hasNext() ) {
8400 Phylogeny p2_1 = p.next();
8401 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8402 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8405 if ( !p.hasNext() ) {
8408 Phylogeny p2_2 = p.next();
8409 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8410 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8413 if ( !p.hasNext() ) {
8416 Phylogeny p2_3 = p.next();
8417 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8418 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8421 if ( !p.hasNext() ) {
8424 Phylogeny p2_4 = p.next();
8425 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8426 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8429 if ( p.hasNext() ) {
8432 if ( p.next() != null ) {
8437 if ( !p.hasNext() ) {
8441 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8442 System.out.println( p2_0.toNewHampshire() );
8445 if ( !p.hasNext() ) {
8449 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8450 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8453 if ( !p.hasNext() ) {
8457 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8458 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8461 if ( !p.hasNext() ) {
8465 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8466 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8469 if ( !p.hasNext() ) {
8473 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8474 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8477 if ( p.hasNext() ) {
8480 if ( p.next() != null ) {
8484 final String p3_str = "((A,B),C)abc";
8485 p.setSource( p3_str );
8486 if ( !p.hasNext() ) {
8489 final Phylogeny p3_0 = p.next();
8490 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8493 if ( p.hasNext() ) {
8496 if ( p.next() != null ) {
8500 final String p4_str = "((A,B)ab,C)abc";
8501 p.setSource( p4_str );
8502 if ( !p.hasNext() ) {
8505 final Phylogeny p4_0 = p.next();
8506 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8509 if ( p.hasNext() ) {
8512 if ( p.next() != null ) {
8516 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8517 p.setSource( p5_str );
8518 if ( !p.hasNext() ) {
8521 final Phylogeny p5_0 = p.next();
8522 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8525 if ( p.hasNext() ) {
8528 if ( p.next() != null ) {
8532 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8533 p.setSource( p6_str );
8534 if ( !p.hasNext() ) {
8537 Phylogeny p6_0 = p.next();
8538 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8541 if ( p.hasNext() ) {
8544 if ( p.next() != null ) {
8548 if ( !p.hasNext() ) {
8552 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8555 if ( p.hasNext() ) {
8558 if ( p.next() != null ) {
8562 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8563 p.setSource( p7_str );
8564 if ( !p.hasNext() ) {
8567 Phylogeny p7_0 = p.next();
8568 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8571 if ( p.hasNext() ) {
8574 if ( p.next() != null ) {
8578 if ( !p.hasNext() ) {
8582 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8585 if ( p.hasNext() ) {
8588 if ( p.next() != null ) {
8592 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8593 p.setSource( p8_str );
8594 if ( !p.hasNext() ) {
8597 Phylogeny p8_0 = p.next();
8598 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8601 if ( !p.hasNext() ) {
8604 if ( !p.hasNext() ) {
8607 Phylogeny p8_1 = p.next();
8608 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8611 if ( p.hasNext() ) {
8614 if ( p.next() != null ) {
8618 if ( !p.hasNext() ) {
8622 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8625 if ( !p.hasNext() ) {
8629 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8632 if ( p.hasNext() ) {
8635 if ( p.next() != null ) {
8641 if ( p.hasNext() ) {
8645 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8646 if ( !p.hasNext() ) {
8649 Phylogeny p_27 = p.next();
8650 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8651 System.out.println( p_27.toNewHampshireX() );
8655 if ( p.hasNext() ) {
8658 if ( p.next() != null ) {
8662 if ( !p.hasNext() ) {
8666 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8667 System.out.println( p_27.toNewHampshireX() );
8671 if ( p.hasNext() ) {
8674 if ( p.next() != null ) {
8678 final String p30_str = "(A,B);(C,D)";
8679 final NHXParser p30 = new NHXParser();
8680 p30.setSource( p30_str );
8681 if ( !p30.hasNext() ) {
8684 Phylogeny phy30 = p30.next();
8685 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8686 System.out.println( phy30.toNewHampshire() );
8689 if ( !p30.hasNext() ) {
8692 Phylogeny phy301 = p30.next();
8693 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8694 System.out.println( phy301.toNewHampshire() );
8697 if ( p30.hasNext() ) {
8700 if ( p30.hasNext() ) {
8703 if ( p30.next() != null ) {
8706 if ( p30.next() != null ) {
8710 if ( !p30.hasNext() ) {
8714 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8715 System.out.println( phy30.toNewHampshire() );
8718 if ( !p30.hasNext() ) {
8721 phy301 = p30.next();
8722 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8723 System.out.println( phy301.toNewHampshire() );
8726 if ( p30.hasNext() ) {
8729 if ( p30.hasNext() ) {
8732 if ( p30.next() != null ) {
8735 if ( p30.next() != null ) {
8739 catch ( final Exception e ) {
8740 e.printStackTrace( System.out );
8746 private static boolean testNHXconversion() {
8748 final PhylogenyNode n1 = new PhylogenyNode();
8749 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8750 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8751 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8752 final PhylogenyNode n5 = PhylogenyNode
8753 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8754 final PhylogenyNode n6 = PhylogenyNode
8755 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8756 if ( !n1.toNewHampshireX().equals( "" ) ) {
8759 if ( !n2.toNewHampshireX().equals( "" ) ) {
8762 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8765 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8768 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8771 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8772 System.out.println( n6.toNewHampshireX() );
8775 final PhylogenyNode n7 = new PhylogenyNode();
8776 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
8777 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8778 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
8779 System.out.println( n7
8780 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
8784 catch ( final Exception e ) {
8785 e.printStackTrace( System.out );
8791 private static boolean testNHXNodeParsing() {
8793 final PhylogenyNode n1 = new PhylogenyNode();
8794 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8795 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8796 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8797 final PhylogenyNode n5 = PhylogenyNode
8798 .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]" );
8799 if ( !n3.getName().equals( "n3" ) ) {
8802 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8805 if ( n3.isDuplication() ) {
8808 if ( n3.isHasAssignedEvent() ) {
8811 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8814 if ( !n4.getName().equals( "n4" ) ) {
8817 if ( n4.getDistanceToParent() != 0.01 ) {
8820 if ( !n5.getName().equals( "n5" ) ) {
8823 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8826 if ( n5.getDistanceToParent() != 0.1 ) {
8829 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8832 if ( !n5.isDuplication() ) {
8835 if ( !n5.isHasAssignedEvent() ) {
8838 final PhylogenyNode n8 = PhylogenyNode
8839 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8840 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8841 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8844 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8847 final PhylogenyNode n9 = PhylogenyNode
8848 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8849 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8850 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8853 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8856 final PhylogenyNode n10 = PhylogenyNode
8857 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8858 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8861 final PhylogenyNode n20 = PhylogenyNode
8862 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8863 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8866 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8869 final PhylogenyNode n20x = PhylogenyNode
8870 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8871 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8874 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8877 final PhylogenyNode n20xx = PhylogenyNode
8878 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8879 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8882 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8885 final PhylogenyNode n20xxx = PhylogenyNode
8886 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8887 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8890 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8893 final PhylogenyNode n20xxxx = PhylogenyNode
8894 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8895 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8898 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8901 final PhylogenyNode n21 = PhylogenyNode
8902 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8903 if ( !n21.getName().equals( "N21_PIG" ) ) {
8906 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8909 final PhylogenyNode n21x = PhylogenyNode
8910 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8911 if ( !n21x.getName().equals( "n21_PIG" ) ) {
8914 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8917 final PhylogenyNode n22 = PhylogenyNode
8918 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8919 if ( !n22.getName().equals( "n22/PIG" ) ) {
8922 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8925 final PhylogenyNode n23 = PhylogenyNode
8926 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8927 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8930 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
8933 final PhylogenyNode a = PhylogenyNode
8934 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8935 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8938 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
8941 final PhylogenyNode c1 = PhylogenyNode
8942 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
8943 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8944 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
8947 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
8950 final PhylogenyNode c2 = PhylogenyNode
8951 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
8952 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8953 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
8956 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
8959 final PhylogenyNode e3 = PhylogenyNode
8960 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8961 if ( !e3.getName().equals( "n10_RAT~" ) ) {
8964 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
8967 final PhylogenyNode n11 = PhylogenyNode
8968 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
8969 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8970 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
8973 if ( n11.getDistanceToParent() != 0.4 ) {
8976 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
8979 final PhylogenyNode n12 = PhylogenyNode
8980 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
8981 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8982 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
8985 if ( n12.getDistanceToParent() != 0.4 ) {
8988 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
8991 final PhylogenyNode o = PhylogenyNode
8992 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8993 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
8996 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
8999 if ( n1.getName().compareTo( "" ) != 0 ) {
9002 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9005 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9008 if ( n2.getName().compareTo( "" ) != 0 ) {
9011 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9014 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9017 final PhylogenyNode n00 = PhylogenyNode
9018 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9019 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9022 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9025 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9026 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9029 final PhylogenyNode n13 = PhylogenyNode
9030 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9031 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9034 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9037 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9040 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9043 final PhylogenyNode n14 = PhylogenyNode
9044 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9045 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9048 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9051 final PhylogenyNode n15 = PhylogenyNode
9052 .createInstanceFromNhxString( "something_wicked[123]",
9053 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9054 if ( !n15.getName().equals( "something_wicked" ) ) {
9057 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9060 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9063 final PhylogenyNode n16 = PhylogenyNode
9064 .createInstanceFromNhxString( "something_wicked2[9]",
9065 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9066 if ( !n16.getName().equals( "something_wicked2" ) ) {
9069 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9072 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9075 final PhylogenyNode n17 = PhylogenyNode
9076 .createInstanceFromNhxString( "something_wicked3[a]",
9077 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9078 if ( !n17.getName().equals( "something_wicked3" ) ) {
9081 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9084 final PhylogenyNode n18 = PhylogenyNode
9085 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9086 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9089 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9092 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9095 final PhylogenyNode n19 = PhylogenyNode
9096 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9097 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9100 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9103 final PhylogenyNode n30 = PhylogenyNode
9104 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9105 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9106 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9109 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9112 final PhylogenyNode n31 = PhylogenyNode
9113 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9114 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9115 if ( n31.getNodeData().isHasTaxonomy() ) {
9118 final PhylogenyNode n32 = PhylogenyNode
9119 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9120 if ( n32.getNodeData().isHasTaxonomy() ) {
9123 final PhylogenyNode n40 = PhylogenyNode
9124 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9125 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9128 final PhylogenyNode n41 = PhylogenyNode
9129 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9130 if ( n41.getNodeData().isHasTaxonomy() ) {
9133 final PhylogenyNode n42 = PhylogenyNode
9134 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9135 if ( n42.getNodeData().isHasTaxonomy() ) {
9138 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9139 NHXParser.TAXONOMY_EXTRACTION.NO );
9140 if ( n43.getNodeData().isHasTaxonomy() ) {
9143 final PhylogenyNode n44 = PhylogenyNode
9144 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9145 if ( n44.getNodeData().isHasTaxonomy() ) {
9149 catch ( final Exception e ) {
9150 e.printStackTrace( System.out );
9156 private static boolean testNHXParsing() {
9158 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9159 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9160 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9163 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]";
9164 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9165 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9168 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]";
9169 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9170 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9173 final Phylogeny[] p3 = factory
9174 .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]",
9176 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9179 final Phylogeny[] p4 = factory
9180 .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(]",
9182 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9185 final Phylogeny[] p5 = factory
9186 .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(((]",
9188 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9191 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)";
9192 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)";
9193 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9194 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9197 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)))";
9198 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)))";
9199 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9200 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9203 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]) ))[,,, ])))))))";
9204 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9205 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9206 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9209 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9210 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9213 final Phylogeny p10 = factory
9214 .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]",
9215 new NHXParser() )[ 0 ];
9216 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9219 final Phylogeny p11 = factory
9220 .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]",
9221 new NHXParser() )[ 0 ];
9222 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9226 catch ( final Exception e ) {
9227 e.printStackTrace( System.out );
9233 private static boolean testNHXParsingMB() {
9235 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9236 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9237 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9238 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9239 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9240 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9241 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9242 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9243 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9244 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9245 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9248 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9251 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9252 0.1100000000000000e+00 ) ) {
9255 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9258 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9261 final Phylogeny p2 = factory
9262 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9263 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9264 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9265 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9266 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9267 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9268 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9269 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9270 + "7.369400000000000e-02}])",
9271 new NHXParser() )[ 0 ];
9272 if ( p2.getNode( "1" ) == null ) {
9275 if ( p2.getNode( "2" ) == null ) {
9279 catch ( final Exception e ) {
9280 e.printStackTrace( System.out );
9287 private static boolean testNHXParsingQuotes() {
9289 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9290 final NHXParser p = new NHXParser();
9291 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9292 if ( phylogenies_0.length != 5 ) {
9295 final Phylogeny phy = phylogenies_0[ 4 ];
9296 if ( phy.getNumberOfExternalNodes() != 7 ) {
9299 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9302 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9305 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9306 .getScientificName().equals( "hsapiens" ) ) {
9309 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9312 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9315 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9318 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9321 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9324 final NHXParser p1p = new NHXParser();
9325 p1p.setIgnoreQuotes( true );
9326 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9327 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9330 final NHXParser p2p = new NHXParser();
9331 p1p.setIgnoreQuotes( false );
9332 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9333 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9336 final NHXParser p3p = new NHXParser();
9337 p3p.setIgnoreQuotes( false );
9338 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9339 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9342 final NHXParser p4p = new NHXParser();
9343 p4p.setIgnoreQuotes( false );
9344 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9345 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9348 final Phylogeny p10 = factory
9349 .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]",
9350 new NHXParser() )[ 0 ];
9351 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]";
9352 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9355 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9356 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9359 final Phylogeny p12 = factory
9360 .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]",
9361 new NHXParser() )[ 0 ];
9362 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]";
9363 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9366 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9367 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9370 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;";
9371 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9374 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9375 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9379 catch ( final Exception e ) {
9380 e.printStackTrace( System.out );
9386 private static boolean testNodeRemoval() {
9388 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9389 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9390 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9391 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9394 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9395 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9396 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9399 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9400 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9401 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9405 catch ( final Exception e ) {
9406 e.printStackTrace( System.out );
9412 private static boolean testPhylogenyBranch() {
9414 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9415 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9416 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9417 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9418 if ( !a1b1.equals( a1b1 ) ) {
9421 if ( !a1b1.equals( b1a1 ) ) {
9424 if ( !b1a1.equals( a1b1 ) ) {
9427 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9428 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9429 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9430 if ( a1_b1.equals( b1_a1 ) ) {
9433 if ( a1_b1.equals( a1_b1_ ) ) {
9436 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9437 if ( !a1_b1.equals( b1_a1_ ) ) {
9440 if ( a1_b1_.equals( b1_a1_ ) ) {
9443 if ( !a1_b1_.equals( b1_a1 ) ) {
9447 catch ( final Exception e ) {
9448 e.printStackTrace( System.out );
9454 private static boolean testPhyloXMLparsingOfDistributionElement() {
9456 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9457 PhyloXmlParser xml_parser = null;
9459 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9461 catch ( final Exception e ) {
9462 // Do nothing -- means were not running from jar.
9464 if ( xml_parser == null ) {
9465 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9466 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9467 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9470 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9473 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9475 if ( xml_parser.getErrorCount() > 0 ) {
9476 System.out.println( xml_parser.getErrorMessages().toString() );
9479 if ( phylogenies_0.length != 1 ) {
9482 final Phylogeny t1 = phylogenies_0[ 0 ];
9483 PhylogenyNode n = null;
9484 Distribution d = null;
9485 n = t1.getNode( "root node" );
9486 if ( !n.getNodeData().isHasDistribution() ) {
9489 if ( n.getNodeData().getDistributions().size() != 1 ) {
9492 d = n.getNodeData().getDistribution();
9493 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9496 if ( d.getPoints().size() != 1 ) {
9499 if ( d.getPolygons() != null ) {
9502 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9505 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9508 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9511 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9514 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9517 n = t1.getNode( "node a" );
9518 if ( !n.getNodeData().isHasDistribution() ) {
9521 if ( n.getNodeData().getDistributions().size() != 2 ) {
9524 d = n.getNodeData().getDistribution( 1 );
9525 if ( !d.getDesc().equals( "San Diego" ) ) {
9528 if ( d.getPoints().size() != 1 ) {
9531 if ( d.getPolygons() != null ) {
9534 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9537 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9540 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9543 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9546 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9549 n = t1.getNode( "node bb" );
9550 if ( !n.getNodeData().isHasDistribution() ) {
9553 if ( n.getNodeData().getDistributions().size() != 1 ) {
9556 d = n.getNodeData().getDistribution( 0 );
9557 if ( d.getPoints().size() != 3 ) {
9560 if ( d.getPolygons().size() != 2 ) {
9563 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9566 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9569 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9572 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9575 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9578 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9581 Polygon p = d.getPolygons().get( 0 );
9582 if ( p.getPoints().size() != 3 ) {
9585 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9588 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9591 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9594 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9597 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9600 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9603 p = d.getPolygons().get( 1 );
9604 if ( p.getPoints().size() != 3 ) {
9607 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9610 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9613 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9617 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9618 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9619 if ( rt.length != 1 ) {
9622 final Phylogeny t1_rt = rt[ 0 ];
9623 n = t1_rt.getNode( "root node" );
9624 if ( !n.getNodeData().isHasDistribution() ) {
9627 if ( n.getNodeData().getDistributions().size() != 1 ) {
9630 d = n.getNodeData().getDistribution();
9631 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9634 if ( d.getPoints().size() != 1 ) {
9637 if ( d.getPolygons() != null ) {
9640 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9643 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9646 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9649 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9652 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9655 n = t1_rt.getNode( "node a" );
9656 if ( !n.getNodeData().isHasDistribution() ) {
9659 if ( n.getNodeData().getDistributions().size() != 2 ) {
9662 d = n.getNodeData().getDistribution( 1 );
9663 if ( !d.getDesc().equals( "San Diego" ) ) {
9666 if ( d.getPoints().size() != 1 ) {
9669 if ( d.getPolygons() != null ) {
9672 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9675 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9678 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9681 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9684 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9687 n = t1_rt.getNode( "node bb" );
9688 if ( !n.getNodeData().isHasDistribution() ) {
9691 if ( n.getNodeData().getDistributions().size() != 1 ) {
9694 d = n.getNodeData().getDistribution( 0 );
9695 if ( d.getPoints().size() != 3 ) {
9698 if ( d.getPolygons().size() != 2 ) {
9701 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9704 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9707 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9710 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9713 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9716 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9719 p = d.getPolygons().get( 0 );
9720 if ( p.getPoints().size() != 3 ) {
9723 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9726 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9729 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9732 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9735 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9738 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9741 p = d.getPolygons().get( 1 );
9742 if ( p.getPoints().size() != 3 ) {
9745 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9748 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9751 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9755 catch ( final Exception e ) {
9756 e.printStackTrace( System.out );
9762 private static boolean testPostOrderIterator() {
9764 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9765 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9766 PhylogenyNodeIterator it0;
9767 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9770 for( it0.reset(); it0.hasNext(); ) {
9773 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9774 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9775 if ( !it.next().getName().equals( "A" ) ) {
9778 if ( !it.next().getName().equals( "B" ) ) {
9781 if ( !it.next().getName().equals( "ab" ) ) {
9784 if ( !it.next().getName().equals( "C" ) ) {
9787 if ( !it.next().getName().equals( "D" ) ) {
9790 if ( !it.next().getName().equals( "cd" ) ) {
9793 if ( !it.next().getName().equals( "abcd" ) ) {
9796 if ( !it.next().getName().equals( "E" ) ) {
9799 if ( !it.next().getName().equals( "F" ) ) {
9802 if ( !it.next().getName().equals( "ef" ) ) {
9805 if ( !it.next().getName().equals( "G" ) ) {
9808 if ( !it.next().getName().equals( "H" ) ) {
9811 if ( !it.next().getName().equals( "gh" ) ) {
9814 if ( !it.next().getName().equals( "efgh" ) ) {
9817 if ( !it.next().getName().equals( "r" ) ) {
9820 if ( it.hasNext() ) {
9824 catch ( final Exception e ) {
9825 e.printStackTrace( System.out );
9831 private static boolean testPreOrderIterator() {
9833 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9834 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9835 PhylogenyNodeIterator it0;
9836 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9839 for( it0.reset(); it0.hasNext(); ) {
9842 PhylogenyNodeIterator it = t0.iteratorPreorder();
9843 if ( !it.next().getName().equals( "r" ) ) {
9846 if ( !it.next().getName().equals( "ab" ) ) {
9849 if ( !it.next().getName().equals( "A" ) ) {
9852 if ( !it.next().getName().equals( "B" ) ) {
9855 if ( !it.next().getName().equals( "cd" ) ) {
9858 if ( !it.next().getName().equals( "C" ) ) {
9861 if ( !it.next().getName().equals( "D" ) ) {
9864 if ( it.hasNext() ) {
9867 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9868 it = t1.iteratorPreorder();
9869 if ( !it.next().getName().equals( "r" ) ) {
9872 if ( !it.next().getName().equals( "abcd" ) ) {
9875 if ( !it.next().getName().equals( "ab" ) ) {
9878 if ( !it.next().getName().equals( "A" ) ) {
9881 if ( !it.next().getName().equals( "B" ) ) {
9884 if ( !it.next().getName().equals( "cd" ) ) {
9887 if ( !it.next().getName().equals( "C" ) ) {
9890 if ( !it.next().getName().equals( "D" ) ) {
9893 if ( !it.next().getName().equals( "efgh" ) ) {
9896 if ( !it.next().getName().equals( "ef" ) ) {
9899 if ( !it.next().getName().equals( "E" ) ) {
9902 if ( !it.next().getName().equals( "F" ) ) {
9905 if ( !it.next().getName().equals( "gh" ) ) {
9908 if ( !it.next().getName().equals( "G" ) ) {
9911 if ( !it.next().getName().equals( "H" ) ) {
9914 if ( it.hasNext() ) {
9918 catch ( final Exception e ) {
9919 e.printStackTrace( System.out );
9925 private static boolean testPropertiesMap() {
9927 final PropertiesMap pm = new PropertiesMap();
9928 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9929 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9930 final Property p2 = new Property( "something:else",
9932 "improbable:research",
9935 pm.addProperty( p0 );
9936 pm.addProperty( p1 );
9937 pm.addProperty( p2 );
9938 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
9941 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
9944 if ( pm.getProperties().size() != 3 ) {
9947 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
9950 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9953 if ( pm.getProperties().size() != 3 ) {
9956 pm.removeProperty( "dimensions:diameter" );
9957 if ( pm.getProperties().size() != 2 ) {
9960 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
9963 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9967 catch ( final Exception e ) {
9968 e.printStackTrace( System.out );
9974 private static boolean testProteinId() {
9976 final ProteinId id1 = new ProteinId( "a" );
9977 final ProteinId id2 = new ProteinId( "a" );
9978 final ProteinId id3 = new ProteinId( "A" );
9979 final ProteinId id4 = new ProteinId( "b" );
9980 if ( !id1.equals( id1 ) ) {
9983 if ( id1.getId().equals( "x" ) ) {
9986 if ( id1.getId().equals( null ) ) {
9989 if ( !id1.equals( id2 ) ) {
9992 if ( id1.equals( id3 ) ) {
9995 if ( id1.hashCode() != id1.hashCode() ) {
9998 if ( id1.hashCode() != id2.hashCode() ) {
10001 if ( id1.hashCode() == id3.hashCode() ) {
10004 if ( id1.compareTo( id1 ) != 0 ) {
10007 if ( id1.compareTo( id2 ) != 0 ) {
10010 if ( id1.compareTo( id3 ) != 0 ) {
10013 if ( id1.compareTo( id4 ) >= 0 ) {
10016 if ( id4.compareTo( id1 ) <= 0 ) {
10019 if ( !id4.getId().equals( "b" ) ) {
10022 final ProteinId id5 = new ProteinId( " C " );
10023 if ( !id5.getId().equals( "C" ) ) {
10026 if ( id5.equals( id1 ) ) {
10030 catch ( final Exception e ) {
10031 e.printStackTrace( System.out );
10037 private static boolean testReIdMethods() {
10039 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10040 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10041 final long count = PhylogenyNode.getNodeCount();
10042 p.levelOrderReID();
10043 if ( p.getNode( "r" ).getId() != count ) {
10046 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10049 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10052 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10055 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10058 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10061 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10064 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10067 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10070 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10073 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10076 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10079 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10082 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10085 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10089 catch ( final Exception e ) {
10090 e.printStackTrace( System.out );
10096 private static boolean testRerooting() {
10098 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10099 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",
10100 new NHXParser() )[ 0 ];
10101 if ( !t1.isRooted() ) {
10104 t1.reRoot( t1.getNode( "D" ) );
10105 t1.reRoot( t1.getNode( "CD" ) );
10106 t1.reRoot( t1.getNode( "A" ) );
10107 t1.reRoot( t1.getNode( "B" ) );
10108 t1.reRoot( t1.getNode( "AB" ) );
10109 t1.reRoot( t1.getNode( "D" ) );
10110 t1.reRoot( t1.getNode( "C" ) );
10111 t1.reRoot( t1.getNode( "CD" ) );
10112 t1.reRoot( t1.getNode( "A" ) );
10113 t1.reRoot( t1.getNode( "B" ) );
10114 t1.reRoot( t1.getNode( "AB" ) );
10115 t1.reRoot( t1.getNode( "D" ) );
10116 t1.reRoot( t1.getNode( "D" ) );
10117 t1.reRoot( t1.getNode( "C" ) );
10118 t1.reRoot( t1.getNode( "A" ) );
10119 t1.reRoot( t1.getNode( "B" ) );
10120 t1.reRoot( t1.getNode( "AB" ) );
10121 t1.reRoot( t1.getNode( "C" ) );
10122 t1.reRoot( t1.getNode( "D" ) );
10123 t1.reRoot( t1.getNode( "CD" ) );
10124 t1.reRoot( t1.getNode( "D" ) );
10125 t1.reRoot( t1.getNode( "A" ) );
10126 t1.reRoot( t1.getNode( "B" ) );
10127 t1.reRoot( t1.getNode( "AB" ) );
10128 t1.reRoot( t1.getNode( "C" ) );
10129 t1.reRoot( t1.getNode( "D" ) );
10130 t1.reRoot( t1.getNode( "CD" ) );
10131 t1.reRoot( t1.getNode( "D" ) );
10132 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10135 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10138 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10141 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10144 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10147 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10150 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",
10151 new NHXParser() )[ 0 ];
10152 t2.reRoot( t2.getNode( "A" ) );
10153 t2.reRoot( t2.getNode( "D" ) );
10154 t2.reRoot( t2.getNode( "ABC" ) );
10155 t2.reRoot( t2.getNode( "A" ) );
10156 t2.reRoot( t2.getNode( "B" ) );
10157 t2.reRoot( t2.getNode( "D" ) );
10158 t2.reRoot( t2.getNode( "C" ) );
10159 t2.reRoot( t2.getNode( "ABC" ) );
10160 t2.reRoot( t2.getNode( "A" ) );
10161 t2.reRoot( t2.getNode( "B" ) );
10162 t2.reRoot( t2.getNode( "AB" ) );
10163 t2.reRoot( t2.getNode( "AB" ) );
10164 t2.reRoot( t2.getNode( "D" ) );
10165 t2.reRoot( t2.getNode( "C" ) );
10166 t2.reRoot( t2.getNode( "B" ) );
10167 t2.reRoot( t2.getNode( "AB" ) );
10168 t2.reRoot( t2.getNode( "D" ) );
10169 t2.reRoot( t2.getNode( "D" ) );
10170 t2.reRoot( t2.getNode( "ABC" ) );
10171 t2.reRoot( t2.getNode( "A" ) );
10172 t2.reRoot( t2.getNode( "B" ) );
10173 t2.reRoot( t2.getNode( "AB" ) );
10174 t2.reRoot( t2.getNode( "D" ) );
10175 t2.reRoot( t2.getNode( "C" ) );
10176 t2.reRoot( t2.getNode( "ABC" ) );
10177 t2.reRoot( t2.getNode( "A" ) );
10178 t2.reRoot( t2.getNode( "B" ) );
10179 t2.reRoot( t2.getNode( "AB" ) );
10180 t2.reRoot( t2.getNode( "D" ) );
10181 t2.reRoot( t2.getNode( "D" ) );
10182 t2.reRoot( t2.getNode( "C" ) );
10183 t2.reRoot( t2.getNode( "A" ) );
10184 t2.reRoot( t2.getNode( "B" ) );
10185 t2.reRoot( t2.getNode( "AB" ) );
10186 t2.reRoot( t2.getNode( "C" ) );
10187 t2.reRoot( t2.getNode( "D" ) );
10188 t2.reRoot( t2.getNode( "ABC" ) );
10189 t2.reRoot( t2.getNode( "D" ) );
10190 t2.reRoot( t2.getNode( "A" ) );
10191 t2.reRoot( t2.getNode( "B" ) );
10192 t2.reRoot( t2.getNode( "AB" ) );
10193 t2.reRoot( t2.getNode( "C" ) );
10194 t2.reRoot( t2.getNode( "D" ) );
10195 t2.reRoot( t2.getNode( "ABC" ) );
10196 t2.reRoot( t2.getNode( "D" ) );
10197 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10200 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10203 t2.reRoot( t2.getNode( "ABC" ) );
10204 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10207 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10210 t2.reRoot( t2.getNode( "AB" ) );
10211 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10214 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10217 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10220 t2.reRoot( t2.getNode( "AB" ) );
10221 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10224 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10227 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10230 t2.reRoot( t2.getNode( "D" ) );
10231 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10234 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10237 t2.reRoot( t2.getNode( "ABC" ) );
10238 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10241 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10244 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10245 new NHXParser() )[ 0 ];
10246 t3.reRoot( t3.getNode( "B" ) );
10247 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10250 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10253 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10256 t3.reRoot( t3.getNode( "B" ) );
10257 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10260 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10263 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10266 t3.reRoot( t3.getRoot() );
10267 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10270 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10273 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10277 catch ( final Exception e ) {
10278 e.printStackTrace( System.out );
10284 private static boolean testSDIse() {
10286 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10287 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10288 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10289 gene1.setRooted( true );
10290 species1.setRooted( true );
10291 final SDI sdi = new SDI( gene1, species1 );
10292 if ( !gene1.getRoot().isDuplication() ) {
10295 final Phylogeny species2 = factory
10296 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10297 new NHXParser() )[ 0 ];
10298 final Phylogeny gene2 = factory
10299 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10300 new NHXParser() )[ 0 ];
10301 species2.setRooted( true );
10302 gene2.setRooted( true );
10303 final SDI sdi2 = new SDI( gene2, species2 );
10304 if ( sdi2.getDuplicationsSum() != 0 ) {
10307 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10310 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10313 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10316 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10319 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10322 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10325 final Phylogeny species3 = factory
10326 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10327 new NHXParser() )[ 0 ];
10328 final Phylogeny gene3 = factory
10329 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10330 new NHXParser() )[ 0 ];
10331 species3.setRooted( true );
10332 gene3.setRooted( true );
10333 final SDI sdi3 = new SDI( gene3, species3 );
10334 if ( sdi3.getDuplicationsSum() != 1 ) {
10337 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10340 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10343 final Phylogeny species4 = factory
10344 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10345 new NHXParser() )[ 0 ];
10346 final Phylogeny gene4 = factory
10347 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10348 new NHXParser() )[ 0 ];
10349 species4.setRooted( true );
10350 gene4.setRooted( true );
10351 final SDI sdi4 = new SDI( gene4, species4 );
10352 if ( sdi4.getDuplicationsSum() != 1 ) {
10355 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10358 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10361 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10364 if ( species4.getNumberOfExternalNodes() != 6 ) {
10367 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10370 final Phylogeny species5 = factory
10371 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10372 new NHXParser() )[ 0 ];
10373 final Phylogeny gene5 = factory
10374 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10375 new NHXParser() )[ 0 ];
10376 species5.setRooted( true );
10377 gene5.setRooted( true );
10378 final SDI sdi5 = new SDI( gene5, species5 );
10379 if ( sdi5.getDuplicationsSum() != 2 ) {
10382 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10385 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10388 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10391 if ( species5.getNumberOfExternalNodes() != 6 ) {
10394 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10397 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10398 // Conjecture for Comparing Molecular Phylogenies"
10399 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10400 final Phylogeny species6 = factory
10401 .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,"
10402 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10403 new NHXParser() )[ 0 ];
10404 final Phylogeny gene6 = factory
10405 .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,"
10406 + "((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,"
10407 + "(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;",
10408 new NHXParser() )[ 0 ];
10409 species6.setRooted( true );
10410 gene6.setRooted( true );
10411 final SDI sdi6 = new SDI( gene6, species6 );
10412 if ( sdi6.getDuplicationsSum() != 3 ) {
10415 if ( !gene6.getNode( "r" ).isDuplication() ) {
10418 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10421 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10424 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10427 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10430 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10433 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10436 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10439 sdi6.computeMappingCostL();
10440 if ( sdi6.computeMappingCostL() != 17 ) {
10443 if ( species6.getNumberOfExternalNodes() != 9 ) {
10446 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10449 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10450 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10451 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10452 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10453 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10454 species7.setRooted( true );
10455 final Phylogeny gene7_1 = Test
10456 .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])" );
10457 gene7_1.setRooted( true );
10458 final SDI sdi7 = new SDI( gene7_1, species7 );
10459 if ( sdi7.getDuplicationsSum() != 0 ) {
10462 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10465 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10468 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10471 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10474 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10477 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10480 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10483 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10486 final Phylogeny gene7_2 = Test
10487 .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])" );
10488 gene7_2.setRooted( true );
10489 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10490 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10493 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10496 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10499 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10502 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10505 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10508 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10511 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10514 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10517 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10521 catch ( final Exception e ) {
10527 private static boolean testSDIunrooted() {
10529 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10530 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10531 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10532 final Iterator<PhylogenyBranch> iter = l.iterator();
10533 PhylogenyBranch br = iter.next();
10534 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10537 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10541 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10544 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10548 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10551 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10555 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10558 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10562 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10565 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10569 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10572 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10576 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10579 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10583 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10586 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10590 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10593 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10597 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10600 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10604 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10607 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10611 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10614 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10618 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10621 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10625 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10628 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10632 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10635 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10638 if ( iter.hasNext() ) {
10641 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10642 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10643 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10645 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10648 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10652 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10655 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10659 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10662 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10665 if ( iter1.hasNext() ) {
10668 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10669 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10670 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10672 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10675 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10679 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10682 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10686 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10689 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10692 if ( iter2.hasNext() ) {
10695 final Phylogeny species0 = factory
10696 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10697 new NHXParser() )[ 0 ];
10698 final Phylogeny gene1 = factory
10699 .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])",
10700 new NHXParser() )[ 0 ];
10701 species0.setRooted( true );
10702 gene1.setRooted( true );
10703 final SDIR sdi_unrooted = new SDIR();
10704 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10705 if ( sdi_unrooted.getCount() != 1 ) {
10708 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10711 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10714 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10717 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10720 final Phylogeny gene2 = factory
10721 .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])",
10722 new NHXParser() )[ 0 ];
10723 gene2.setRooted( true );
10724 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10725 if ( sdi_unrooted.getCount() != 1 ) {
10728 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10731 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10734 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10737 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10740 final Phylogeny species6 = factory
10741 .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,"
10742 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10743 new NHXParser() )[ 0 ];
10744 final Phylogeny gene6 = factory
10745 .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],"
10746 + "(((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],"
10747 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10748 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10749 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10750 new NHXParser() )[ 0 ];
10751 species6.setRooted( true );
10752 gene6.setRooted( true );
10753 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10754 if ( sdi_unrooted.getCount() != 1 ) {
10757 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10760 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10763 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10766 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10769 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10772 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10775 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10778 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10781 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10784 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10787 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10790 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10794 final Phylogeny species7 = factory
10795 .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,"
10796 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10797 new NHXParser() )[ 0 ];
10798 final Phylogeny gene7 = factory
10799 .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],"
10800 + "(((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],"
10801 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10802 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10803 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10804 new NHXParser() )[ 0 ];
10805 species7.setRooted( true );
10806 gene7.setRooted( true );
10807 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10808 if ( sdi_unrooted.getCount() != 1 ) {
10811 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10814 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10817 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10820 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10823 if ( !p7[ 0 ].getRoot().isDuplication() ) {
10826 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10829 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10832 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10835 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10838 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10841 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10844 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10848 final Phylogeny species8 = factory
10849 .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,"
10850 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10851 new NHXParser() )[ 0 ];
10852 final Phylogeny gene8 = factory
10853 .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],"
10854 + "(((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],"
10855 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10856 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10857 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10858 new NHXParser() )[ 0 ];
10859 species8.setRooted( true );
10860 gene8.setRooted( true );
10861 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10862 if ( sdi_unrooted.getCount() != 1 ) {
10865 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10868 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10871 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10874 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10877 if ( !p8[ 0 ].getRoot().isDuplication() ) {
10880 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10883 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10886 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10889 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10892 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10895 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10898 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10903 catch ( final Exception e ) {
10904 e.printStackTrace( System.out );
10910 private static boolean testSequenceDbWsTools1() {
10912 final PhylogenyNode n = new PhylogenyNode();
10913 n.setName( "NP_001025424" );
10914 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10915 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10916 || !acc.getValue().equals( "NP_001025424" ) ) {
10919 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10920 acc = SequenceDbWsTools.obtainSeqAccession( n );
10921 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10922 || !acc.getValue().equals( "NP_001025424" ) ) {
10925 n.setName( "NP_001025424.1" );
10926 acc = SequenceDbWsTools.obtainSeqAccession( n );
10927 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10928 || !acc.getValue().equals( "NP_001025424" ) ) {
10931 n.setName( "NM_001030253" );
10932 acc = SequenceDbWsTools.obtainSeqAccession( n );
10933 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10934 || !acc.getValue().equals( "NM_001030253" ) ) {
10937 n.setName( "BCL2_HUMAN" );
10938 acc = SequenceDbWsTools.obtainSeqAccession( n );
10939 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10940 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10941 System.out.println( acc.toString() );
10944 n.setName( "P10415" );
10945 acc = SequenceDbWsTools.obtainSeqAccession( n );
10946 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10947 || !acc.getValue().equals( "P10415" ) ) {
10948 System.out.println( acc.toString() );
10951 n.setName( " P10415 " );
10952 acc = SequenceDbWsTools.obtainSeqAccession( n );
10953 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10954 || !acc.getValue().equals( "P10415" ) ) {
10955 System.out.println( acc.toString() );
10958 n.setName( "_P10415|" );
10959 acc = SequenceDbWsTools.obtainSeqAccession( n );
10960 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10961 || !acc.getValue().equals( "P10415" ) ) {
10962 System.out.println( acc.toString() );
10965 n.setName( "AY695820" );
10966 acc = SequenceDbWsTools.obtainSeqAccession( n );
10967 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10968 || !acc.getValue().equals( "AY695820" ) ) {
10969 System.out.println( acc.toString() );
10972 n.setName( "_AY695820_" );
10973 acc = SequenceDbWsTools.obtainSeqAccession( n );
10974 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10975 || !acc.getValue().equals( "AY695820" ) ) {
10976 System.out.println( acc.toString() );
10979 n.setName( "AAA59452" );
10980 acc = SequenceDbWsTools.obtainSeqAccession( n );
10981 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10982 || !acc.getValue().equals( "AAA59452" ) ) {
10983 System.out.println( acc.toString() );
10986 n.setName( "_AAA59452_" );
10987 acc = SequenceDbWsTools.obtainSeqAccession( n );
10988 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10989 || !acc.getValue().equals( "AAA59452" ) ) {
10990 System.out.println( acc.toString() );
10993 n.setName( "AAA59452.1" );
10994 acc = SequenceDbWsTools.obtainSeqAccession( n );
10995 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10996 || !acc.getValue().equals( "AAA59452.1" ) ) {
10997 System.out.println( acc.toString() );
11000 n.setName( "_AAA59452.1_" );
11001 acc = SequenceDbWsTools.obtainSeqAccession( n );
11002 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11003 || !acc.getValue().equals( "AAA59452.1" ) ) {
11004 System.out.println( acc.toString() );
11007 n.setName( "GI:94894583" );
11008 acc = SequenceDbWsTools.obtainSeqAccession( n );
11009 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11010 || !acc.getValue().equals( "94894583" ) ) {
11011 System.out.println( acc.toString() );
11014 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11015 acc = SequenceDbWsTools.obtainSeqAccession( n );
11016 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11017 || !acc.getValue().equals( "71845847" ) ) {
11018 System.out.println( acc.toString() );
11021 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11022 acc = SequenceDbWsTools.obtainSeqAccession( n );
11023 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11024 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11025 System.out.println( acc.toString() );
11029 catch ( final Exception e ) {
11035 private static boolean testSequenceDbWsTools2() {
11037 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11038 SequenceDbWsTools.obtainSeqInformation( n1 );
11039 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11042 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11045 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11048 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11051 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11052 SequenceDbWsTools.obtainSeqInformation( n2 );
11053 if ( !n2.getNodeData().getSequence().getName()
11054 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
11057 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11060 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11063 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11066 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11067 SequenceDbWsTools.obtainSeqInformation( n3 );
11068 if ( !n3.getNodeData().getSequence().getName()
11069 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11072 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11075 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11078 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11082 catch ( final IOException e ) {
11083 System.out.println();
11084 System.out.println( "the following might be due to absence internet connection:" );
11085 e.printStackTrace( System.out );
11088 catch ( final Exception e ) {
11089 e.printStackTrace();
11095 private static boolean testSequenceIdParsing() {
11097 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11098 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11099 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11100 if ( id != null ) {
11101 System.out.println( "value =" + id.getValue() );
11102 System.out.println( "provider=" + id.getSource() );
11107 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11108 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11109 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11110 if ( id != null ) {
11111 System.out.println( "value =" + id.getValue() );
11112 System.out.println( "provider=" + id.getSource() );
11117 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11118 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11119 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11120 if ( id != null ) {
11121 System.out.println( "value =" + id.getValue() );
11122 System.out.println( "provider=" + id.getSource() );
11127 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11128 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11129 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11130 if ( id != null ) {
11131 System.out.println( "value =" + id.getValue() );
11132 System.out.println( "provider=" + id.getSource() );
11137 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11138 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11139 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11140 if ( id != null ) {
11141 System.out.println( "value =" + id.getValue() );
11142 System.out.println( "provider=" + id.getSource() );
11147 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11148 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11149 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11150 if ( id != null ) {
11151 System.out.println( "value =" + id.getValue() );
11152 System.out.println( "provider=" + id.getSource() );
11157 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11158 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11159 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11160 if ( id != null ) {
11161 System.out.println( "value =" + id.getValue() );
11162 System.out.println( "provider=" + id.getSource() );
11167 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11168 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11169 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11170 if ( id != null ) {
11171 System.out.println( "value =" + id.getValue() );
11172 System.out.println( "provider=" + id.getSource() );
11177 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11178 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11179 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11180 if ( id != null ) {
11181 System.out.println( "value =" + id.getValue() );
11182 System.out.println( "provider=" + id.getSource() );
11187 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11188 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11189 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11190 if ( id != null ) {
11191 System.out.println( "value =" + id.getValue() );
11192 System.out.println( "provider=" + id.getSource() );
11196 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11197 if ( id != null ) {
11198 System.out.println( "value =" + id.getValue() );
11199 System.out.println( "provider=" + id.getSource() );
11203 catch ( final Exception e ) {
11204 e.printStackTrace( System.out );
11210 private static boolean testSequenceWriter() {
11212 final String n = ForesterUtil.LINE_SEPARATOR;
11213 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11216 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11219 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11222 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11225 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11226 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11229 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11230 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11234 catch ( final Exception e ) {
11235 e.printStackTrace();
11241 private static boolean testSpecies() {
11243 final Species s1 = new BasicSpecies( "a" );
11244 final Species s2 = new BasicSpecies( "a" );
11245 final Species s3 = new BasicSpecies( "A" );
11246 final Species s4 = new BasicSpecies( "b" );
11247 if ( !s1.equals( s1 ) ) {
11250 if ( s1.getSpeciesId().equals( "x" ) ) {
11253 if ( s1.getSpeciesId().equals( null ) ) {
11256 if ( !s1.equals( s2 ) ) {
11259 if ( s1.equals( s3 ) ) {
11262 if ( s1.hashCode() != s1.hashCode() ) {
11265 if ( s1.hashCode() != s2.hashCode() ) {
11268 if ( s1.hashCode() == s3.hashCode() ) {
11271 if ( s1.compareTo( s1 ) != 0 ) {
11274 if ( s1.compareTo( s2 ) != 0 ) {
11277 if ( s1.compareTo( s3 ) != 0 ) {
11280 if ( s1.compareTo( s4 ) >= 0 ) {
11283 if ( s4.compareTo( s1 ) <= 0 ) {
11286 if ( !s4.getSpeciesId().equals( "b" ) ) {
11289 final Species s5 = new BasicSpecies( " C " );
11290 if ( !s5.getSpeciesId().equals( "C" ) ) {
11293 if ( s5.equals( s1 ) ) {
11297 catch ( final Exception e ) {
11298 e.printStackTrace( System.out );
11304 private static boolean testSplit() {
11306 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11307 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11308 //Archaeopteryx.createApplication( p0 );
11309 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11310 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11311 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11312 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11313 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11314 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11315 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11316 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11317 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11318 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11319 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11320 // System.out.println( s0.toString() );
11322 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11323 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11324 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11325 if ( s0.match( query_nodes ) ) {
11328 query_nodes = new HashSet<PhylogenyNode>();
11329 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11330 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11331 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11332 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11333 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11334 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11335 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11336 if ( !s0.match( query_nodes ) ) {
11340 query_nodes = new HashSet<PhylogenyNode>();
11341 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11342 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11343 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11344 if ( !s0.match( query_nodes ) ) {
11348 query_nodes = new HashSet<PhylogenyNode>();
11349 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11350 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11351 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11352 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11353 if ( !s0.match( query_nodes ) ) {
11357 query_nodes = new HashSet<PhylogenyNode>();
11358 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11359 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11360 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11361 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11362 if ( !s0.match( query_nodes ) ) {
11366 query_nodes = new HashSet<PhylogenyNode>();
11367 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11368 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11369 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11370 if ( !s0.match( query_nodes ) ) {
11374 query_nodes = new HashSet<PhylogenyNode>();
11375 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11376 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11377 if ( !s0.match( query_nodes ) ) {
11381 query_nodes = new HashSet<PhylogenyNode>();
11382 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11383 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11384 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11385 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11386 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11387 if ( !s0.match( query_nodes ) ) {
11391 query_nodes = new HashSet<PhylogenyNode>();
11392 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11393 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11394 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11395 if ( !s0.match( query_nodes ) ) {
11399 query_nodes = new HashSet<PhylogenyNode>();
11400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11401 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11402 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11403 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11404 if ( !s0.match( query_nodes ) ) {
11408 query_nodes = new HashSet<PhylogenyNode>();
11409 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11410 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11411 if ( s0.match( query_nodes ) ) {
11415 query_nodes = new HashSet<PhylogenyNode>();
11416 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11417 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11418 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11419 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11420 if ( s0.match( query_nodes ) ) {
11424 query_nodes = new HashSet<PhylogenyNode>();
11425 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11426 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11427 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11428 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11429 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11430 if ( s0.match( query_nodes ) ) {
11434 query_nodes = new HashSet<PhylogenyNode>();
11435 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11436 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11437 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11438 if ( s0.match( query_nodes ) ) {
11442 query_nodes = new HashSet<PhylogenyNode>();
11443 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11444 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11445 if ( s0.match( query_nodes ) ) {
11449 query_nodes = new HashSet<PhylogenyNode>();
11450 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11451 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11452 if ( s0.match( query_nodes ) ) {
11456 query_nodes = new HashSet<PhylogenyNode>();
11457 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11458 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11459 if ( s0.match( query_nodes ) ) {
11463 query_nodes = new HashSet<PhylogenyNode>();
11464 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11465 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11466 if ( s0.match( query_nodes ) ) {
11470 query_nodes = new HashSet<PhylogenyNode>();
11471 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11472 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11473 if ( s0.match( query_nodes ) ) {
11477 query_nodes = new HashSet<PhylogenyNode>();
11478 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11479 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11480 if ( s0.match( query_nodes ) ) {
11484 query_nodes = new HashSet<PhylogenyNode>();
11485 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11486 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11487 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11488 if ( s0.match( query_nodes ) ) {
11492 query_nodes = new HashSet<PhylogenyNode>();
11493 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11494 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11495 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11496 if ( s0.match( query_nodes ) ) {
11500 query_nodes = new HashSet<PhylogenyNode>();
11501 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11502 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11503 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11504 if ( s0.match( query_nodes ) ) {
11508 query_nodes = new HashSet<PhylogenyNode>();
11509 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11510 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11511 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11512 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11513 if ( s0.match( query_nodes ) ) {
11517 // query_nodes = new HashSet<PhylogenyNode>();
11518 // query_nodes.add( new PhylogenyNode( "X" ) );
11519 // query_nodes.add( new PhylogenyNode( "Y" ) );
11520 // query_nodes.add( new PhylogenyNode( "A" ) );
11521 // query_nodes.add( new PhylogenyNode( "B" ) );
11522 // query_nodes.add( new PhylogenyNode( "C" ) );
11523 // query_nodes.add( new PhylogenyNode( "D" ) );
11524 // query_nodes.add( new PhylogenyNode( "E" ) );
11525 // query_nodes.add( new PhylogenyNode( "F" ) );
11526 // query_nodes.add( new PhylogenyNode( "G" ) );
11527 // if ( !s0.match( query_nodes ) ) {
11530 // query_nodes = new HashSet<PhylogenyNode>();
11531 // query_nodes.add( new PhylogenyNode( "X" ) );
11532 // query_nodes.add( new PhylogenyNode( "Y" ) );
11533 // query_nodes.add( new PhylogenyNode( "A" ) );
11534 // query_nodes.add( new PhylogenyNode( "B" ) );
11535 // query_nodes.add( new PhylogenyNode( "C" ) );
11536 // if ( !s0.match( query_nodes ) ) {
11540 // query_nodes = new HashSet<PhylogenyNode>();
11541 // query_nodes.add( new PhylogenyNode( "X" ) );
11542 // query_nodes.add( new PhylogenyNode( "Y" ) );
11543 // query_nodes.add( new PhylogenyNode( "D" ) );
11544 // query_nodes.add( new PhylogenyNode( "E" ) );
11545 // query_nodes.add( new PhylogenyNode( "F" ) );
11546 // query_nodes.add( new PhylogenyNode( "G" ) );
11547 // if ( !s0.match( query_nodes ) ) {
11551 // query_nodes = new HashSet<PhylogenyNode>();
11552 // query_nodes.add( new PhylogenyNode( "X" ) );
11553 // query_nodes.add( new PhylogenyNode( "Y" ) );
11554 // query_nodes.add( new PhylogenyNode( "A" ) );
11555 // query_nodes.add( new PhylogenyNode( "B" ) );
11556 // query_nodes.add( new PhylogenyNode( "C" ) );
11557 // query_nodes.add( new PhylogenyNode( "D" ) );
11558 // if ( !s0.match( query_nodes ) ) {
11562 // query_nodes = new HashSet<PhylogenyNode>();
11563 // query_nodes.add( new PhylogenyNode( "X" ) );
11564 // query_nodes.add( new PhylogenyNode( "Y" ) );
11565 // query_nodes.add( new PhylogenyNode( "E" ) );
11566 // query_nodes.add( new PhylogenyNode( "F" ) );
11567 // query_nodes.add( new PhylogenyNode( "G" ) );
11568 // if ( !s0.match( query_nodes ) ) {
11572 // query_nodes = new HashSet<PhylogenyNode>();
11573 // query_nodes.add( new PhylogenyNode( "X" ) );
11574 // query_nodes.add( new PhylogenyNode( "Y" ) );
11575 // query_nodes.add( new PhylogenyNode( "F" ) );
11576 // query_nodes.add( new PhylogenyNode( "G" ) );
11577 // if ( !s0.match( query_nodes ) ) {
11581 query_nodes = new HashSet<PhylogenyNode>();
11582 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11583 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11584 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11585 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11586 if ( s0.match( query_nodes ) ) {
11590 query_nodes = new HashSet<PhylogenyNode>();
11591 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11592 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11593 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11594 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11595 if ( s0.match( query_nodes ) ) {
11598 ///////////////////////////
11600 query_nodes = new HashSet<PhylogenyNode>();
11601 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11602 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11603 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11604 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11605 if ( s0.match( query_nodes ) ) {
11609 query_nodes = new HashSet<PhylogenyNode>();
11610 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11611 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11612 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11613 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11614 if ( s0.match( query_nodes ) ) {
11618 query_nodes = new HashSet<PhylogenyNode>();
11619 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11620 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11621 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11622 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11623 if ( s0.match( query_nodes ) ) {
11627 query_nodes = new HashSet<PhylogenyNode>();
11628 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11629 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11630 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11632 if ( s0.match( query_nodes ) ) {
11636 query_nodes = new HashSet<PhylogenyNode>();
11637 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11638 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11639 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11640 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11641 if ( s0.match( query_nodes ) ) {
11645 query_nodes = new HashSet<PhylogenyNode>();
11646 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11647 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11648 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11649 if ( s0.match( query_nodes ) ) {
11653 query_nodes = new HashSet<PhylogenyNode>();
11654 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11655 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11656 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11657 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11658 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11659 if ( s0.match( query_nodes ) ) {
11663 query_nodes = new HashSet<PhylogenyNode>();
11664 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11665 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11666 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11667 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11668 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11669 if ( s0.match( query_nodes ) ) {
11673 query_nodes = new HashSet<PhylogenyNode>();
11674 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11675 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11676 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11677 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11678 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11679 if ( s0.match( query_nodes ) ) {
11683 query_nodes = new HashSet<PhylogenyNode>();
11684 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11685 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11686 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11687 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11688 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11689 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11690 if ( s0.match( query_nodes ) ) {
11694 catch ( final Exception e ) {
11695 e.printStackTrace();
11701 private static boolean testSplitStrict() {
11703 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11704 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11705 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11706 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11707 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11708 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11709 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11710 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11711 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11712 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11713 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11714 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11715 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11716 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11717 if ( s0.match( query_nodes ) ) {
11720 query_nodes = new HashSet<PhylogenyNode>();
11721 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11722 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11723 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11724 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11725 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11726 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11727 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11728 if ( !s0.match( query_nodes ) ) {
11732 query_nodes = new HashSet<PhylogenyNode>();
11733 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11734 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11735 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11736 if ( !s0.match( query_nodes ) ) {
11740 query_nodes = new HashSet<PhylogenyNode>();
11741 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11742 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11743 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11744 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11745 if ( !s0.match( query_nodes ) ) {
11749 query_nodes = new HashSet<PhylogenyNode>();
11750 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11751 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11752 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11753 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11754 if ( !s0.match( query_nodes ) ) {
11758 query_nodes = new HashSet<PhylogenyNode>();
11759 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11760 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11761 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11762 if ( !s0.match( query_nodes ) ) {
11766 query_nodes = new HashSet<PhylogenyNode>();
11767 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11768 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11769 if ( !s0.match( query_nodes ) ) {
11773 query_nodes = new HashSet<PhylogenyNode>();
11774 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11775 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11776 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11777 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11778 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11779 if ( !s0.match( query_nodes ) ) {
11783 query_nodes = new HashSet<PhylogenyNode>();
11784 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11785 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11786 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11787 if ( !s0.match( query_nodes ) ) {
11791 query_nodes = new HashSet<PhylogenyNode>();
11792 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11793 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11794 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11795 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11796 if ( !s0.match( query_nodes ) ) {
11800 query_nodes = new HashSet<PhylogenyNode>();
11801 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11802 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11803 if ( s0.match( query_nodes ) ) {
11807 query_nodes = new HashSet<PhylogenyNode>();
11808 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11809 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11810 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11811 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11812 if ( s0.match( query_nodes ) ) {
11816 query_nodes = new HashSet<PhylogenyNode>();
11817 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11818 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11819 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11820 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11821 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11822 if ( s0.match( query_nodes ) ) {
11826 query_nodes = new HashSet<PhylogenyNode>();
11827 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11828 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11829 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11830 if ( s0.match( query_nodes ) ) {
11834 query_nodes = new HashSet<PhylogenyNode>();
11835 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11836 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11837 if ( s0.match( query_nodes ) ) {
11841 query_nodes = new HashSet<PhylogenyNode>();
11842 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11843 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11844 if ( s0.match( query_nodes ) ) {
11848 query_nodes = new HashSet<PhylogenyNode>();
11849 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11850 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11851 if ( s0.match( query_nodes ) ) {
11855 query_nodes = new HashSet<PhylogenyNode>();
11856 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11857 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11858 if ( s0.match( query_nodes ) ) {
11862 query_nodes = new HashSet<PhylogenyNode>();
11863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11864 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11865 if ( s0.match( query_nodes ) ) {
11869 query_nodes = new HashSet<PhylogenyNode>();
11870 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11871 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11872 if ( s0.match( query_nodes ) ) {
11876 query_nodes = new HashSet<PhylogenyNode>();
11877 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11878 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11880 if ( s0.match( query_nodes ) ) {
11884 query_nodes = new HashSet<PhylogenyNode>();
11885 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11886 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11888 if ( s0.match( query_nodes ) ) {
11892 query_nodes = new HashSet<PhylogenyNode>();
11893 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11894 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11895 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11896 if ( s0.match( query_nodes ) ) {
11900 query_nodes = new HashSet<PhylogenyNode>();
11901 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11902 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11903 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11904 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11905 if ( s0.match( query_nodes ) ) {
11909 catch ( final Exception e ) {
11910 e.printStackTrace();
11916 private static boolean testSubtreeDeletion() {
11918 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11919 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11920 t1.deleteSubtree( t1.getNode( "A" ), false );
11921 if ( t1.getNumberOfExternalNodes() != 5 ) {
11924 t1.toNewHampshireX();
11925 t1.deleteSubtree( t1.getNode( "E" ), false );
11926 if ( t1.getNumberOfExternalNodes() != 4 ) {
11929 t1.toNewHampshireX();
11930 t1.deleteSubtree( t1.getNode( "F" ), false );
11931 if ( t1.getNumberOfExternalNodes() != 3 ) {
11934 t1.toNewHampshireX();
11935 t1.deleteSubtree( t1.getNode( "D" ), false );
11936 t1.toNewHampshireX();
11937 if ( t1.getNumberOfExternalNodes() != 3 ) {
11940 t1.deleteSubtree( t1.getNode( "def" ), false );
11941 t1.toNewHampshireX();
11942 if ( t1.getNumberOfExternalNodes() != 2 ) {
11945 t1.deleteSubtree( t1.getNode( "B" ), false );
11946 t1.toNewHampshireX();
11947 if ( t1.getNumberOfExternalNodes() != 1 ) {
11950 t1.deleteSubtree( t1.getNode( "C" ), false );
11951 t1.toNewHampshireX();
11952 if ( t1.getNumberOfExternalNodes() != 1 ) {
11955 t1.deleteSubtree( t1.getNode( "abc" ), false );
11956 t1.toNewHampshireX();
11957 if ( t1.getNumberOfExternalNodes() != 1 ) {
11960 t1.deleteSubtree( t1.getNode( "r" ), false );
11961 if ( t1.getNumberOfExternalNodes() != 0 ) {
11964 if ( !t1.isEmpty() ) {
11967 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11968 t2.deleteSubtree( t2.getNode( "A" ), false );
11969 t2.toNewHampshireX();
11970 if ( t2.getNumberOfExternalNodes() != 5 ) {
11973 t2.deleteSubtree( t2.getNode( "abc" ), false );
11974 t2.toNewHampshireX();
11975 if ( t2.getNumberOfExternalNodes() != 3 ) {
11978 t2.deleteSubtree( t2.getNode( "def" ), false );
11979 t2.toNewHampshireX();
11980 if ( t2.getNumberOfExternalNodes() != 1 ) {
11984 catch ( final Exception e ) {
11985 e.printStackTrace( System.out );
11991 private static boolean testSupportCount() {
11993 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11994 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
11995 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
11996 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
11997 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
11998 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
11999 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12001 SupportCount.count( t0_1, phylogenies_1, true, false );
12002 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12003 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12004 + "(((((A,B),C),D),E),((F,G),X))"
12005 + "(((((A,Y),B),C),D),((F,G),E))"
12006 + "(((((A,B),C),D),E),(F,G))"
12007 + "(((((A,B),C),D),E),(F,G))"
12008 + "(((((A,B),C),D),E),(F,G))"
12009 + "(((((A,B),C),D),E),(F,G),Z)"
12010 + "(((((A,B),C),D),E),(F,G))"
12011 + "((((((A,B),C),D),E),F),G)"
12012 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12014 SupportCount.count( t0_2, phylogenies_2, true, false );
12015 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12016 while ( it.hasNext() ) {
12017 final PhylogenyNode n = it.next();
12018 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12022 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12023 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12024 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12025 SupportCount.count( t0_3, phylogenies_3, true, false );
12026 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12027 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12030 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12033 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12036 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12039 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12042 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12045 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12048 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12051 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12054 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12057 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12058 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12059 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12060 SupportCount.count( t0_4, phylogenies_4, true, false );
12061 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12062 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12065 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12068 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12071 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12074 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12077 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12080 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12083 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12086 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12089 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12092 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12093 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12094 double d = SupportCount.compare( b1, a, true, true, true );
12095 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12098 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12099 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12100 d = SupportCount.compare( b2, a, true, true, true );
12101 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12104 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12105 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12106 d = SupportCount.compare( b3, a, true, true, true );
12107 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12110 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12111 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12112 d = SupportCount.compare( b4, a, true, true, false );
12113 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12117 catch ( final Exception e ) {
12118 e.printStackTrace( System.out );
12124 private static boolean testSupportTransfer() {
12126 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12127 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)",
12128 new NHXParser() )[ 0 ];
12129 final Phylogeny p2 = factory
12130 .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 ];
12131 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12134 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12137 support_transfer.moveBranchLengthsToBootstrap( p1 );
12138 support_transfer.transferSupportValues( p1, p2 );
12139 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12142 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12145 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12148 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12151 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12154 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12157 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12160 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12164 catch ( final Exception e ) {
12165 e.printStackTrace( System.out );
12171 private static boolean testTaxonomyExtraction() {
12173 final PhylogenyNode n0 = PhylogenyNode
12174 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12175 if ( n0.getNodeData().isHasTaxonomy() ) {
12178 final PhylogenyNode n1 = PhylogenyNode
12179 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12180 if ( n1.getNodeData().isHasTaxonomy() ) {
12181 System.out.println( n1.toString() );
12184 final PhylogenyNode n2x = PhylogenyNode
12185 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12186 if ( n2x.getNodeData().isHasTaxonomy() ) {
12189 final PhylogenyNode n3 = PhylogenyNode
12190 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12191 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12192 System.out.println( n3.toString() );
12195 final PhylogenyNode n4 = PhylogenyNode
12196 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12197 if ( n4.getNodeData().isHasTaxonomy() ) {
12198 System.out.println( n4.toString() );
12201 final PhylogenyNode n5 = PhylogenyNode
12202 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12203 if ( n5.getNodeData().isHasTaxonomy() ) {
12204 System.out.println( n5.toString() );
12207 final PhylogenyNode n6 = PhylogenyNode
12208 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12209 if ( n6.getNodeData().isHasTaxonomy() ) {
12210 System.out.println( n6.toString() );
12213 final PhylogenyNode n7 = PhylogenyNode
12214 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12215 if ( n7.getNodeData().isHasTaxonomy() ) {
12216 System.out.println( n7.toString() );
12219 final PhylogenyNode n8 = PhylogenyNode
12220 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12221 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12222 System.out.println( n8.toString() );
12225 final PhylogenyNode n9 = PhylogenyNode
12226 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12227 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12228 System.out.println( n9.toString() );
12231 final PhylogenyNode n10x = PhylogenyNode
12232 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12233 if ( n10x.getNodeData().isHasTaxonomy() ) {
12234 System.out.println( n10x.toString() );
12237 final PhylogenyNode n10xx = PhylogenyNode
12238 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12239 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12240 System.out.println( n10xx.toString() );
12243 final PhylogenyNode n10 = PhylogenyNode
12244 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12245 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12246 System.out.println( n10.toString() );
12249 final PhylogenyNode n11 = PhylogenyNode
12250 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12251 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12252 System.out.println( n11.toString() );
12255 final PhylogenyNode n12 = PhylogenyNode
12256 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12257 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12258 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12259 System.out.println( n12.toString() );
12262 final PhylogenyNode n13 = PhylogenyNode
12263 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12264 if ( n13.getNodeData().isHasTaxonomy() ) {
12265 System.out.println( n13.toString() );
12268 final PhylogenyNode n14 = PhylogenyNode
12269 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12270 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12271 System.out.println( n14.toString() );
12274 final PhylogenyNode n15 = PhylogenyNode
12275 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12276 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12277 System.out.println( n15.toString() );
12280 final PhylogenyNode n16 = PhylogenyNode
12281 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12282 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12283 System.out.println( n16.toString() );
12286 final PhylogenyNode n17 = PhylogenyNode
12287 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12288 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12289 System.out.println( n17.toString() );
12293 final PhylogenyNode n18 = PhylogenyNode
12294 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12295 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12296 System.out.println( n18.toString() );
12299 final PhylogenyNode n19 = PhylogenyNode
12300 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12301 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12302 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12303 System.out.println( n19.toString() );
12306 final PhylogenyNode n20 = PhylogenyNode
12307 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12308 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12309 System.out.println( n20.toString() );
12312 final PhylogenyNode n21 = PhylogenyNode
12313 .createInstanceFromNhxString( "Mus musculus musculus K392",
12314 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12315 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12316 System.out.println( n21.toString() );
12319 final PhylogenyNode n22 = PhylogenyNode
12320 .createInstanceFromNhxString( "NEMVE_Nematostella_vectensis",
12321 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12322 if ( !n22.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12323 System.out.println( n22.toString() );
12326 final PhylogenyNode n23 = PhylogenyNode
12327 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
12328 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12329 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12330 System.out.println( n23.toString() );
12333 final PhylogenyNode n24 = PhylogenyNode
12334 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12335 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12336 System.out.println( n24.toString() );
12340 final PhylogenyNode n25 = PhylogenyNode
12341 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
12342 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12343 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12344 System.out.println( n25.toString() );
12347 final PhylogenyNode n26 = PhylogenyNode
12348 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
12349 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12350 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12351 System.out.println( n26.toString() );
12354 final PhylogenyNode n27 = PhylogenyNode
12355 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12356 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12357 System.out.println( n27.toString() );
12361 catch ( final Exception e ) {
12362 e.printStackTrace( System.out );
12368 private static boolean testTreeCopy() {
12370 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12371 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12372 final Phylogeny t1 = t0.copy();
12373 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12376 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12379 t0.deleteSubtree( t0.getNode( "c" ), true );
12380 t0.deleteSubtree( t0.getNode( "a" ), true );
12381 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12382 t0.getNode( "b" ).setName( "Bee" );
12383 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12386 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12389 t0.deleteSubtree( t0.getNode( "e" ), true );
12390 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12391 t0.deleteSubtree( t0.getNode( "d" ), true );
12392 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12396 catch ( final Exception e ) {
12397 e.printStackTrace();
12403 private static boolean testTreeMethods() {
12405 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12406 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12407 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12408 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12409 System.out.println( t0.toNewHampshireX() );
12412 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12413 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12414 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12417 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12420 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12424 catch ( final Exception e ) {
12425 e.printStackTrace( System.out );
12431 private static boolean testUniprotEntryRetrieval() {
12433 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
12434 if ( !entry.getAccession().equals( "P12345" ) ) {
12437 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12440 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12443 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12446 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12449 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12453 catch ( final IOException e ) {
12454 System.out.println();
12455 System.out.println( "the following might be due to absence internet connection:" );
12456 e.printStackTrace( System.out );
12459 catch ( final Exception e ) {
12465 private static boolean testUniprotTaxonomySearch() {
12467 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12469 if ( results.size() != 1 ) {
12472 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12475 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12478 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12481 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12484 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12488 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12489 if ( results.size() != 1 ) {
12492 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12495 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12498 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12501 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12504 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12508 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12509 if ( results.size() != 1 ) {
12512 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12515 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12518 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12521 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12524 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12528 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12529 if ( results.size() != 1 ) {
12532 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12535 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12538 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12541 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12544 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12547 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12550 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12553 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12554 .equals( "Nematostella vectensis" ) ) {
12555 System.out.println( results.get( 0 ).getLineage() );
12560 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12561 if ( results.size() != 1 ) {
12564 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12567 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12570 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12573 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12576 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12579 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12580 .equals( "Xenopus tropicalis" ) ) {
12581 System.out.println( results.get( 0 ).getLineage() );
12586 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12587 if ( results.size() != 1 ) {
12590 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12593 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12596 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12599 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12602 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12605 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12606 .equals( "Xenopus tropicalis" ) ) {
12607 System.out.println( results.get( 0 ).getLineage() );
12612 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12613 if ( results.size() != 1 ) {
12616 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12619 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12622 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12625 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12628 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12631 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12632 .equals( "Xenopus tropicalis" ) ) {
12633 System.out.println( results.get( 0 ).getLineage() );
12637 catch ( final IOException e ) {
12638 System.out.println();
12639 System.out.println( "the following might be due to absence internet connection:" );
12640 e.printStackTrace( System.out );
12643 catch ( final Exception e ) {
12649 private static boolean testWabiTxSearch() {
12651 String result = "";
12652 result = TxSearch.searchSimple( "nematostella" );
12653 result = TxSearch.getTxId( "nematostella" );
12654 if ( !result.equals( "45350" ) ) {
12657 result = TxSearch.getTxName( "45350" );
12658 if ( !result.equals( "Nematostella" ) ) {
12661 result = TxSearch.getTxId( "nematostella vectensis" );
12662 if ( !result.equals( "45351" ) ) {
12665 result = TxSearch.getTxName( "45351" );
12666 if ( !result.equals( "Nematostella vectensis" ) ) {
12669 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12670 if ( !result.equals( "536089" ) ) {
12673 result = TxSearch.getTxName( "536089" );
12674 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12677 final List<String> queries = new ArrayList<String>();
12678 queries.add( "Campylobacter coli" );
12679 queries.add( "Escherichia coli" );
12680 queries.add( "Arabidopsis" );
12681 queries.add( "Trichoplax" );
12682 queries.add( "Samanea saman" );
12683 queries.add( "Kluyveromyces marxianus" );
12684 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12685 queries.add( "Bornavirus parrot/PDD/2008" );
12686 final List<RANKS> ranks = new ArrayList<RANKS>();
12687 ranks.add( RANKS.SUPERKINGDOM );
12688 ranks.add( RANKS.KINGDOM );
12689 ranks.add( RANKS.FAMILY );
12690 ranks.add( RANKS.GENUS );
12691 ranks.add( RANKS.TRIBE );
12692 result = TxSearch.searchLineage( queries, ranks );
12693 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12694 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12696 catch ( final Exception e ) {
12697 System.out.println();
12698 System.out.println( "the following might be due to absence internet connection:" );
12699 e.printStackTrace( System.out );