2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
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 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.test;
28 import java.io.ByteArrayInputStream;
30 import java.io.FileInputStream;
31 import java.io.IOException;
33 import java.util.ArrayList;
34 import java.util.Date;
35 import java.util.HashSet;
36 import java.util.Iterator;
37 import java.util.List;
38 import java.util.Locale;
40 import java.util.SortedSet;
42 import org.forester.application.support_transfer;
43 import org.forester.archaeopteryx.TreePanelUtil;
44 import org.forester.archaeopteryx.webservices.WebserviceUtil;
45 import org.forester.development.DevelopmentTools;
46 import org.forester.evoinference.TestPhylogenyReconstruction;
47 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
48 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
49 import org.forester.go.TestGo;
50 import org.forester.io.parsers.FastaParser;
51 import org.forester.io.parsers.GeneralMsaParser;
52 import org.forester.io.parsers.HmmscanPerDomainTableParser;
53 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
54 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
55 import org.forester.io.parsers.nexus.NexusCharactersParser;
56 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
57 import org.forester.io.parsers.nhx.NHXParser;
58 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
59 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
60 import org.forester.io.parsers.tol.TolParser;
61 import org.forester.io.parsers.util.ParserUtils;
62 import org.forester.io.writers.PhylogenyWriter;
63 import org.forester.io.writers.SequenceWriter;
64 import org.forester.msa.BasicMsa;
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 if ( PERFORM_DB_TESTS ) {
904 System.out.print( "Uniprot Entry Retrieval: " );
905 if ( Test.testUniprotEntryRetrieval() ) {
906 System.out.println( "OK." );
910 System.out.println( "failed." );
913 System.out.print( "Ebi Entry Retrieval: " );
914 if ( Test.testEbiEntryRetrieval() ) {
915 System.out.println( "OK." );
919 System.out.println( "failed." );
922 System.out.print( "Sequence DB tools 2: " );
923 if ( testSequenceDbWsTools2() ) {
924 System.out.println( "OK." );
928 System.out.println( "failed." );
932 System.out.print( "Uniprot Taxonomy Search: " );
933 if ( Test.testUniprotTaxonomySearch() ) {
934 System.out.println( "OK." );
938 System.out.println( "failed." );
942 if ( PERFORM_WEB_TREE_ACCESS ) {
943 System.out.print( "NHX parsing from URL: " );
944 if ( Test.testNHXparsingFromURL() ) {
945 System.out.println( "OK." );
949 System.out.println( "failed." );
952 System.out.print( "phyloXML parsing from URL: " );
953 if ( Test.testPhyloXMLparsingFromURL() ) {
954 System.out.println( "OK." );
958 System.out.println( "failed." );
961 System.out.print( "TreeBase acccess: " );
962 if ( Test.testTreeBaseReading() ) {
963 System.out.println( "OK." );
967 System.out.println( "failed." );
971 System.out.print( "ToL access: " );
972 if ( Test.testToLReading() ) {
973 System.out.println( "OK." );
977 System.out.println( "failed." );
981 System.out.print( "TreeFam access: " );
982 if ( Test.testTreeFamReading() ) {
983 System.out.println( "OK." );
987 System.out.println( "failed." );
992 System.out.print( "Pfam tree access: " );
993 if ( Test.testPfamTreeReading() ) {
994 System.out.println( "OK." );
998 System.out.println( "failed." );
1002 System.out.println();
1003 final Runtime rt = java.lang.Runtime.getRuntime();
1004 final long free_memory = rt.freeMemory() / 1000000;
1005 final long total_memory = rt.totalMemory() / 1000000;
1006 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1007 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1008 System.out.println();
1009 System.out.println( "Successful tests: " + succeeded );
1010 System.out.println( "Failed tests: " + failed );
1011 System.out.println();
1013 System.out.println( "OK." );
1016 System.out.println( "Not OK." );
1020 public static boolean testEngulfingOverlapRemoval() {
1022 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1023 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1024 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1025 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1026 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1027 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1028 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1029 final List<Boolean> covered = new ArrayList<Boolean>();
1030 covered.add( true ); // 0
1031 covered.add( false ); // 1
1032 covered.add( true ); // 2
1033 covered.add( false ); // 3
1034 covered.add( true ); // 4
1035 covered.add( true ); // 5
1036 covered.add( false ); // 6
1037 covered.add( true ); // 7
1038 covered.add( true ); // 8
1039 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1042 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1045 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1048 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1051 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1054 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1057 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1060 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1061 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1062 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1063 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1064 abc.addProteinDomain( a );
1065 abc.addProteinDomain( b );
1066 abc.addProteinDomain( c );
1067 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1068 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1069 if ( abc.getNumberOfProteinDomains() != 3 ) {
1072 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1075 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1078 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1081 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1084 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1085 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1086 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1087 final Protein def = new BasicProtein( "def", "nemve", 0 );
1088 def.addProteinDomain( d );
1089 def.addProteinDomain( e );
1090 def.addProteinDomain( f );
1091 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1092 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1093 if ( def.getNumberOfProteinDomains() != 3 ) {
1096 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1099 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1102 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1105 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1108 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1112 catch ( final Exception e ) {
1113 e.printStackTrace( System.out );
1119 public static final boolean testNHXparsingFromURL() {
1121 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1122 final URL u = new URL( s );
1123 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1124 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1125 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1128 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1129 System.out.println( phys[ 0 ].toNewHampshire() );
1132 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1133 System.out.println( phys[ 1 ].toNewHampshire() );
1136 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1137 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1140 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1141 System.out.println( phys2[ 0 ].toNewHampshire() );
1144 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1145 final NHXParser p = new NHXParser();
1146 final URL u2 = new URL( s );
1148 if ( !p.hasNext() ) {
1151 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1154 if ( !p.hasNext() ) {
1158 if ( !p.hasNext() ) {
1161 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1164 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
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 catch ( final Exception e ) {
1179 e.printStackTrace();
1184 public static boolean testOverlapRemoval() {
1186 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1187 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1188 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1189 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1190 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1191 final List<Boolean> covered = new ArrayList<Boolean>();
1192 covered.add( true ); // 0
1193 covered.add( false ); // 1
1194 covered.add( true ); // 2
1195 covered.add( false ); // 3
1196 covered.add( true ); // 4
1197 covered.add( true ); // 5
1198 covered.add( false ); // 6
1199 covered.add( true ); // 7
1200 covered.add( true ); // 8
1201 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1204 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1207 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1210 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1213 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1216 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1217 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1218 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1219 ab.addProteinDomain( a );
1220 ab.addProteinDomain( b );
1221 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1222 if ( ab.getNumberOfProteinDomains() != 2 ) {
1225 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1228 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1231 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1232 if ( ab.getNumberOfProteinDomains() != 2 ) {
1235 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1238 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1239 final Domain d = new BasicDomain( "d",
1246 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1247 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1248 cde.addProteinDomain( c );
1249 cde.addProteinDomain( d );
1250 cde.addProteinDomain( e );
1251 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1252 if ( cde.getNumberOfProteinDomains() != 3 ) {
1255 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1258 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1259 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1260 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1261 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1262 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1263 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1264 fghi.addProteinDomain( f );
1265 fghi.addProteinDomain( g );
1266 fghi.addProteinDomain( h );
1267 fghi.addProteinDomain( i );
1268 fghi.addProteinDomain( i );
1269 fghi.addProteinDomain( i );
1270 fghi.addProteinDomain( i2 );
1271 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1272 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1275 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1278 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1281 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1282 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1285 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1288 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1289 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1290 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1291 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1292 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1293 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1294 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1295 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1296 jklm.addProteinDomain( j );
1297 jklm.addProteinDomain( k );
1298 jklm.addProteinDomain( l );
1299 jklm.addProteinDomain( m );
1300 jklm.addProteinDomain( m0 );
1301 jklm.addProteinDomain( m1 );
1302 jklm.addProteinDomain( m2 );
1303 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1304 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1307 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1310 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1313 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1314 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1317 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1320 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1321 final Protein od = new BasicProtein( "od", "varanus", 0 );
1322 od.addProteinDomain( only );
1323 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1324 if ( od.getNumberOfProteinDomains() != 1 ) {
1327 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1331 catch ( final Exception e ) {
1332 e.printStackTrace( System.out );
1338 public static final boolean testPfamTreeReading() {
1340 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1341 final NHXParser parser = new NHXParser();
1342 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1343 parser.setReplaceUnderscores( false );
1344 parser.setGuessRootedness( true );
1345 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1346 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1347 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1350 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1354 catch ( final Exception e ) {
1355 e.printStackTrace();
1360 public static final boolean testPhyloXMLparsingFromURL() {
1362 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1363 final URL u = new URL( s );
1364 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1365 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1366 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1370 catch ( final Exception e ) {
1371 e.printStackTrace();
1376 public static final boolean testToLReading() {
1378 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1379 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1380 final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
1381 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1384 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1387 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1390 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1394 catch ( final Exception e ) {
1395 e.printStackTrace();
1400 public static final boolean testTreeBaseReading() {
1402 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1403 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1404 parser.setReplaceUnderscores( true );
1405 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1406 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1407 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1410 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1411 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1412 parser2.setReplaceUnderscores( true );
1413 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1414 final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
1415 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1419 catch ( final Exception e ) {
1420 e.printStackTrace();
1425 public static final boolean testTreeFamReading() {
1427 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1428 final NHXParser parser = new NHXParser();
1429 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1430 parser.setReplaceUnderscores( false );
1431 parser.setGuessRootedness( true );
1432 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1433 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1434 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1437 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1441 catch ( final Exception e ) {
1442 e.printStackTrace();
1447 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1448 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1452 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1453 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1456 private static boolean testAminoAcidSequence() {
1458 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1459 if ( aa1.getLength() != 13 ) {
1462 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1465 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1468 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1471 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1472 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1475 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1476 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1479 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1480 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1484 catch ( final Exception e ) {
1485 e.printStackTrace();
1491 private static boolean testBasicDomain() {
1493 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1494 if ( !pd.getDomainId().equals( "id" ) ) {
1497 if ( pd.getNumber() != 1 ) {
1500 if ( pd.getTotalCount() != 4 ) {
1503 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1506 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1507 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1508 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1509 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1510 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1511 if ( !a1.equals( a1 ) ) {
1514 if ( !a1.equals( a1_copy ) ) {
1517 if ( !a1.equals( a1_equal ) ) {
1520 if ( !a1.equals( a2 ) ) {
1523 if ( a1.equals( a3 ) ) {
1526 if ( a1.compareTo( a1 ) != 0 ) {
1529 if ( a1.compareTo( a1_copy ) != 0 ) {
1532 if ( a1.compareTo( a1_equal ) != 0 ) {
1535 if ( a1.compareTo( a2 ) != 0 ) {
1538 if ( a1.compareTo( a3 ) == 0 ) {
1542 catch ( final Exception e ) {
1543 e.printStackTrace( System.out );
1549 private static boolean testBasicNodeMethods() {
1551 if ( PhylogenyNode.getNodeCount() != 0 ) {
1554 final PhylogenyNode n1 = new PhylogenyNode();
1555 final PhylogenyNode n2 = PhylogenyNode
1556 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1557 final PhylogenyNode n3 = PhylogenyNode
1558 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1559 final PhylogenyNode n4 = PhylogenyNode
1560 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1561 if ( n1.isHasAssignedEvent() ) {
1564 if ( PhylogenyNode.getNodeCount() != 4 ) {
1567 if ( n3.getIndicator() != 0 ) {
1570 if ( n3.getNumberOfExternalNodes() != 1 ) {
1573 if ( !n3.isExternal() ) {
1576 if ( !n3.isRoot() ) {
1579 if ( !n4.getName().equals( "n4" ) ) {
1583 catch ( final Exception e ) {
1584 e.printStackTrace( System.out );
1590 private static boolean testBasicPhyloXMLparsing() {
1592 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1593 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1594 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1596 if ( xml_parser.getErrorCount() > 0 ) {
1597 System.out.println( xml_parser.getErrorMessages().toString() );
1600 if ( phylogenies_0.length != 4 ) {
1603 final Phylogeny t1 = phylogenies_0[ 0 ];
1604 final Phylogeny t2 = phylogenies_0[ 1 ];
1605 final Phylogeny t3 = phylogenies_0[ 2 ];
1606 final Phylogeny t4 = phylogenies_0[ 3 ];
1607 if ( t1.getNumberOfExternalNodes() != 1 ) {
1610 if ( !t1.isRooted() ) {
1613 if ( t1.isRerootable() ) {
1616 if ( !t1.getType().equals( "gene_tree" ) ) {
1619 if ( t2.getNumberOfExternalNodes() != 2 ) {
1622 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1625 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1628 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1631 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1634 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1637 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1640 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1641 .startsWith( "actgtgggggt" ) ) {
1644 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1645 .startsWith( "ctgtgatgcat" ) ) {
1648 if ( t3.getNumberOfExternalNodes() != 4 ) {
1651 if ( !t1.getName().equals( "t1" ) ) {
1654 if ( !t2.getName().equals( "t2" ) ) {
1657 if ( !t3.getName().equals( "t3" ) ) {
1660 if ( !t4.getName().equals( "t4" ) ) {
1663 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1666 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1669 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1672 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1673 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1676 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1679 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1682 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1685 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1686 .equals( "apoptosis" ) ) {
1689 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1690 .equals( "GO:0006915" ) ) {
1693 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1694 .equals( "UniProtKB" ) ) {
1697 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1698 .equals( "experimental" ) ) {
1701 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1702 .equals( "function" ) ) {
1705 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1706 .getValue() != 1 ) {
1709 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1710 .getType().equals( "ml" ) ) {
1713 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1714 .equals( "apoptosis" ) ) {
1717 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1718 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1721 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1722 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1725 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1726 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1729 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1730 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1733 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1734 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1737 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1738 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1741 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1742 .equals( "GO:0005829" ) ) {
1745 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1746 .equals( "intracellular organelle" ) ) {
1749 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1752 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1753 .equals( "UniProt link" ) ) ) {
1756 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1759 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1760 if ( x.size() != 4 ) {
1764 for( final Accession acc : x ) {
1766 if ( !acc.getSource().equals( "KEGG" ) ) {
1769 if ( !acc.getValue().equals( "hsa:596" ) ) {
1776 catch ( final Exception e ) {
1777 e.printStackTrace( System.out );
1783 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1785 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1786 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1787 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1788 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1791 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1793 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1795 if ( xml_parser.getErrorCount() > 0 ) {
1796 System.out.println( xml_parser.getErrorMessages().toString() );
1799 if ( phylogenies_0.length != 4 ) {
1802 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1803 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1804 if ( phylogenies_t1.length != 1 ) {
1807 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1808 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1811 if ( !t1_rt.isRooted() ) {
1814 if ( t1_rt.isRerootable() ) {
1817 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1820 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1821 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1822 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1823 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1826 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1829 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1832 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1835 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1836 .startsWith( "actgtgggggt" ) ) {
1839 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1840 .startsWith( "ctgtgatgcat" ) ) {
1843 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1844 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1845 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1846 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1847 if ( phylogenies_1.length != 1 ) {
1850 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1851 if ( !t3_rt.getName().equals( "t3" ) ) {
1854 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1857 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1860 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1863 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1866 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1867 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1870 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1873 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1876 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1877 .equals( "UniProtKB" ) ) {
1880 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1881 .equals( "apoptosis" ) ) {
1884 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1885 .equals( "GO:0006915" ) ) {
1888 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1889 .equals( "UniProtKB" ) ) {
1892 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1893 .equals( "experimental" ) ) {
1896 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1897 .equals( "function" ) ) {
1900 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1901 .getValue() != 1 ) {
1904 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1905 .getType().equals( "ml" ) ) {
1908 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1909 .equals( "apoptosis" ) ) {
1912 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1913 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1916 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1917 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1920 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1921 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1924 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1925 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1928 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1929 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1932 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1933 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1936 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1937 .equals( "GO:0005829" ) ) {
1940 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1941 .equals( "intracellular organelle" ) ) {
1944 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1947 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1948 .equals( "UniProt link" ) ) ) {
1951 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1954 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1957 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1958 .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." ) ) ) {
1961 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1964 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1967 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1970 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1973 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1974 .equals( "ncbi" ) ) {
1977 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1980 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1981 .getName().equals( "B" ) ) {
1984 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1985 .getFrom() != 21 ) {
1988 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1991 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1992 .getLength() != 24 ) {
1995 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1996 .getConfidence() != 2144 ) {
1999 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2000 .equals( "pfam" ) ) {
2003 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2006 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2009 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2012 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2015 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2016 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2019 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2022 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2025 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2028 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2031 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2034 if ( taxbb.getSynonyms().size() != 2 ) {
2037 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2040 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2043 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2046 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2049 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2052 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2053 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2056 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2059 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2062 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2065 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2068 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2071 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2074 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2078 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2081 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2082 .equalsIgnoreCase( "435" ) ) {
2085 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2088 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2089 .equalsIgnoreCase( "443.7" ) ) {
2092 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2095 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2098 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2099 .equalsIgnoreCase( "433" ) ) {
2102 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2103 .getCrossReferences();
2104 if ( x.size() != 4 ) {
2108 for( final Accession acc : x ) {
2110 if ( !acc.getSource().equals( "KEGG" ) ) {
2113 if ( !acc.getValue().equals( "hsa:596" ) ) {
2120 catch ( final Exception e ) {
2121 e.printStackTrace( System.out );
2127 private static boolean testBasicPhyloXMLparsingValidating() {
2129 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2130 PhyloXmlParser xml_parser = null;
2132 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2134 catch ( final Exception e ) {
2135 // Do nothing -- means were not running from jar.
2137 if ( xml_parser == null ) {
2138 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2139 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2140 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2143 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2146 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2148 if ( xml_parser.getErrorCount() > 0 ) {
2149 System.out.println( xml_parser.getErrorMessages().toString() );
2152 if ( phylogenies_0.length != 4 ) {
2155 final Phylogeny t1 = phylogenies_0[ 0 ];
2156 final Phylogeny t2 = phylogenies_0[ 1 ];
2157 final Phylogeny t3 = phylogenies_0[ 2 ];
2158 final Phylogeny t4 = phylogenies_0[ 3 ];
2159 if ( !t1.getName().equals( "t1" ) ) {
2162 if ( !t2.getName().equals( "t2" ) ) {
2165 if ( !t3.getName().equals( "t3" ) ) {
2168 if ( !t4.getName().equals( "t4" ) ) {
2171 if ( t1.getNumberOfExternalNodes() != 1 ) {
2174 if ( t2.getNumberOfExternalNodes() != 2 ) {
2177 if ( t3.getNumberOfExternalNodes() != 4 ) {
2180 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2181 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2182 if ( xml_parser.getErrorCount() > 0 ) {
2183 System.out.println( "errors:" );
2184 System.out.println( xml_parser.getErrorMessages().toString() );
2187 if ( phylogenies_1.length != 4 ) {
2190 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2192 if ( xml_parser.getErrorCount() > 0 ) {
2193 System.out.println( "errors:" );
2194 System.out.println( xml_parser.getErrorMessages().toString() );
2197 if ( phylogenies_2.length != 1 ) {
2200 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2203 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2205 if ( xml_parser.getErrorCount() > 0 ) {
2206 System.out.println( xml_parser.getErrorMessages().toString() );
2209 if ( phylogenies_3.length != 2 ) {
2212 final Phylogeny a = phylogenies_3[ 0 ];
2213 if ( !a.getName().equals( "tree 4" ) ) {
2216 if ( a.getNumberOfExternalNodes() != 3 ) {
2219 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2222 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2225 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2227 if ( xml_parser.getErrorCount() > 0 ) {
2228 System.out.println( xml_parser.getErrorMessages().toString() );
2231 if ( phylogenies_4.length != 1 ) {
2234 final Phylogeny s = phylogenies_4[ 0 ];
2235 if ( s.getNumberOfExternalNodes() != 6 ) {
2238 s.getNode( "first" );
2240 s.getNode( "\"<a'b&c'd\">\"" );
2241 s.getNode( "'''\"" );
2242 s.getNode( "\"\"\"" );
2243 s.getNode( "dick & doof" );
2245 catch ( final Exception e ) {
2246 e.printStackTrace( System.out );
2252 private static boolean testBasicProtein() {
2254 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2255 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2256 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2257 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2258 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2259 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2260 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2261 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2262 p0.addProteinDomain( y );
2263 p0.addProteinDomain( e );
2264 p0.addProteinDomain( b );
2265 p0.addProteinDomain( c );
2266 p0.addProteinDomain( d );
2267 p0.addProteinDomain( a );
2268 p0.addProteinDomain( x );
2269 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2272 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2276 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2277 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2278 aa0.addProteinDomain( a1 );
2279 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2282 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2286 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2287 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2288 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2289 aa1.addProteinDomain( a11 );
2290 aa1.addProteinDomain( a12 );
2291 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2294 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2297 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2298 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2301 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2304 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2307 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2308 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2311 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2314 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2317 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2320 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2321 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2324 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2327 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2330 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2333 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2334 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2337 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2340 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2343 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2347 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2348 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2349 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2350 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2351 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2352 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2353 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2354 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2355 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2356 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2357 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2358 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2359 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2360 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2361 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2362 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2363 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2364 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2365 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2366 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2367 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2368 p00.addProteinDomain( y0 );
2369 p00.addProteinDomain( e0 );
2370 p00.addProteinDomain( b0 );
2371 p00.addProteinDomain( c0 );
2372 p00.addProteinDomain( d0 );
2373 p00.addProteinDomain( a0 );
2374 p00.addProteinDomain( x0 );
2375 p00.addProteinDomain( y1 );
2376 p00.addProteinDomain( y2 );
2377 p00.addProteinDomain( y3 );
2378 p00.addProteinDomain( e1 );
2379 p00.addProteinDomain( e2 );
2380 p00.addProteinDomain( e3 );
2381 p00.addProteinDomain( e4 );
2382 p00.addProteinDomain( e5 );
2383 p00.addProteinDomain( z0 );
2384 p00.addProteinDomain( z1 );
2385 p00.addProteinDomain( z2 );
2386 p00.addProteinDomain( zz0 );
2387 p00.addProteinDomain( zz1 );
2388 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2391 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2394 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2397 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2400 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" ) ) {
2403 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2404 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2405 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2406 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2407 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2408 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2409 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2410 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2411 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2412 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2413 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2414 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2415 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2416 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2417 p.addProteinDomain( B15 );
2418 p.addProteinDomain( C50 );
2419 p.addProteinDomain( A60 );
2420 p.addProteinDomain( A30 );
2421 p.addProteinDomain( C70 );
2422 p.addProteinDomain( B35 );
2423 p.addProteinDomain( B40 );
2424 p.addProteinDomain( A0 );
2425 p.addProteinDomain( A10 );
2426 p.addProteinDomain( A20 );
2427 p.addProteinDomain( B25 );
2428 p.addProteinDomain( D80 );
2429 List<String> domains_ids = new ArrayList<String>();
2430 domains_ids.add( "A" );
2431 domains_ids.add( "B" );
2432 domains_ids.add( "C" );
2433 if ( !p.contains( domains_ids, false ) ) {
2436 if ( !p.contains( domains_ids, true ) ) {
2439 domains_ids.add( "X" );
2440 if ( p.contains( domains_ids, false ) ) {
2443 if ( p.contains( domains_ids, true ) ) {
2446 domains_ids = new ArrayList<String>();
2447 domains_ids.add( "A" );
2448 domains_ids.add( "C" );
2449 domains_ids.add( "D" );
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( "D" );
2459 domains_ids.add( "C" );
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( "A" );
2469 domains_ids.add( "B" );
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( "A" );
2480 domains_ids.add( "B" );
2481 domains_ids.add( "B" );
2482 if ( !p.contains( domains_ids, false ) ) {
2485 if ( !p.contains( domains_ids, true ) ) {
2488 domains_ids = new ArrayList<String>();
2489 domains_ids.add( "A" );
2490 domains_ids.add( "A" );
2491 domains_ids.add( "B" );
2492 domains_ids.add( "A" );
2493 domains_ids.add( "B" );
2494 domains_ids.add( "B" );
2495 domains_ids.add( "A" );
2496 domains_ids.add( "B" );
2497 domains_ids.add( "C" );
2498 domains_ids.add( "A" );
2499 domains_ids.add( "C" );
2500 domains_ids.add( "D" );
2501 if ( !p.contains( domains_ids, false ) ) {
2504 if ( p.contains( domains_ids, true ) ) {
2508 catch ( final Exception e ) {
2509 e.printStackTrace( System.out );
2515 private static boolean testBasicTable() {
2517 final BasicTable<String> t0 = new BasicTable<String>();
2518 if ( t0.getNumberOfColumns() != 0 ) {
2521 if ( t0.getNumberOfRows() != 0 ) {
2524 t0.setValue( 3, 2, "23" );
2525 t0.setValue( 10, 1, "error" );
2526 t0.setValue( 10, 1, "110" );
2527 t0.setValue( 9, 1, "19" );
2528 t0.setValue( 1, 10, "101" );
2529 t0.setValue( 10, 10, "1010" );
2530 t0.setValue( 100, 10, "10100" );
2531 t0.setValue( 0, 0, "00" );
2532 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2535 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2538 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2541 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2544 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2547 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2550 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2553 if ( t0.getNumberOfColumns() != 101 ) {
2556 if ( t0.getNumberOfRows() != 11 ) {
2559 if ( t0.getValueAsString( 49, 4 ) != null ) {
2562 final String l = ForesterUtil.getLineSeparator();
2563 final StringBuffer source = new StringBuffer();
2564 source.append( "" + l );
2565 source.append( "# 1 1 1 1 1 1 1 1" + l );
2566 source.append( " 00 01 02 03" + l );
2567 source.append( " 10 11 12 13 " + l );
2568 source.append( "20 21 22 23 " + l );
2569 source.append( " 30 31 32 33" + l );
2570 source.append( "40 41 42 43" + l );
2571 source.append( " # 1 1 1 1 1 " + l );
2572 source.append( "50 51 52 53 54" + l );
2573 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2574 if ( t1.getNumberOfColumns() != 5 ) {
2577 if ( t1.getNumberOfRows() != 6 ) {
2580 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2583 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2586 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2589 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2592 final StringBuffer source1 = new StringBuffer();
2593 source1.append( "" + l );
2594 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2595 source1.append( " 00; 01 ;02;03" + l );
2596 source1.append( " 10; 11; 12; 13 " + l );
2597 source1.append( "20; 21; 22; 23 " + l );
2598 source1.append( " 30; 31; 32; 33" + l );
2599 source1.append( "40;41;42;43" + l );
2600 source1.append( " # 1 1 1 1 1 " + l );
2601 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2602 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2603 if ( t2.getNumberOfColumns() != 5 ) {
2606 if ( t2.getNumberOfRows() != 6 ) {
2609 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2612 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2615 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2618 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2621 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2624 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2627 final StringBuffer source2 = new StringBuffer();
2628 source2.append( "" + l );
2629 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2630 source2.append( " 00; 01 ;02;03" + l );
2631 source2.append( " 10; 11; 12; 13 " + l );
2632 source2.append( "20; 21; 22; 23 " + l );
2633 source2.append( " " + l );
2634 source2.append( " 30; 31; 32; 33" + l );
2635 source2.append( "40;41;42;43" + l );
2636 source2.append( " comment: 1 1 1 1 1 " + l );
2637 source2.append( ";;;50 ; 52; 53;;54 " + l );
2638 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2644 if ( tl.size() != 2 ) {
2647 final BasicTable<String> t3 = tl.get( 0 );
2648 final BasicTable<String> t4 = tl.get( 1 );
2649 if ( t3.getNumberOfColumns() != 4 ) {
2652 if ( t3.getNumberOfRows() != 3 ) {
2655 if ( t4.getNumberOfColumns() != 4 ) {
2658 if ( t4.getNumberOfRows() != 3 ) {
2661 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2664 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2668 catch ( final Exception e ) {
2669 e.printStackTrace( System.out );
2675 private static boolean testBasicTolXMLparsing() {
2677 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2678 final TolParser parser = new TolParser();
2679 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2680 if ( parser.getErrorCount() > 0 ) {
2681 System.out.println( parser.getErrorMessages().toString() );
2684 if ( phylogenies_0.length != 1 ) {
2687 final Phylogeny t1 = phylogenies_0[ 0 ];
2688 if ( t1.getNumberOfExternalNodes() != 5 ) {
2691 if ( !t1.isRooted() ) {
2694 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2697 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2700 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2703 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2706 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2707 if ( parser.getErrorCount() > 0 ) {
2708 System.out.println( parser.getErrorMessages().toString() );
2711 if ( phylogenies_1.length != 1 ) {
2714 final Phylogeny t2 = phylogenies_1[ 0 ];
2715 if ( t2.getNumberOfExternalNodes() != 664 ) {
2718 if ( !t2.isRooted() ) {
2721 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2724 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2727 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2730 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2733 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2736 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2737 .equals( "Aquifex" ) ) {
2740 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2741 if ( parser.getErrorCount() > 0 ) {
2742 System.out.println( parser.getErrorMessages().toString() );
2745 if ( phylogenies_2.length != 1 ) {
2748 final Phylogeny t3 = phylogenies_2[ 0 ];
2749 if ( t3.getNumberOfExternalNodes() != 184 ) {
2752 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2755 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2758 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2761 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2762 if ( parser.getErrorCount() > 0 ) {
2763 System.out.println( parser.getErrorMessages().toString() );
2766 if ( phylogenies_3.length != 1 ) {
2769 final Phylogeny t4 = phylogenies_3[ 0 ];
2770 if ( t4.getNumberOfExternalNodes() != 1 ) {
2773 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2776 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2779 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2782 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2783 if ( parser.getErrorCount() > 0 ) {
2784 System.out.println( parser.getErrorMessages().toString() );
2787 if ( phylogenies_4.length != 1 ) {
2790 final Phylogeny t5 = phylogenies_4[ 0 ];
2791 if ( t5.getNumberOfExternalNodes() != 13 ) {
2794 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2797 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2800 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2804 catch ( final Exception e ) {
2805 e.printStackTrace( System.out );
2811 private static boolean testBasicTreeMethods() {
2813 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2814 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2815 if ( t2.getNumberOfExternalNodes() != 4 ) {
2818 if ( t2.getHeight() != 8.5 ) {
2821 if ( !t2.isCompletelyBinary() ) {
2824 if ( t2.isEmpty() ) {
2827 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2828 if ( t3.getNumberOfExternalNodes() != 5 ) {
2831 if ( t3.getHeight() != 11 ) {
2834 if ( t3.isCompletelyBinary() ) {
2837 final PhylogenyNode n = t3.getNode( "ABC" );
2838 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 ];
2839 if ( t4.getNumberOfExternalNodes() != 9 ) {
2842 if ( t4.getHeight() != 11 ) {
2845 if ( t4.isCompletelyBinary() ) {
2848 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)" );
2849 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2850 if ( t5.getNumberOfExternalNodes() != 8 ) {
2853 if ( t5.getHeight() != 15 ) {
2856 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)" );
2857 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2858 if ( t6.getHeight() != 15 ) {
2861 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)" );
2862 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2863 if ( t7.getHeight() != 15 ) {
2866 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)" );
2867 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2868 if ( t8.getNumberOfExternalNodes() != 10 ) {
2871 if ( t8.getHeight() != 15 ) {
2874 final char[] a9 = new char[] { 'a' };
2875 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2876 if ( t9.getHeight() != 0 ) {
2879 final char[] a10 = new char[] { 'a', ':', '6' };
2880 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2881 if ( t10.getHeight() != 6 ) {
2885 catch ( final Exception e ) {
2886 e.printStackTrace( System.out );
2892 private static boolean testConfidenceAssessor() {
2894 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2895 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2896 final Phylogeny[] ev0 = factory
2897 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2899 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2900 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2903 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2906 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2907 final Phylogeny[] ev1 = factory
2908 .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)));",
2910 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2911 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2914 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2917 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2918 final Phylogeny[] ev_b = factory
2919 .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",
2921 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2922 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2925 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2929 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2930 final Phylogeny[] ev1x = factory
2931 .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)));",
2933 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2934 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2937 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2940 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2941 final Phylogeny[] ev_bx = factory
2942 .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",
2944 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2945 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2948 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2952 final Phylogeny[] t2 = factory
2953 .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);",
2955 final Phylogeny[] ev2 = factory
2956 .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);",
2958 for( final Phylogeny target : t2 ) {
2959 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2962 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2963 new NHXParser() )[ 0 ];
2964 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2965 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2966 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2969 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2972 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2976 catch ( final Exception e ) {
2977 e.printStackTrace();
2983 private static boolean testCopyOfNodeData() {
2985 final PhylogenyNode n1 = PhylogenyNode
2986 .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]" );
2987 final PhylogenyNode n2 = n1.copyNodeData();
2988 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2992 catch ( final Exception e ) {
2993 e.printStackTrace();
2999 private static boolean testCreateBalancedPhylogeny() {
3001 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3002 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3005 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3008 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3009 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3012 if ( p1.getNumberOfExternalNodes() != 100 ) {
3016 catch ( final Exception e ) {
3017 e.printStackTrace();
3023 private static boolean testCreateUriForSeqWeb() {
3025 final PhylogenyNode n = new PhylogenyNode();
3026 n.setName( "tr|B3RJ64" );
3027 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3030 n.setName( "B0LM41_HUMAN" );
3031 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3034 n.setName( "NP_001025424" );
3035 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3038 n.setName( "_NM_001030253-" );
3039 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3042 n.setName( "XM_002122186" );
3043 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3046 n.setName( "dgh_AAA34956_gdg" );
3047 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3050 n.setName( "AAA34956" );
3051 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3054 n.setName( "GI:394892" );
3055 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3056 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3059 n.setName( "gi_394892" );
3060 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3061 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3064 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3065 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3066 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3069 n.setName( "P12345" );
3070 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3071 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3074 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3075 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3076 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3080 catch ( final Exception e ) {
3081 e.printStackTrace( System.out );
3087 private static boolean testDataObjects() {
3089 final Confidence s0 = new Confidence();
3090 final Confidence s1 = new Confidence();
3091 if ( !s0.isEqual( s1 ) ) {
3094 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3095 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3096 if ( s2.isEqual( s1 ) ) {
3099 if ( !s2.isEqual( s3 ) ) {
3102 final Confidence s4 = ( Confidence ) s3.copy();
3103 if ( !s4.isEqual( s3 ) ) {
3110 final Taxonomy t1 = new Taxonomy();
3111 final Taxonomy t2 = new Taxonomy();
3112 final Taxonomy t3 = new Taxonomy();
3113 final Taxonomy t4 = new Taxonomy();
3114 final Taxonomy t5 = new Taxonomy();
3115 t1.setIdentifier( new Identifier( "ecoli" ) );
3116 t1.setTaxonomyCode( "ECOLI" );
3117 t1.setScientificName( "E. coli" );
3118 t1.setCommonName( "coli" );
3119 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3120 if ( !t1.isEqual( t0 ) ) {
3123 t2.setIdentifier( new Identifier( "ecoli" ) );
3124 t2.setTaxonomyCode( "OTHER" );
3125 t2.setScientificName( "what" );
3126 t2.setCommonName( "something" );
3127 if ( !t1.isEqual( t2 ) ) {
3130 t2.setIdentifier( new Identifier( "nemve" ) );
3131 if ( t1.isEqual( t2 ) ) {
3134 t1.setIdentifier( null );
3135 t3.setTaxonomyCode( "ECOLI" );
3136 t3.setScientificName( "what" );
3137 t3.setCommonName( "something" );
3138 if ( !t1.isEqual( t3 ) ) {
3141 t1.setIdentifier( null );
3142 t1.setTaxonomyCode( "" );
3143 t4.setScientificName( "E. ColI" );
3144 t4.setCommonName( "something" );
3145 if ( !t1.isEqual( t4 ) ) {
3148 t4.setScientificName( "B. subtilis" );
3149 t4.setCommonName( "something" );
3150 if ( t1.isEqual( t4 ) ) {
3153 t1.setIdentifier( null );
3154 t1.setTaxonomyCode( "" );
3155 t1.setScientificName( "" );
3156 t5.setCommonName( "COLI" );
3157 if ( !t1.isEqual( t5 ) ) {
3160 t5.setCommonName( "vibrio" );
3161 if ( t1.isEqual( t5 ) ) {
3166 final Identifier id0 = new Identifier( "123", "pfam" );
3167 final Identifier id1 = ( Identifier ) id0.copy();
3168 if ( !id1.isEqual( id1 ) ) {
3171 if ( !id1.isEqual( id0 ) ) {
3174 if ( !id0.isEqual( id1 ) ) {
3181 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3182 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3183 if ( !pd1.isEqual( pd1 ) ) {
3186 if ( !pd1.isEqual( pd0 ) ) {
3191 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3192 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3193 if ( !pd3.isEqual( pd3 ) ) {
3196 if ( !pd2.isEqual( pd3 ) ) {
3199 if ( !pd0.isEqual( pd3 ) ) {
3204 // DomainArchitecture
3205 // ------------------
3206 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3207 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3208 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3209 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3210 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3211 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3216 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3217 if ( ds0.getNumberOfDomains() != 4 ) {
3220 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3221 if ( !ds0.isEqual( ds0 ) ) {
3224 if ( !ds0.isEqual( ds1 ) ) {
3227 if ( ds1.getNumberOfDomains() != 4 ) {
3230 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3235 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3236 if ( ds0.isEqual( ds2 ) ) {
3242 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3243 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3244 System.out.println( ds3.toNHX() );
3247 if ( ds3.getNumberOfDomains() != 3 ) {
3252 final Event e1 = new Event( Event.EventType.fusion );
3253 if ( e1.isDuplication() ) {
3256 if ( !e1.isFusion() ) {
3259 if ( !e1.asText().toString().equals( "fusion" ) ) {
3262 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3265 final Event e11 = new Event( Event.EventType.fusion );
3266 if ( !e11.isEqual( e1 ) ) {
3269 if ( !e11.toNHX().toString().equals( "" ) ) {
3272 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3273 if ( e2.isDuplication() ) {
3276 if ( !e2.isSpeciationOrDuplication() ) {
3279 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3282 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3285 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3288 if ( e11.isEqual( e2 ) ) {
3291 final Event e2c = ( Event ) e2.copy();
3292 if ( !e2c.isEqual( e2 ) ) {
3295 Event e3 = new Event( 1, 2, 3 );
3296 if ( e3.isDuplication() ) {
3299 if ( e3.isSpeciation() ) {
3302 if ( e3.isGeneLoss() ) {
3305 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3308 final Event e3c = ( Event ) e3.copy();
3309 final Event e3cc = ( Event ) e3c.copy();
3310 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3314 if ( !e3c.isEqual( e3cc ) ) {
3317 Event e4 = new Event( 1, 2, 3 );
3318 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3321 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3324 final Event e4c = ( Event ) e4.copy();
3326 final Event e4cc = ( Event ) e4c.copy();
3327 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3330 if ( !e4c.isEqual( e4cc ) ) {
3333 final Event e5 = new Event();
3334 if ( !e5.isUnassigned() ) {
3337 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3340 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3343 final Event e6 = new Event( 1, 0, 0 );
3344 if ( !e6.asText().toString().equals( "duplication" ) ) {
3347 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3350 final Event e7 = new Event( 0, 1, 0 );
3351 if ( !e7.asText().toString().equals( "speciation" ) ) {
3354 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3357 final Event e8 = new Event( 0, 0, 1 );
3358 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3361 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3365 catch ( final Exception e ) {
3366 e.printStackTrace( System.out );
3372 private static boolean testDeletionOfExternalNodes() {
3374 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3375 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3376 final PhylogenyWriter w = new PhylogenyWriter();
3377 if ( t0.isEmpty() ) {
3380 if ( t0.getNumberOfExternalNodes() != 1 ) {
3383 t0.deleteSubtree( t0.getNode( "A" ), false );
3384 if ( t0.getNumberOfExternalNodes() != 0 ) {
3387 if ( !t0.isEmpty() ) {
3390 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3391 if ( t1.getNumberOfExternalNodes() != 2 ) {
3394 t1.deleteSubtree( t1.getNode( "A" ), false );
3395 if ( t1.getNumberOfExternalNodes() != 1 ) {
3398 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3401 t1.deleteSubtree( t1.getNode( "B" ), false );
3402 if ( t1.getNumberOfExternalNodes() != 1 ) {
3405 t1.deleteSubtree( t1.getNode( "r" ), false );
3406 if ( !t1.isEmpty() ) {
3409 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3410 if ( t2.getNumberOfExternalNodes() != 3 ) {
3413 t2.deleteSubtree( t2.getNode( "B" ), false );
3414 if ( t2.getNumberOfExternalNodes() != 2 ) {
3417 t2.toNewHampshireX();
3418 PhylogenyNode n = t2.getNode( "A" );
3419 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3422 t2.deleteSubtree( t2.getNode( "A" ), false );
3423 if ( t2.getNumberOfExternalNodes() != 2 ) {
3426 t2.deleteSubtree( t2.getNode( "C" ), true );
3427 if ( t2.getNumberOfExternalNodes() != 1 ) {
3430 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3431 if ( t3.getNumberOfExternalNodes() != 4 ) {
3434 t3.deleteSubtree( t3.getNode( "B" ), true );
3435 if ( t3.getNumberOfExternalNodes() != 3 ) {
3438 n = t3.getNode( "A" );
3439 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3442 n = n.getNextExternalNode();
3443 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3446 t3.deleteSubtree( t3.getNode( "A" ), true );
3447 if ( t3.getNumberOfExternalNodes() != 2 ) {
3450 n = t3.getNode( "C" );
3451 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3454 t3.deleteSubtree( t3.getNode( "C" ), true );
3455 if ( t3.getNumberOfExternalNodes() != 1 ) {
3458 t3.deleteSubtree( t3.getNode( "D" ), true );
3459 if ( t3.getNumberOfExternalNodes() != 0 ) {
3462 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3463 if ( t4.getNumberOfExternalNodes() != 6 ) {
3466 t4.deleteSubtree( t4.getNode( "B2" ), true );
3467 if ( t4.getNumberOfExternalNodes() != 5 ) {
3470 String s = w.toNewHampshire( t4, true ).toString();
3471 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3474 t4.deleteSubtree( t4.getNode( "B11" ), true );
3475 if ( t4.getNumberOfExternalNodes() != 4 ) {
3478 t4.deleteSubtree( t4.getNode( "C" ), true );
3479 if ( t4.getNumberOfExternalNodes() != 3 ) {
3482 n = t4.getNode( "A" );
3483 n = n.getNextExternalNode();
3484 if ( !n.getName().equals( "B12" ) ) {
3487 n = n.getNextExternalNode();
3488 if ( !n.getName().equals( "D" ) ) {
3491 s = w.toNewHampshire( t4, true ).toString();
3492 if ( !s.equals( "((A,B12),D);" ) ) {
3495 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3496 t5.deleteSubtree( t5.getNode( "A" ), true );
3497 if ( t5.getNumberOfExternalNodes() != 5 ) {
3500 s = w.toNewHampshire( t5, true ).toString();
3501 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3504 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3505 t6.deleteSubtree( t6.getNode( "B11" ), true );
3506 if ( t6.getNumberOfExternalNodes() != 5 ) {
3509 s = w.toNewHampshire( t6, false ).toString();
3510 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3513 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3514 t7.deleteSubtree( t7.getNode( "B12" ), true );
3515 if ( t7.getNumberOfExternalNodes() != 5 ) {
3518 s = w.toNewHampshire( t7, true ).toString();
3519 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3522 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3523 t8.deleteSubtree( t8.getNode( "B2" ), true );
3524 if ( t8.getNumberOfExternalNodes() != 5 ) {
3527 s = w.toNewHampshire( t8, false ).toString();
3528 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3531 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3532 t9.deleteSubtree( t9.getNode( "C" ), true );
3533 if ( t9.getNumberOfExternalNodes() != 5 ) {
3536 s = w.toNewHampshire( t9, true ).toString();
3537 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3540 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3541 t10.deleteSubtree( t10.getNode( "D" ), true );
3542 if ( t10.getNumberOfExternalNodes() != 5 ) {
3545 s = w.toNewHampshire( t10, true ).toString();
3546 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3549 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3550 t11.deleteSubtree( t11.getNode( "A" ), true );
3551 if ( t11.getNumberOfExternalNodes() != 2 ) {
3554 s = w.toNewHampshire( t11, true ).toString();
3555 if ( !s.equals( "(B,C);" ) ) {
3558 t11.deleteSubtree( t11.getNode( "C" ), true );
3559 if ( t11.getNumberOfExternalNodes() != 1 ) {
3562 s = w.toNewHampshire( t11, false ).toString();
3563 if ( !s.equals( "B;" ) ) {
3566 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3567 t12.deleteSubtree( t12.getNode( "B2" ), true );
3568 if ( t12.getNumberOfExternalNodes() != 8 ) {
3571 s = w.toNewHampshire( t12, true ).toString();
3572 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3575 t12.deleteSubtree( t12.getNode( "B3" ), true );
3576 if ( t12.getNumberOfExternalNodes() != 7 ) {
3579 s = w.toNewHampshire( t12, true ).toString();
3580 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3583 t12.deleteSubtree( t12.getNode( "C3" ), true );
3584 if ( t12.getNumberOfExternalNodes() != 6 ) {
3587 s = w.toNewHampshire( t12, true ).toString();
3588 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3591 t12.deleteSubtree( t12.getNode( "A1" ), true );
3592 if ( t12.getNumberOfExternalNodes() != 5 ) {
3595 s = w.toNewHampshire( t12, true ).toString();
3596 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3599 t12.deleteSubtree( t12.getNode( "B1" ), true );
3600 if ( t12.getNumberOfExternalNodes() != 4 ) {
3603 s = w.toNewHampshire( t12, true ).toString();
3604 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3607 t12.deleteSubtree( t12.getNode( "A3" ), true );
3608 if ( t12.getNumberOfExternalNodes() != 3 ) {
3611 s = w.toNewHampshire( t12, true ).toString();
3612 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3615 t12.deleteSubtree( t12.getNode( "A2" ), true );
3616 if ( t12.getNumberOfExternalNodes() != 2 ) {
3619 s = w.toNewHampshire( t12, true ).toString();
3620 if ( !s.equals( "(C1,C2);" ) ) {
3623 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3624 t13.deleteSubtree( t13.getNode( "D" ), true );
3625 if ( t13.getNumberOfExternalNodes() != 4 ) {
3628 s = w.toNewHampshire( t13, true ).toString();
3629 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3632 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3633 t14.deleteSubtree( t14.getNode( "E" ), true );
3634 if ( t14.getNumberOfExternalNodes() != 5 ) {
3637 s = w.toNewHampshire( t14, true ).toString();
3638 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3641 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3642 t15.deleteSubtree( t15.getNode( "B2" ), true );
3643 if ( t15.getNumberOfExternalNodes() != 11 ) {
3646 t15.deleteSubtree( t15.getNode( "B1" ), true );
3647 if ( t15.getNumberOfExternalNodes() != 10 ) {
3650 t15.deleteSubtree( t15.getNode( "B3" ), true );
3651 if ( t15.getNumberOfExternalNodes() != 9 ) {
3654 t15.deleteSubtree( t15.getNode( "B4" ), true );
3655 if ( t15.getNumberOfExternalNodes() != 8 ) {
3658 t15.deleteSubtree( t15.getNode( "A1" ), true );
3659 if ( t15.getNumberOfExternalNodes() != 7 ) {
3662 t15.deleteSubtree( t15.getNode( "C4" ), true );
3663 if ( t15.getNumberOfExternalNodes() != 6 ) {
3667 catch ( final Exception e ) {
3668 e.printStackTrace( System.out );
3674 private static boolean testDescriptiveStatistics() {
3676 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3677 dss1.addValue( 82 );
3678 dss1.addValue( 78 );
3679 dss1.addValue( 70 );
3680 dss1.addValue( 58 );
3681 dss1.addValue( 42 );
3682 if ( dss1.getN() != 5 ) {
3685 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3688 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3691 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3694 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3697 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3700 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3703 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3706 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3709 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3712 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3715 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3718 dss1.addValue( 123 );
3719 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3722 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3725 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3728 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3729 dss2.addValue( -1.85 );
3730 dss2.addValue( 57.5 );
3731 dss2.addValue( 92.78 );
3732 dss2.addValue( 57.78 );
3733 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3736 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3739 final double[] a = dss2.getDataAsDoubleArray();
3740 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3743 dss2.addValue( -100 );
3744 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3747 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3750 final double[] ds = new double[ 14 ];
3765 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3766 if ( bins.length != 4 ) {
3769 if ( bins[ 0 ] != 2 ) {
3772 if ( bins[ 1 ] != 3 ) {
3775 if ( bins[ 2 ] != 4 ) {
3778 if ( bins[ 3 ] != 5 ) {
3781 final double[] ds1 = new double[ 9 ];
3791 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3792 if ( bins1.length != 4 ) {
3795 if ( bins1[ 0 ] != 2 ) {
3798 if ( bins1[ 1 ] != 3 ) {
3801 if ( bins1[ 2 ] != 0 ) {
3804 if ( bins1[ 3 ] != 4 ) {
3807 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3808 if ( bins1_1.length != 3 ) {
3811 if ( bins1_1[ 0 ] != 3 ) {
3814 if ( bins1_1[ 1 ] != 2 ) {
3817 if ( bins1_1[ 2 ] != 4 ) {
3820 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3821 if ( bins1_2.length != 3 ) {
3824 if ( bins1_2[ 0 ] != 2 ) {
3827 if ( bins1_2[ 1 ] != 2 ) {
3830 if ( bins1_2[ 2 ] != 2 ) {
3833 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3847 dss3.addValue( 10 );
3848 dss3.addValue( 10 );
3849 dss3.addValue( 10 );
3850 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3851 histo.toStringBuffer( 10, '=', 40, 5 );
3852 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3854 catch ( final Exception e ) {
3855 e.printStackTrace( System.out );
3861 private static boolean testDir( final String file ) {
3863 final File f = new File( file );
3864 if ( !f.exists() ) {
3867 if ( !f.isDirectory() ) {
3870 if ( !f.canRead() ) {
3874 catch ( final Exception e ) {
3880 private static boolean testEbiEntryRetrieval() {
3882 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3883 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3884 System.out.println( entry.getAccession() );
3887 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3888 System.out.println( entry.getTaxonomyScientificName() );
3891 if ( !entry.getSequenceName()
3892 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3893 System.out.println( entry.getSequenceName() );
3896 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3897 // System.out.println( entry.getSequenceSymbol() );
3900 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3901 System.out.println( entry.getGeneName() );
3904 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
3905 System.out.println( entry.getTaxonomyIdentifier() );
3908 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
3909 System.out.println( entry.getAnnotations().first().getRefValue() );
3912 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
3913 System.out.println( entry.getAnnotations().first().getRefSource() );
3916 if ( entry.getCrossReferences().size() != 5 ) {
3920 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
3921 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
3924 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
3925 System.out.println( entry1.getTaxonomyScientificName() );
3928 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
3929 System.out.println( entry1.getSequenceName() );
3932 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
3933 System.out.println( entry1.getTaxonomyIdentifier() );
3936 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
3937 System.out.println( entry1.getGeneName() );
3940 if ( entry1.getCrossReferences().size() != 6 ) {
3944 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
3945 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
3948 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3949 System.out.println( entry2.getTaxonomyScientificName() );
3952 if ( !entry2.getSequenceName()
3953 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
3954 System.out.println( entry2.getSequenceName() );
3957 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
3958 System.out.println( entry2.getTaxonomyIdentifier() );
3961 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
3962 System.out.println( entry2.getGeneName() );
3965 if ( entry2.getCrossReferences().size() != 3 ) {
3969 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
3970 if ( !entry3.getAccession().equals( "HM043801" ) ) {
3973 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
3974 System.out.println( entry3.getTaxonomyScientificName() );
3977 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
3978 System.out.println( entry3.getSequenceName() );
3981 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
3982 System.out.println( entry3.getTaxonomyIdentifier() );
3985 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
3986 System.out.println( entry3.getSequenceSymbol() );
3989 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
3992 if ( entry3.getCrossReferences().size() != 8 ) {
3997 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
3998 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4001 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4002 System.out.println( entry4.getTaxonomyScientificName() );
4005 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4006 System.out.println( entry4.getSequenceName() );
4009 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4010 System.out.println( entry4.getTaxonomyIdentifier() );
4013 if ( !entry4.getGeneName().equals( "ras" ) ) {
4014 System.out.println( entry4.getGeneName() );
4017 // if ( !entry4.getChromosome().equals( "ras" ) ) {
4018 // System.out.println( entry4.getChromosome() );
4021 // if ( !entry4.getMap().equals( "ras" ) ) {
4022 // System.out.println( entry4.getMap() );
4028 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
4029 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
4032 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4033 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4036 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4037 System.out.println( entry5.getTaxonomyScientificName() );
4040 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4041 System.out.println( entry5.getSequenceName() );
4044 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4045 System.out.println( entry5.getTaxonomyIdentifier() );
4049 catch ( final IOException e ) {
4050 System.out.println();
4051 System.out.println( "the following might be due to absence internet connection:" );
4052 e.printStackTrace( System.out );
4055 catch ( final Exception e ) {
4056 e.printStackTrace();
4062 private static boolean testExternalNodeRelatedMethods() {
4064 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4065 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4066 PhylogenyNode n = t1.getNode( "A" );
4067 n = n.getNextExternalNode();
4068 if ( !n.getName().equals( "B" ) ) {
4071 n = n.getNextExternalNode();
4072 if ( !n.getName().equals( "C" ) ) {
4075 n = n.getNextExternalNode();
4076 if ( !n.getName().equals( "D" ) ) {
4079 n = t1.getNode( "B" );
4080 while ( !n.isLastExternalNode() ) {
4081 n = n.getNextExternalNode();
4083 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4084 n = t2.getNode( "A" );
4085 n = n.getNextExternalNode();
4086 if ( !n.getName().equals( "B" ) ) {
4089 n = n.getNextExternalNode();
4090 if ( !n.getName().equals( "C" ) ) {
4093 n = n.getNextExternalNode();
4094 if ( !n.getName().equals( "D" ) ) {
4097 n = t2.getNode( "B" );
4098 while ( !n.isLastExternalNode() ) {
4099 n = n.getNextExternalNode();
4101 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4102 n = t3.getNode( "A" );
4103 n = n.getNextExternalNode();
4104 if ( !n.getName().equals( "B" ) ) {
4107 n = n.getNextExternalNode();
4108 if ( !n.getName().equals( "C" ) ) {
4111 n = n.getNextExternalNode();
4112 if ( !n.getName().equals( "D" ) ) {
4115 n = n.getNextExternalNode();
4116 if ( !n.getName().equals( "E" ) ) {
4119 n = n.getNextExternalNode();
4120 if ( !n.getName().equals( "F" ) ) {
4123 n = n.getNextExternalNode();
4124 if ( !n.getName().equals( "G" ) ) {
4127 n = n.getNextExternalNode();
4128 if ( !n.getName().equals( "H" ) ) {
4131 n = t3.getNode( "B" );
4132 while ( !n.isLastExternalNode() ) {
4133 n = n.getNextExternalNode();
4135 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4136 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4137 final PhylogenyNode node = iter.next();
4139 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4140 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4141 final PhylogenyNode node = iter.next();
4143 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4144 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4145 if ( !iter.next().getName().equals( "A" ) ) {
4148 if ( !iter.next().getName().equals( "B" ) ) {
4151 if ( !iter.next().getName().equals( "C" ) ) {
4154 if ( !iter.next().getName().equals( "D" ) ) {
4157 if ( !iter.next().getName().equals( "E" ) ) {
4160 if ( !iter.next().getName().equals( "F" ) ) {
4163 if ( iter.hasNext() ) {
4167 catch ( final Exception e ) {
4168 e.printStackTrace( System.out );
4174 private static boolean testExtractSNFromNodeName() {
4176 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4179 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4182 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4185 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4186 .equals( "Mus musculus musculus" ) ) {
4189 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4190 .equals( "Mus musculus musculus" ) ) {
4193 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4194 .equals( "Mus musculus musculus" ) ) {
4197 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4198 .equals( "Mus musculus musculus" ) ) {
4201 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4204 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4205 .equals( "Mus musculus musculus" ) ) {
4208 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4209 .equals( "Mus musculus musculus" ) ) {
4212 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4215 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4218 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4221 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4224 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4225 .equals( "Mus musculus musculus" ) ) {
4228 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4231 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4234 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4237 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4240 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4243 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4246 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4249 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4252 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4253 .equals( "Mus musculus" ) ) {
4256 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4257 .equals( "Mus musculus" ) ) {
4260 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4263 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4264 .equals( "Mus musculus musculus" ) ) {
4267 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4268 .equals( "Mus musculus musculus" ) ) {
4271 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4272 .equals( "Mus musculus musculus" ) ) {
4275 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4278 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4279 .equals( "Pilostyles mexicana" ) ) {
4282 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4283 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4286 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4287 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4290 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4291 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4294 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4295 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4298 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4299 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4302 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4303 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4306 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4307 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4310 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4311 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4314 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4315 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4318 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4319 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4322 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4323 .equals( "Escherichia coli (strain K12)" ) ) {
4326 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4327 .equals( "Escherichia coli (strain K12)" ) ) {
4330 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4331 .equals( "Escherichia coli (str. K12)" ) ) {
4334 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4335 .equals( "Escherichia coli (str. K12)" ) ) {
4338 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4339 .equals( "Escherichia coli (str. K12)" ) ) {
4342 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4343 .equals( "Escherichia coli (var. K12)" ) ) {
4346 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4347 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4350 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4351 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4355 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4356 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4359 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4360 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4364 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4365 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4368 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4369 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4372 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4373 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4377 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4380 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4383 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4386 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4387 .equals( "Macrocera sp." ) ) {
4390 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4394 catch ( final Exception e ) {
4395 e.printStackTrace( System.out );
4401 private static boolean testExtractTaxonomyCodeFromNodeName() {
4403 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4406 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4407 .equals( "SOYBN" ) ) {
4410 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4411 .equals( "ARATH" ) ) {
4414 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4415 .equals( "ARATH" ) ) {
4418 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4421 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4424 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4427 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4428 .equals( "SOYBN" ) ) {
4431 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4432 .equals( "SOYBN" ) ) {
4435 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4436 .equals( "SOYBN" ) ) {
4439 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4440 .equals( "SOYBN" ) ) {
4443 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4444 .equals( "SOYBN" ) ) {
4447 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4448 .equals( "SOYBN" ) ) {
4451 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4452 .equals( "SOYBN" ) ) {
4455 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4456 .equals( "SOYBN" ) ) {
4459 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4462 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4463 .equals( "SOYBN" ) ) {
4466 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4467 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4470 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4471 .equals( "9YX45" ) ) {
4474 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4475 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4476 .equals( "MOUSE" ) ) {
4479 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4480 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4481 .equals( "MOUSE" ) ) {
4484 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4485 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4486 .equals( "MOUSE" ) ) {
4489 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4490 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4493 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4494 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4497 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4498 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4501 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4502 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4505 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4506 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4509 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4510 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4513 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4514 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4517 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4518 .equals( "RAT" ) ) {
4521 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4522 .equals( "PIG" ) ) {
4526 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4527 .equals( "MOUSE" ) ) {
4530 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4531 .equals( "MOUSE" ) ) {
4534 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4538 catch ( final Exception e ) {
4539 e.printStackTrace( System.out );
4545 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4547 PhylogenyNode n = new PhylogenyNode();
4548 n.setName( "tr|B3RJ64" );
4549 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4552 n.setName( "tr.B3RJ64" );
4553 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4556 n.setName( "tr=B3RJ64" );
4557 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4560 n.setName( "tr-B3RJ64" );
4561 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4564 n.setName( "tr/B3RJ64" );
4565 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4568 n.setName( "tr\\B3RJ64" );
4569 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4572 n.setName( "tr_B3RJ64" );
4573 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4576 n.setName( " tr|B3RJ64 " );
4577 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4580 n.setName( "-tr|B3RJ64-" );
4581 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4584 n.setName( "-tr=B3RJ64-" );
4585 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4588 n.setName( "_tr=B3RJ64_" );
4589 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4592 n.setName( " tr_tr|B3RJ64_sp|123 " );
4593 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4596 n.setName( "B3RJ64" );
4597 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4600 n.setName( "sp|B3RJ64" );
4601 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4604 n.setName( "sp|B3RJ64C" );
4605 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4608 n.setName( "sp B3RJ64" );
4609 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4612 n.setName( "sp|B3RJ6X" );
4613 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4616 n.setName( "sp|B3RJ6" );
4617 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4620 n.setName( "K1PYK7_CRAGI" );
4621 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4624 n.setName( "K1PYK7_PEA" );
4625 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4628 n.setName( "K1PYK7_RAT" );
4629 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4632 n.setName( "K1PYK7_PIG" );
4633 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4636 n.setName( "~K1PYK7_PIG~" );
4637 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4640 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4641 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4644 n.setName( "K1PYKX_CRAGI" );
4645 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4648 n.setName( "XXXXX_CRAGI" );
4649 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4652 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4653 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4656 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4657 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4660 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4661 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4664 n = new PhylogenyNode();
4665 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4666 seq.setSymbol( "K1PYK7_CRAGI" );
4667 n.getNodeData().addSequence( seq );
4668 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4671 seq.setSymbol( "tr|B3RJ64" );
4672 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4675 n = new PhylogenyNode();
4676 seq = new org.forester.phylogeny.data.Sequence();
4677 seq.setName( "K1PYK7_CRAGI" );
4678 n.getNodeData().addSequence( seq );
4679 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4682 seq.setName( "tr|B3RJ64" );
4683 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4686 n = new PhylogenyNode();
4687 seq = new org.forester.phylogeny.data.Sequence();
4688 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4689 n.getNodeData().addSequence( seq );
4690 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4693 n = new PhylogenyNode();
4694 seq = new org.forester.phylogeny.data.Sequence();
4695 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4696 n.getNodeData().addSequence( seq );
4697 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4701 n = new PhylogenyNode();
4702 n.setName( "ACP19736" );
4703 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4706 n = new PhylogenyNode();
4707 n.setName( "|ACP19736|" );
4708 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4712 catch ( final Exception e ) {
4713 e.printStackTrace( System.out );
4719 private static boolean testFastaParser() {
4721 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4724 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4727 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4728 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4731 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4734 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4737 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4740 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4743 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4747 catch ( final Exception e ) {
4748 e.printStackTrace();
4754 private static boolean testGenbankAccessorParsing() {
4755 //The format for GenBank Accession numbers are:
4756 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4757 //Protein: 3 letters + 5 numerals
4758 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4759 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4762 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4765 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4768 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4771 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4774 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4777 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4780 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4783 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4786 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4789 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4792 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4795 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4798 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4804 private static boolean testGeneralMsaParser() {
4806 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4807 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4808 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4809 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4810 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4811 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4812 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4813 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4814 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4817 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4820 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4823 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4826 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4829 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4832 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4835 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4838 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4841 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4844 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4847 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4850 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4851 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4854 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4857 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4860 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4861 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4864 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4867 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4870 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4871 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4874 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4877 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4881 catch ( final Exception e ) {
4882 e.printStackTrace();
4888 private static boolean testGeneralTable() {
4890 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4891 t0.setValue( 3, 2, "23" );
4892 t0.setValue( 10, 1, "error" );
4893 t0.setValue( 10, 1, "110" );
4894 t0.setValue( 9, 1, "19" );
4895 t0.setValue( 1, 10, "101" );
4896 t0.setValue( 10, 10, "1010" );
4897 t0.setValue( 100, 10, "10100" );
4898 t0.setValue( 0, 0, "00" );
4899 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4902 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4905 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4908 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4911 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4914 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4917 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4920 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4923 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4926 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4927 t1.setValue( "3", "2", "23" );
4928 t1.setValue( "10", "1", "error" );
4929 t1.setValue( "10", "1", "110" );
4930 t1.setValue( "9", "1", "19" );
4931 t1.setValue( "1", "10", "101" );
4932 t1.setValue( "10", "10", "1010" );
4933 t1.setValue( "100", "10", "10100" );
4934 t1.setValue( "0", "0", "00" );
4935 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4936 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4939 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4942 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4945 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4948 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4951 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4954 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4957 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4960 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4963 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4967 catch ( final Exception e ) {
4968 e.printStackTrace( System.out );
4974 private static boolean testGetDistance() {
4976 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4977 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",
4978 new NHXParser() )[ 0 ];
4979 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4982 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4985 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4988 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4991 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4994 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4997 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5000 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5003 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5006 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5009 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5012 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5015 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5018 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5021 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5024 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5027 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5030 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5033 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5036 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5039 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5042 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5045 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5048 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5051 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5054 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5057 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5060 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5063 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5066 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5069 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5072 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",
5073 new NHXParser() )[ 0 ];
5074 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5077 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5080 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5083 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5086 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5089 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5092 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5095 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5098 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5101 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5104 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5108 catch ( final Exception e ) {
5109 e.printStackTrace( System.out );
5115 private static boolean testGetLCA() {
5117 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5118 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5119 new NHXParser() )[ 0 ];
5120 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5121 if ( !A.getName().equals( "A" ) ) {
5124 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5125 if ( !gh.getName().equals( "gh" ) ) {
5128 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5129 if ( !ab.getName().equals( "ab" ) ) {
5132 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5133 if ( !ab2.getName().equals( "ab" ) ) {
5136 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5137 if ( !gh2.getName().equals( "gh" ) ) {
5140 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5141 if ( !gh3.getName().equals( "gh" ) ) {
5144 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5145 if ( !abc.getName().equals( "abc" ) ) {
5148 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5149 if ( !abc2.getName().equals( "abc" ) ) {
5152 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5153 if ( !abcd.getName().equals( "abcd" ) ) {
5156 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5157 if ( !abcd2.getName().equals( "abcd" ) ) {
5160 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5161 if ( !abcdef.getName().equals( "abcdef" ) ) {
5164 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5165 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5168 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5169 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5172 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5173 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5176 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5177 if ( !abcde.getName().equals( "abcde" ) ) {
5180 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5181 if ( !abcde2.getName().equals( "abcde" ) ) {
5184 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5185 if ( !r.getName().equals( "abcdefgh" ) ) {
5188 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5189 if ( !r2.getName().equals( "abcdefgh" ) ) {
5192 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5193 if ( !r3.getName().equals( "abcdefgh" ) ) {
5196 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5197 if ( !abcde3.getName().equals( "abcde" ) ) {
5200 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5201 if ( !abcde4.getName().equals( "abcde" ) ) {
5204 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5205 if ( !ab3.getName().equals( "ab" ) ) {
5208 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5209 if ( !ab4.getName().equals( "ab" ) ) {
5212 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5213 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5214 if ( !cd.getName().equals( "cd" ) ) {
5217 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5218 if ( !cd2.getName().equals( "cd" ) ) {
5221 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5222 if ( !cde.getName().equals( "cde" ) ) {
5225 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5226 if ( !cde2.getName().equals( "cde" ) ) {
5229 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5230 if ( !cdef.getName().equals( "cdef" ) ) {
5233 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5234 if ( !cdef2.getName().equals( "cdef" ) ) {
5237 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5238 if ( !cdef3.getName().equals( "cdef" ) ) {
5241 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5242 if ( !rt.getName().equals( "r" ) ) {
5245 final Phylogeny p3 = factory
5246 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5247 new NHXParser() )[ 0 ];
5248 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5249 if ( !bc_3.getName().equals( "bc" ) ) {
5252 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5253 if ( !ac_3.getName().equals( "abc" ) ) {
5256 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5257 if ( !ad_3.getName().equals( "abcde" ) ) {
5260 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5261 if ( !af_3.getName().equals( "abcdef" ) ) {
5264 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5265 if ( !ag_3.getName().equals( "" ) ) {
5268 if ( !ag_3.isRoot() ) {
5271 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5272 if ( !al_3.getName().equals( "" ) ) {
5275 if ( !al_3.isRoot() ) {
5278 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5279 if ( !kl_3.getName().equals( "" ) ) {
5282 if ( !kl_3.isRoot() ) {
5285 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5286 if ( !fl_3.getName().equals( "" ) ) {
5289 if ( !fl_3.isRoot() ) {
5292 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5293 if ( !gk_3.getName().equals( "ghijk" ) ) {
5296 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5297 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5298 if ( !r_4.getName().equals( "r" ) ) {
5301 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5302 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5303 if ( !r_5.getName().equals( "root" ) ) {
5306 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5307 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5308 if ( !r_6.getName().equals( "rot" ) ) {
5311 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5312 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5313 if ( !r_7.getName().equals( "rott" ) ) {
5317 catch ( final Exception e ) {
5318 e.printStackTrace( System.out );
5324 private static boolean testGetLCA2() {
5326 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5327 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5328 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5329 PhylogenyMethods.preOrderReId( p_a );
5330 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5331 p_a.getNode( "a" ) );
5332 if ( !p_a_1.getName().equals( "a" ) ) {
5335 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5336 PhylogenyMethods.preOrderReId( p_b );
5337 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5338 p_b.getNode( "a" ) );
5339 if ( !p_b_1.getName().equals( "b" ) ) {
5342 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5343 p_b.getNode( "b" ) );
5344 if ( !p_b_2.getName().equals( "b" ) ) {
5347 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5348 PhylogenyMethods.preOrderReId( p_c );
5349 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5350 p_c.getNode( "a" ) );
5351 if ( !p_c_1.getName().equals( "b" ) ) {
5354 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5355 p_c.getNode( "c" ) );
5356 if ( !p_c_2.getName().equals( "c" ) ) {
5357 System.out.println( p_c_2.getName() );
5361 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5362 p_c.getNode( "b" ) );
5363 if ( !p_c_3.getName().equals( "b" ) ) {
5366 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5367 p_c.getNode( "a" ) );
5368 if ( !p_c_4.getName().equals( "c" ) ) {
5371 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5372 new NHXParser() )[ 0 ];
5373 PhylogenyMethods.preOrderReId( p1 );
5374 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5375 p1.getNode( "A" ) );
5376 if ( !A.getName().equals( "A" ) ) {
5379 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5380 p1.getNode( "gh" ) );
5381 if ( !gh.getName().equals( "gh" ) ) {
5384 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5385 p1.getNode( "B" ) );
5386 if ( !ab.getName().equals( "ab" ) ) {
5389 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5390 p1.getNode( "A" ) );
5391 if ( !ab2.getName().equals( "ab" ) ) {
5394 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5395 p1.getNode( "G" ) );
5396 if ( !gh2.getName().equals( "gh" ) ) {
5399 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5400 p1.getNode( "H" ) );
5401 if ( !gh3.getName().equals( "gh" ) ) {
5404 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5405 p1.getNode( "A" ) );
5406 if ( !abc.getName().equals( "abc" ) ) {
5409 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5410 p1.getNode( "C" ) );
5411 if ( !abc2.getName().equals( "abc" ) ) {
5414 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5415 p1.getNode( "D" ) );
5416 if ( !abcd.getName().equals( "abcd" ) ) {
5419 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5420 p1.getNode( "A" ) );
5421 if ( !abcd2.getName().equals( "abcd" ) ) {
5424 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5425 p1.getNode( "F" ) );
5426 if ( !abcdef.getName().equals( "abcdef" ) ) {
5429 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5430 p1.getNode( "A" ) );
5431 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5434 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5435 p1.getNode( "F" ) );
5436 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5439 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5440 p1.getNode( "ab" ) );
5441 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5444 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5445 p1.getNode( "E" ) );
5446 if ( !abcde.getName().equals( "abcde" ) ) {
5449 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5450 p1.getNode( "A" ) );
5451 if ( !abcde2.getName().equals( "abcde" ) ) {
5454 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5455 p1.getNode( "abcdefgh" ) );
5456 if ( !r.getName().equals( "abcdefgh" ) ) {
5459 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5460 p1.getNode( "H" ) );
5461 if ( !r2.getName().equals( "abcdefgh" ) ) {
5464 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5465 p1.getNode( "A" ) );
5466 if ( !r3.getName().equals( "abcdefgh" ) ) {
5469 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5470 p1.getNode( "abcde" ) );
5471 if ( !abcde3.getName().equals( "abcde" ) ) {
5474 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5475 p1.getNode( "E" ) );
5476 if ( !abcde4.getName().equals( "abcde" ) ) {
5479 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5480 p1.getNode( "B" ) );
5481 if ( !ab3.getName().equals( "ab" ) ) {
5484 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5485 p1.getNode( "ab" ) );
5486 if ( !ab4.getName().equals( "ab" ) ) {
5489 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5490 PhylogenyMethods.preOrderReId( p2 );
5491 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5492 p2.getNode( "d" ) );
5493 if ( !cd.getName().equals( "cd" ) ) {
5496 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5497 p2.getNode( "c" ) );
5498 if ( !cd2.getName().equals( "cd" ) ) {
5501 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5502 p2.getNode( "e" ) );
5503 if ( !cde.getName().equals( "cde" ) ) {
5506 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5507 p2.getNode( "c" ) );
5508 if ( !cde2.getName().equals( "cde" ) ) {
5511 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5512 p2.getNode( "f" ) );
5513 if ( !cdef.getName().equals( "cdef" ) ) {
5516 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5517 p2.getNode( "f" ) );
5518 if ( !cdef2.getName().equals( "cdef" ) ) {
5521 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5522 p2.getNode( "d" ) );
5523 if ( !cdef3.getName().equals( "cdef" ) ) {
5526 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5527 p2.getNode( "a" ) );
5528 if ( !rt.getName().equals( "r" ) ) {
5531 final Phylogeny p3 = factory
5532 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5533 new NHXParser() )[ 0 ];
5534 PhylogenyMethods.preOrderReId( p3 );
5535 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5536 p3.getNode( "c" ) );
5537 if ( !bc_3.getName().equals( "bc" ) ) {
5540 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5541 p3.getNode( "c" ) );
5542 if ( !ac_3.getName().equals( "abc" ) ) {
5545 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5546 p3.getNode( "d" ) );
5547 if ( !ad_3.getName().equals( "abcde" ) ) {
5550 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5551 p3.getNode( "f" ) );
5552 if ( !af_3.getName().equals( "abcdef" ) ) {
5555 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5556 p3.getNode( "g" ) );
5557 if ( !ag_3.getName().equals( "" ) ) {
5560 if ( !ag_3.isRoot() ) {
5563 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5564 p3.getNode( "l" ) );
5565 if ( !al_3.getName().equals( "" ) ) {
5568 if ( !al_3.isRoot() ) {
5571 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5572 p3.getNode( "l" ) );
5573 if ( !kl_3.getName().equals( "" ) ) {
5576 if ( !kl_3.isRoot() ) {
5579 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5580 p3.getNode( "l" ) );
5581 if ( !fl_3.getName().equals( "" ) ) {
5584 if ( !fl_3.isRoot() ) {
5587 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5588 p3.getNode( "k" ) );
5589 if ( !gk_3.getName().equals( "ghijk" ) ) {
5592 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5593 PhylogenyMethods.preOrderReId( p4 );
5594 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5595 p4.getNode( "c" ) );
5596 if ( !r_4.getName().equals( "r" ) ) {
5599 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5600 PhylogenyMethods.preOrderReId( p5 );
5601 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5602 p5.getNode( "c" ) );
5603 if ( !r_5.getName().equals( "root" ) ) {
5606 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5607 PhylogenyMethods.preOrderReId( p6 );
5608 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5609 p6.getNode( "a" ) );
5610 if ( !r_6.getName().equals( "rot" ) ) {
5613 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5614 PhylogenyMethods.preOrderReId( p7 );
5615 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5616 p7.getNode( "e" ) );
5617 if ( !r_7.getName().equals( "rott" ) ) {
5620 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5621 p7.getNode( "a" ) );
5622 if ( !r_71.getName().equals( "rott" ) ) {
5625 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5626 p7.getNode( "rott" ) );
5627 if ( !r_72.getName().equals( "rott" ) ) {
5630 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5631 p7.getNode( "a" ) );
5632 if ( !r_73.getName().equals( "rott" ) ) {
5635 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5636 p7.getNode( "rott" ) );
5637 if ( !r_74.getName().equals( "rott" ) ) {
5640 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5641 p7.getNode( "e" ) );
5642 if ( !r_75.getName().equals( "e" ) ) {
5646 catch ( final Exception e ) {
5647 e.printStackTrace( System.out );
5653 private static boolean testHmmscanOutputParser() {
5654 final String test_dir = Test.PATH_TO_TEST_DATA;
5656 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5657 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5659 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5660 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5661 final List<Protein> proteins = parser2.parse();
5662 if ( parser2.getProteinsEncountered() != 4 ) {
5665 if ( proteins.size() != 4 ) {
5668 if ( parser2.getDomainsEncountered() != 69 ) {
5671 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5674 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5677 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5680 final Protein p1 = proteins.get( 0 );
5681 if ( p1.getNumberOfProteinDomains() != 15 ) {
5684 if ( p1.getLength() != 850 ) {
5687 final Protein p2 = proteins.get( 1 );
5688 if ( p2.getNumberOfProteinDomains() != 51 ) {
5691 if ( p2.getLength() != 1291 ) {
5694 final Protein p3 = proteins.get( 2 );
5695 if ( p3.getNumberOfProteinDomains() != 2 ) {
5698 final Protein p4 = proteins.get( 3 );
5699 if ( p4.getNumberOfProteinDomains() != 1 ) {
5702 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5705 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5708 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5711 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5714 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5717 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5720 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5724 catch ( final Exception e ) {
5725 e.printStackTrace( System.out );
5731 private static boolean testLastExternalNodeMethods() {
5733 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5734 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5735 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5736 final PhylogenyNode n1 = t0.getNode( "A" );
5737 if ( n1.isLastExternalNode() ) {
5740 final PhylogenyNode n2 = t0.getNode( "B" );
5741 if ( n2.isLastExternalNode() ) {
5744 final PhylogenyNode n3 = t0.getNode( "C" );
5745 if ( n3.isLastExternalNode() ) {
5748 final PhylogenyNode n4 = t0.getNode( "D" );
5749 if ( !n4.isLastExternalNode() ) {
5753 catch ( final Exception e ) {
5754 e.printStackTrace( System.out );
5760 private static boolean testLevelOrderIterator() {
5762 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5763 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5764 PhylogenyNodeIterator it0;
5765 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5768 for( it0.reset(); it0.hasNext(); ) {
5771 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5772 if ( !it.next().getName().equals( "r" ) ) {
5775 if ( !it.next().getName().equals( "ab" ) ) {
5778 if ( !it.next().getName().equals( "cd" ) ) {
5781 if ( !it.next().getName().equals( "A" ) ) {
5784 if ( !it.next().getName().equals( "B" ) ) {
5787 if ( !it.next().getName().equals( "C" ) ) {
5790 if ( !it.next().getName().equals( "D" ) ) {
5793 if ( it.hasNext() ) {
5796 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",
5797 new NHXParser() )[ 0 ];
5798 PhylogenyNodeIterator it2;
5799 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5802 for( it2.reset(); it2.hasNext(); ) {
5805 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5806 if ( !it3.next().getName().equals( "r" ) ) {
5809 if ( !it3.next().getName().equals( "abc" ) ) {
5812 if ( !it3.next().getName().equals( "defg" ) ) {
5815 if ( !it3.next().getName().equals( "A" ) ) {
5818 if ( !it3.next().getName().equals( "B" ) ) {
5821 if ( !it3.next().getName().equals( "C" ) ) {
5824 if ( !it3.next().getName().equals( "D" ) ) {
5827 if ( !it3.next().getName().equals( "E" ) ) {
5830 if ( !it3.next().getName().equals( "F" ) ) {
5833 if ( !it3.next().getName().equals( "G" ) ) {
5836 if ( !it3.next().getName().equals( "1" ) ) {
5839 if ( !it3.next().getName().equals( "2" ) ) {
5842 if ( !it3.next().getName().equals( "3" ) ) {
5845 if ( !it3.next().getName().equals( "4" ) ) {
5848 if ( !it3.next().getName().equals( "5" ) ) {
5851 if ( !it3.next().getName().equals( "6" ) ) {
5854 if ( !it3.next().getName().equals( "f1" ) ) {
5857 if ( !it3.next().getName().equals( "f2" ) ) {
5860 if ( !it3.next().getName().equals( "f3" ) ) {
5863 if ( !it3.next().getName().equals( "a" ) ) {
5866 if ( !it3.next().getName().equals( "b" ) ) {
5869 if ( !it3.next().getName().equals( "f21" ) ) {
5872 if ( !it3.next().getName().equals( "X" ) ) {
5875 if ( !it3.next().getName().equals( "Y" ) ) {
5878 if ( !it3.next().getName().equals( "Z" ) ) {
5881 if ( it3.hasNext() ) {
5884 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5885 PhylogenyNodeIterator it4;
5886 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5889 for( it4.reset(); it4.hasNext(); ) {
5892 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5893 if ( !it5.next().getName().equals( "r" ) ) {
5896 if ( !it5.next().getName().equals( "A" ) ) {
5899 if ( !it5.next().getName().equals( "B" ) ) {
5902 if ( !it5.next().getName().equals( "C" ) ) {
5905 if ( !it5.next().getName().equals( "D" ) ) {
5908 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5909 PhylogenyNodeIterator it6;
5910 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5913 for( it6.reset(); it6.hasNext(); ) {
5916 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5917 if ( !it7.next().getName().equals( "A" ) ) {
5920 if ( it.hasNext() ) {
5924 catch ( final Exception e ) {
5925 e.printStackTrace( System.out );
5931 private static boolean testMafft( final String path ) {
5933 final List<String> opts = new ArrayList<String>();
5934 opts.add( "--maxiterate" );
5936 opts.add( "--localpair" );
5937 opts.add( "--quiet" );
5939 final MsaInferrer mafft = Mafft.createInstance( path );
5940 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5941 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5944 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5948 catch ( final Exception e ) {
5949 e.printStackTrace( System.out );
5955 private static boolean testMidpointrooting() {
5957 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5958 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5959 PhylogenyMethods.midpointRoot( t0 );
5960 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5963 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5966 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5970 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",
5971 new NHXParser() )[ 0 ];
5972 if ( !t1.isRooted() ) {
5975 PhylogenyMethods.midpointRoot( t1 );
5976 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5979 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5982 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5985 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5988 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5991 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5994 t1.reRoot( t1.getNode( "A" ) );
5995 PhylogenyMethods.midpointRoot( t1 );
5996 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5999 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6002 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6005 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6008 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6012 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6016 catch ( final Exception e ) {
6017 e.printStackTrace( System.out );
6023 private static boolean testMsaQualityMethod() {
6025 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6026 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6027 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6028 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6029 final List<Sequence> l = new ArrayList<Sequence>();
6034 final Msa msa = BasicMsa.createInstance( l );
6035 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6038 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6041 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6044 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6047 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6050 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6053 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6057 catch ( final Exception e ) {
6058 e.printStackTrace( System.out );
6064 private static boolean testNextNodeWithCollapsing() {
6066 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6068 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6069 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6070 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6071 t0.getNode( "cd" ).setCollapse( true );
6072 t0.getNode( "cde" ).setCollapse( true );
6073 n = t0.getFirstExternalNode();
6074 while ( n != null ) {
6076 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6078 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6081 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6084 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6087 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6090 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6093 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6097 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6098 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6099 t1.getNode( "ab" ).setCollapse( true );
6100 t1.getNode( "cd" ).setCollapse( true );
6101 t1.getNode( "cde" ).setCollapse( true );
6102 n = t1.getNode( "ab" );
6103 ext = new ArrayList<PhylogenyNode>();
6104 while ( n != null ) {
6106 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6108 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6111 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6114 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6117 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6120 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6126 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6127 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6128 t2.getNode( "ab" ).setCollapse( true );
6129 t2.getNode( "cd" ).setCollapse( true );
6130 t2.getNode( "cde" ).setCollapse( true );
6131 t2.getNode( "c" ).setCollapse( true );
6132 t2.getNode( "d" ).setCollapse( true );
6133 t2.getNode( "e" ).setCollapse( true );
6134 t2.getNode( "gh" ).setCollapse( true );
6135 n = t2.getNode( "ab" );
6136 ext = new ArrayList<PhylogenyNode>();
6137 while ( n != null ) {
6139 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6141 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6144 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6147 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6150 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6156 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6157 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6158 t3.getNode( "ab" ).setCollapse( true );
6159 t3.getNode( "cd" ).setCollapse( true );
6160 t3.getNode( "cde" ).setCollapse( true );
6161 t3.getNode( "c" ).setCollapse( true );
6162 t3.getNode( "d" ).setCollapse( true );
6163 t3.getNode( "e" ).setCollapse( true );
6164 t3.getNode( "gh" ).setCollapse( true );
6165 t3.getNode( "fgh" ).setCollapse( true );
6166 n = t3.getNode( "ab" );
6167 ext = new ArrayList<PhylogenyNode>();
6168 while ( n != null ) {
6170 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6172 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6175 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6178 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6184 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6185 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6186 t4.getNode( "ab" ).setCollapse( true );
6187 t4.getNode( "cd" ).setCollapse( true );
6188 t4.getNode( "cde" ).setCollapse( true );
6189 t4.getNode( "c" ).setCollapse( true );
6190 t4.getNode( "d" ).setCollapse( true );
6191 t4.getNode( "e" ).setCollapse( true );
6192 t4.getNode( "gh" ).setCollapse( true );
6193 t4.getNode( "fgh" ).setCollapse( true );
6194 t4.getNode( "abcdefgh" ).setCollapse( true );
6195 n = t4.getNode( "abcdefgh" );
6196 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6201 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6202 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6204 n = t5.getFirstExternalNode();
6205 while ( n != null ) {
6207 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6209 if ( ext.size() != 8 ) {
6212 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6215 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6218 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6221 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6224 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6227 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6230 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6233 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6238 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6239 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6241 t6.getNode( "ab" ).setCollapse( true );
6242 n = t6.getNode( "ab" );
6243 while ( n != null ) {
6245 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6247 if ( ext.size() != 7 ) {
6250 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6253 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6256 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6259 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6262 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6265 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6268 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6273 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6274 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6276 t7.getNode( "cd" ).setCollapse( true );
6277 n = t7.getNode( "a" );
6278 while ( n != null ) {
6280 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6282 if ( ext.size() != 7 ) {
6285 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6288 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6291 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6294 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6297 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6300 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6303 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6308 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6309 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6311 t8.getNode( "cd" ).setCollapse( true );
6312 t8.getNode( "c" ).setCollapse( true );
6313 t8.getNode( "d" ).setCollapse( true );
6314 n = t8.getNode( "a" );
6315 while ( n != null ) {
6317 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6319 if ( ext.size() != 7 ) {
6322 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6325 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6328 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6329 System.out.println( "2 fail" );
6332 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6335 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6338 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6341 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6346 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6347 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6349 t9.getNode( "gh" ).setCollapse( true );
6350 n = t9.getNode( "a" );
6351 while ( n != null ) {
6353 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6355 if ( ext.size() != 7 ) {
6358 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6361 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6364 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6367 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6370 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6373 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6376 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6381 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6382 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6384 t10.getNode( "gh" ).setCollapse( true );
6385 t10.getNode( "g" ).setCollapse( true );
6386 t10.getNode( "h" ).setCollapse( true );
6387 n = t10.getNode( "a" );
6388 while ( n != null ) {
6390 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6392 if ( ext.size() != 7 ) {
6395 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6398 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6401 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6404 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6407 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6410 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6413 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6418 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6419 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6421 t11.getNode( "gh" ).setCollapse( true );
6422 t11.getNode( "fgh" ).setCollapse( true );
6423 n = t11.getNode( "a" );
6424 while ( n != null ) {
6426 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6428 if ( ext.size() != 6 ) {
6431 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6434 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6437 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6440 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6443 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6446 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6451 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6452 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6454 t12.getNode( "gh" ).setCollapse( true );
6455 t12.getNode( "fgh" ).setCollapse( true );
6456 t12.getNode( "g" ).setCollapse( true );
6457 t12.getNode( "h" ).setCollapse( true );
6458 t12.getNode( "f" ).setCollapse( true );
6459 n = t12.getNode( "a" );
6460 while ( n != null ) {
6462 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6464 if ( ext.size() != 6 ) {
6467 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6470 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6473 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6476 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6479 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6482 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6487 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6488 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6490 t13.getNode( "ab" ).setCollapse( true );
6491 t13.getNode( "b" ).setCollapse( true );
6492 t13.getNode( "fgh" ).setCollapse( true );
6493 t13.getNode( "gh" ).setCollapse( true );
6494 n = t13.getNode( "ab" );
6495 while ( n != null ) {
6497 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6499 if ( ext.size() != 5 ) {
6502 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6505 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6508 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6511 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6514 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6519 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6520 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6522 t14.getNode( "ab" ).setCollapse( true );
6523 t14.getNode( "a" ).setCollapse( true );
6524 t14.getNode( "fgh" ).setCollapse( true );
6525 t14.getNode( "gh" ).setCollapse( true );
6526 n = t14.getNode( "ab" );
6527 while ( n != null ) {
6529 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6531 if ( ext.size() != 5 ) {
6534 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6537 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6540 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6543 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6546 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6551 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" );
6552 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6554 t15.getNode( "ab" ).setCollapse( true );
6555 t15.getNode( "a" ).setCollapse( true );
6556 t15.getNode( "fgh" ).setCollapse( true );
6557 t15.getNode( "gh" ).setCollapse( true );
6558 n = t15.getNode( "ab" );
6559 while ( n != null ) {
6561 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6563 if ( ext.size() != 6 ) {
6566 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6569 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6572 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6575 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6578 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6581 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6586 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" );
6587 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6589 t16.getNode( "ab" ).setCollapse( true );
6590 t16.getNode( "a" ).setCollapse( true );
6591 t16.getNode( "fgh" ).setCollapse( true );
6592 t16.getNode( "gh" ).setCollapse( true );
6593 t16.getNode( "cd" ).setCollapse( true );
6594 t16.getNode( "cde" ).setCollapse( true );
6595 t16.getNode( "d" ).setCollapse( true );
6596 t16.getNode( "x" ).setCollapse( true );
6597 n = t16.getNode( "ab" );
6598 while ( n != null ) {
6600 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6602 if ( ext.size() != 4 ) {
6605 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6608 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6611 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6614 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6618 catch ( final Exception e ) {
6619 e.printStackTrace( System.out );
6625 private static boolean testNexusCharactersParsing() {
6627 final NexusCharactersParser parser = new NexusCharactersParser();
6628 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6630 String[] labels = parser.getCharStateLabels();
6631 if ( labels.length != 7 ) {
6634 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6637 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6640 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6643 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6646 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6649 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6652 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6655 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6657 labels = parser.getCharStateLabels();
6658 if ( labels.length != 7 ) {
6661 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6664 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6667 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6670 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6673 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6676 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6679 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6683 catch ( final Exception e ) {
6684 e.printStackTrace( System.out );
6690 private static boolean testNexusMatrixParsing() {
6692 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6693 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6695 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6696 if ( m.getNumberOfCharacters() != 9 ) {
6699 if ( m.getNumberOfIdentifiers() != 5 ) {
6702 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6705 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6708 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6711 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6714 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6717 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6720 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6723 // if ( labels.length != 7 ) {
6726 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6729 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6732 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6735 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6738 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6741 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6744 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6747 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6749 // labels = parser.getCharStateLabels();
6750 // if ( labels.length != 7 ) {
6753 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6756 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6759 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6762 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6765 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6768 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6771 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6775 catch ( final Exception e ) {
6776 e.printStackTrace( System.out );
6782 private static boolean testNexusTreeParsing() {
6784 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6785 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6786 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6787 if ( phylogenies.length != 1 ) {
6790 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6793 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6797 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6798 if ( phylogenies.length != 1 ) {
6801 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6804 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6808 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6809 if ( phylogenies.length != 1 ) {
6812 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6815 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6818 if ( phylogenies[ 0 ].isRooted() ) {
6822 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
6823 if ( phylogenies.length != 18 ) {
6826 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6829 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
6832 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
6835 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
6838 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6841 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
6844 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
6847 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
6850 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
6853 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
6856 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
6859 if ( phylogenies[ 8 ].isRooted() ) {
6862 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
6865 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
6868 if ( !phylogenies[ 9 ].isRooted() ) {
6871 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
6874 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
6877 if ( !phylogenies[ 10 ].isRooted() ) {
6880 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
6883 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
6886 if ( phylogenies[ 11 ].isRooted() ) {
6889 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
6892 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
6895 if ( !phylogenies[ 12 ].isRooted() ) {
6898 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
6901 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6904 if ( !phylogenies[ 13 ].isRooted() ) {
6907 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6910 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6913 if ( !phylogenies[ 14 ].isRooted() ) {
6916 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6919 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6922 if ( phylogenies[ 15 ].isRooted() ) {
6925 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6928 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6931 if ( !phylogenies[ 16 ].isRooted() ) {
6934 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6937 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6940 if ( phylogenies[ 17 ].isRooted() ) {
6943 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6946 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
6948 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
6949 if ( phylogenies.length != 9 ) {
6952 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
6953 .getDistanceToParent() ) ) {
6956 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
6957 .getDistanceToParent() ) ) {
6960 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
6963 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
6966 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
6969 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
6972 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
6976 catch ( final Exception e ) {
6977 e.printStackTrace( System.out );
6983 private static boolean testNexusTreeParsingIterating() {
6985 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6986 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6987 if ( !p.hasNext() ) {
6990 Phylogeny phy = p.next();
6991 if ( phy == null ) {
6994 if ( phy.getNumberOfExternalNodes() != 25 ) {
6997 if ( !phy.getName().equals( "" ) ) {
7000 if ( p.hasNext() ) {
7004 if ( phy != null ) {
7009 if ( !p.hasNext() ) {
7013 if ( phy == null ) {
7016 if ( phy.getNumberOfExternalNodes() != 25 ) {
7019 if ( !phy.getName().equals( "" ) ) {
7022 if ( p.hasNext() ) {
7026 if ( phy != null ) {
7030 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7031 if ( !p.hasNext() ) {
7035 if ( phy == null ) {
7038 if ( phy.getNumberOfExternalNodes() != 10 ) {
7041 if ( !phy.getName().equals( "name" ) ) {
7044 if ( p.hasNext() ) {
7048 if ( phy != null ) {
7053 if ( !p.hasNext() ) {
7057 if ( phy == null ) {
7060 if ( phy.getNumberOfExternalNodes() != 10 ) {
7063 if ( !phy.getName().equals( "name" ) ) {
7066 if ( p.hasNext() ) {
7070 if ( phy != null ) {
7074 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7075 if ( !p.hasNext() ) {
7079 if ( phy == null ) {
7082 if ( phy.getNumberOfExternalNodes() != 3 ) {
7085 if ( !phy.getName().equals( "" ) ) {
7088 if ( phy.isRooted() ) {
7091 if ( p.hasNext() ) {
7095 if ( phy != null ) {
7100 if ( !p.hasNext() ) {
7104 if ( phy == null ) {
7107 if ( phy.getNumberOfExternalNodes() != 3 ) {
7110 if ( !phy.getName().equals( "" ) ) {
7113 if ( p.hasNext() ) {
7117 if ( phy != null ) {
7121 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7122 if ( !p.hasNext() ) {
7127 if ( phy == null ) {
7130 if ( phy.getNumberOfExternalNodes() != 10 ) {
7133 if ( !phy.getName().equals( "tree 0" ) ) {
7137 if ( !p.hasNext() ) {
7141 if ( phy == null ) {
7144 if ( phy.getNumberOfExternalNodes() != 10 ) {
7147 if ( !phy.getName().equals( "tree 1" ) ) {
7151 if ( !p.hasNext() ) {
7155 if ( phy == null ) {
7158 if ( phy.getNumberOfExternalNodes() != 3 ) {
7159 System.out.println( phy.toString() );
7162 if ( !phy.getName().equals( "" ) ) {
7165 if ( phy.isRooted() ) {
7169 if ( !p.hasNext() ) {
7173 if ( phy == null ) {
7176 if ( phy.getNumberOfExternalNodes() != 4 ) {
7179 if ( !phy.getName().equals( "" ) ) {
7182 if ( !phy.isRooted() ) {
7186 if ( !p.hasNext() ) {
7190 if ( phy == null ) {
7193 if ( phy.getNumberOfExternalNodes() != 5 ) {
7194 System.out.println( phy.getNumberOfExternalNodes() );
7197 if ( !phy.getName().equals( "" ) ) {
7200 if ( !phy.isRooted() ) {
7204 if ( !p.hasNext() ) {
7208 if ( phy == null ) {
7211 if ( phy.getNumberOfExternalNodes() != 3 ) {
7214 if ( !phy.getName().equals( "" ) ) {
7217 if ( phy.isRooted() ) {
7221 if ( !p.hasNext() ) {
7225 if ( phy == null ) {
7228 if ( phy.getNumberOfExternalNodes() != 2 ) {
7231 if ( !phy.getName().equals( "" ) ) {
7234 if ( !phy.isRooted() ) {
7238 if ( !p.hasNext() ) {
7242 if ( phy.getNumberOfExternalNodes() != 3 ) {
7245 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7248 if ( !phy.isRooted() ) {
7252 if ( !p.hasNext() ) {
7256 if ( phy.getNumberOfExternalNodes() != 3 ) {
7259 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7262 if ( !phy.getName().equals( "tree 8" ) ) {
7266 if ( !p.hasNext() ) {
7270 if ( phy.getNumberOfExternalNodes() != 3 ) {
7273 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7276 if ( !phy.getName().equals( "tree 9" ) ) {
7280 if ( !p.hasNext() ) {
7284 if ( phy.getNumberOfExternalNodes() != 3 ) {
7287 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7290 if ( !phy.getName().equals( "tree 10" ) ) {
7293 if ( !phy.isRooted() ) {
7297 if ( !p.hasNext() ) {
7301 if ( phy.getNumberOfExternalNodes() != 3 ) {
7304 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7307 if ( !phy.getName().equals( "tree 11" ) ) {
7310 if ( phy.isRooted() ) {
7314 if ( !p.hasNext() ) {
7318 if ( phy.getNumberOfExternalNodes() != 3 ) {
7321 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7324 if ( !phy.getName().equals( "tree 12" ) ) {
7327 if ( !phy.isRooted() ) {
7331 if ( !p.hasNext() ) {
7335 if ( phy.getNumberOfExternalNodes() != 3 ) {
7338 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7341 if ( !phy.getName().equals( "tree 13" ) ) {
7344 if ( !phy.isRooted() ) {
7348 if ( !p.hasNext() ) {
7352 if ( phy.getNumberOfExternalNodes() != 10 ) {
7353 System.out.println( phy.getNumberOfExternalNodes() );
7358 .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;" ) ) {
7359 System.out.println( phy.toNewHampshire() );
7362 if ( !phy.getName().equals( "tree 14" ) ) {
7365 if ( !phy.isRooted() ) {
7369 if ( !p.hasNext() ) {
7373 if ( phy.getNumberOfExternalNodes() != 10 ) {
7374 System.out.println( phy.getNumberOfExternalNodes() );
7379 .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;" ) ) {
7380 System.out.println( phy.toNewHampshire() );
7383 if ( !phy.getName().equals( "tree 15" ) ) {
7386 if ( phy.isRooted() ) {
7390 if ( !p.hasNext() ) {
7394 if ( phy.getNumberOfExternalNodes() != 10 ) {
7395 System.out.println( phy.getNumberOfExternalNodes() );
7400 .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;" ) ) {
7401 System.out.println( phy.toNewHampshire() );
7404 if ( !phy.getName().equals( "tree 16" ) ) {
7407 if ( !phy.isRooted() ) {
7411 if ( !p.hasNext() ) {
7415 if ( phy.getNumberOfExternalNodes() != 10 ) {
7416 System.out.println( phy.getNumberOfExternalNodes() );
7421 .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;" ) ) {
7422 System.out.println( phy.toNewHampshire() );
7425 if ( !phy.getName().equals( "tree 17" ) ) {
7428 if ( phy.isRooted() ) {
7432 if ( p.hasNext() ) {
7436 if ( phy != null ) {
7441 if ( !p.hasNext() ) {
7445 if ( phy == null ) {
7448 if ( phy.getNumberOfExternalNodes() != 10 ) {
7451 if ( !phy.getName().equals( "tree 0" ) ) {
7455 if ( !p.hasNext() ) {
7459 if ( phy == null ) {
7462 if ( phy.getNumberOfExternalNodes() != 10 ) {
7465 if ( !phy.getName().equals( "tree 1" ) ) {
7469 if ( !p.hasNext() ) {
7473 if ( phy == null ) {
7476 if ( phy.getNumberOfExternalNodes() != 3 ) {
7479 if ( !phy.getName().equals( "" ) ) {
7482 if ( phy.isRooted() ) {
7486 if ( !p.hasNext() ) {
7490 if ( phy == null ) {
7493 if ( phy.getNumberOfExternalNodes() != 4 ) {
7496 if ( !phy.getName().equals( "" ) ) {
7499 if ( !phy.isRooted() ) {
7503 if ( !p.hasNext() ) {
7507 if ( phy == null ) {
7510 if ( phy.getNumberOfExternalNodes() != 5 ) {
7511 System.out.println( phy.getNumberOfExternalNodes() );
7514 if ( !phy.getName().equals( "" ) ) {
7517 if ( !phy.isRooted() ) {
7521 if ( !p.hasNext() ) {
7525 if ( phy == null ) {
7528 if ( phy.getNumberOfExternalNodes() != 3 ) {
7531 if ( !phy.getName().equals( "" ) ) {
7534 if ( phy.isRooted() ) {
7538 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7539 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7541 if ( !p2.hasNext() ) {
7545 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7548 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7552 if ( !p2.hasNext() ) {
7557 if ( !p2.hasNext() ) {
7562 if ( !p2.hasNext() ) {
7567 if ( !p2.hasNext() ) {
7572 if ( !p2.hasNext() ) {
7577 if ( !p2.hasNext() ) {
7582 if ( !p2.hasNext() ) {
7587 if ( !p2.hasNext() ) {
7591 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7594 if ( p2.hasNext() ) {
7598 if ( phy != null ) {
7603 if ( !p2.hasNext() ) {
7607 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7610 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7614 catch ( final Exception e ) {
7615 e.printStackTrace( System.out );
7621 private static boolean testNexusTreeParsingTranslating() {
7623 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7624 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7625 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7626 if ( phylogenies.length != 1 ) {
7629 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7632 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7635 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7638 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7641 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7642 .equals( "Aranaeus" ) ) {
7646 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7647 if ( phylogenies.length != 3 ) {
7650 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7653 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7656 if ( phylogenies[ 0 ].isRooted() ) {
7659 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7662 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7665 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7666 .equals( "Aranaeus" ) ) {
7669 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7672 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7675 if ( phylogenies[ 1 ].isRooted() ) {
7678 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7681 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7684 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7685 .equals( "Aranaeus" ) ) {
7688 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7691 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7694 if ( !phylogenies[ 2 ].isRooted() ) {
7697 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7700 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7703 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7704 .equals( "Aranaeus" ) ) {
7708 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7709 if ( phylogenies.length != 3 ) {
7712 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7715 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7718 if ( phylogenies[ 0 ].isRooted() ) {
7721 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7724 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7727 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7728 .equals( "Aranaeus" ) ) {
7731 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7734 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7737 if ( phylogenies[ 1 ].isRooted() ) {
7740 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7743 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7746 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7747 .equals( "Aranaeus" ) ) {
7750 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7753 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7756 if ( !phylogenies[ 2 ].isRooted() ) {
7759 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7762 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7765 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7766 .equals( "Aranaeus" ) ) {
7769 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
7770 if ( phylogenies.length != 3 ) {
7773 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
7778 catch ( final Exception e ) {
7779 e.printStackTrace( System.out );
7785 private static boolean testNHParsing() {
7787 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7788 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7789 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7792 final NHXParser nhxp = new NHXParser();
7793 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7794 nhxp.setReplaceUnderscores( true );
7795 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7796 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
7799 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
7802 final Phylogeny p1b = factory
7803 .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 ",
7804 new NHXParser() )[ 0 ];
7805 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7808 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7811 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7812 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7813 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7814 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7815 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7816 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7817 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7818 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
7819 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
7820 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
7821 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
7822 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
7823 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
7825 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
7828 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
7831 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
7834 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
7837 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
7838 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
7839 final String p16_S = "((A,B),C)";
7840 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
7841 if ( p16.length != 1 ) {
7844 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
7847 final String p17_S = "(C,(A,B))";
7848 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
7849 if ( p17.length != 1 ) {
7852 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
7855 final String p18_S = "((A,B),(C,D))";
7856 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
7857 if ( p18.length != 1 ) {
7860 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
7863 final String p19_S = "(((A,B),C),D)";
7864 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
7865 if ( p19.length != 1 ) {
7868 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
7871 final String p20_S = "(A,(B,(C,D)))";
7872 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
7873 if ( p20.length != 1 ) {
7876 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
7879 final String p21_S = "(A,(B,(C,(D,E))))";
7880 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
7881 if ( p21.length != 1 ) {
7884 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
7887 final String p22_S = "((((A,B),C),D),E)";
7888 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
7889 if ( p22.length != 1 ) {
7892 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
7895 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7896 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
7897 if ( p23.length != 1 ) {
7898 System.out.println( "xl=" + p23.length );
7902 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
7905 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7906 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
7907 if ( p24.length != 1 ) {
7910 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
7913 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7914 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7915 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
7916 if ( p241.length != 2 ) {
7919 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
7922 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
7925 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
7926 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
7927 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
7928 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
7929 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
7930 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
7931 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
7932 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
7933 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
7934 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
7937 final String p26_S = "(A,B)ab";
7938 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
7939 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
7942 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7943 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
7944 if ( p27s.length != 1 ) {
7945 System.out.println( "xxl=" + p27s.length );
7949 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7950 System.out.println( p27s[ 0 ].toNewHampshireX() );
7954 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
7956 if ( p27.length != 1 ) {
7957 System.out.println( "yl=" + p27.length );
7961 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7962 System.out.println( p27[ 0 ].toNewHampshireX() );
7966 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7967 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7968 final String p28_S3 = "(A,B)ab";
7969 final String p28_S4 = "((((A,B),C),D),;E;)";
7970 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
7972 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
7975 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
7978 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
7981 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
7984 if ( p28.length != 4 ) {
7987 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";
7988 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
7989 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
7992 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";
7993 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
7994 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
7997 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
7998 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
7999 if ( ( p32.length != 0 ) ) {
8002 final String p33_S = "A";
8003 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8004 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8007 final String p34_S = "B;";
8008 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8009 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8012 final String p35_S = "B:0.2";
8013 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8014 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8017 final String p36_S = "(A)";
8018 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8019 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8022 final String p37_S = "((A))";
8023 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8024 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8027 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8028 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8029 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8032 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8033 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8034 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8037 final String p40_S = "(A,B,C)";
8038 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8039 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8042 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8043 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8044 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8047 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8048 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8049 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8052 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)";
8053 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8054 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8057 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)))";
8058 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8059 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8062 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8063 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8064 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8067 final String p46_S = "";
8068 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8069 if ( p46.length != 0 ) {
8072 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8073 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8076 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8077 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8080 final Phylogeny p49 = factory
8081 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8082 new NHXParser() )[ 0 ];
8083 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8086 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8087 if ( p50.getNode( "A" ) == null ) {
8090 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8091 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8094 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8097 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8098 .equals( "((A,B)88:2.0,C);" ) ) {
8101 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8102 if ( p51.getNode( "A(A" ) == null ) {
8105 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8106 if ( p52.getNode( "A(A" ) == null ) {
8109 final Phylogeny p53 = factory
8110 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8111 new NHXParser() )[ 0 ];
8112 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8115 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8116 if ( p54.getNode( "A" ) == null ) {
8119 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8122 final Phylogeny p55 = factory
8123 .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);" ),
8124 new NHXParser() )[ 0 ];
8127 .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);" ) ) {
8128 System.out.println( p55.toNewHampshire() );
8131 final Phylogeny p56 = factory
8132 .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);" ),
8133 new NHXParser() )[ 0 ];
8136 .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);" ) ) {
8137 System.out.println( p56.toNewHampshire() );
8140 final Phylogeny p57 = factory
8141 .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);" ),
8142 new NHXParser() )[ 0 ];
8145 .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);" ) ) {
8146 System.out.println( p56.toNewHampshire() );
8149 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8150 final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ];
8151 if ( !p58.toNewHampshire().equals( s58 ) ) {
8152 System.out.println( p58.toNewHampshire() );
8155 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8156 final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ];
8157 if ( !p59.toNewHampshire().equals( s59 ) ) {
8158 System.out.println( p59.toNewHampshire() );
8161 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8162 final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ];
8163 if ( !p60.toNewHampshire().equals( s60 ) ) {
8164 System.out.println( p60.toNewHampshire() );
8167 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8168 final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ];
8169 if ( !p61.toNewHampshire()
8170 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8171 System.out.println( p61.toNewHampshire() );
8175 catch ( final Exception e ) {
8176 e.printStackTrace( System.out );
8182 private static boolean testNHParsingIter() {
8184 final String p0_str = "(A,B);";
8185 final NHXParser p = new NHXParser();
8186 p.setSource( p0_str );
8187 if ( !p.hasNext() ) {
8190 final Phylogeny p0 = p.next();
8191 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8192 System.out.println( p0.toNewHampshire() );
8195 if ( p.hasNext() ) {
8198 if ( p.next() != null ) {
8202 final String p00_str = "(A,B)root;";
8203 p.setSource( p00_str );
8204 final Phylogeny p00 = p.next();
8205 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8206 System.out.println( p00.toNewHampshire() );
8210 final String p000_str = "A;";
8211 p.setSource( p000_str );
8212 final Phylogeny p000 = p.next();
8213 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8214 System.out.println( p000.toNewHampshire() );
8218 final String p0000_str = "A";
8219 p.setSource( p0000_str );
8220 final Phylogeny p0000 = p.next();
8221 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8222 System.out.println( p0000.toNewHampshire() );
8226 p.setSource( "(A)" );
8227 final Phylogeny p00000 = p.next();
8228 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8229 System.out.println( p00000.toNewHampshire() );
8233 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8234 p.setSource( p1_str );
8235 if ( !p.hasNext() ) {
8238 final Phylogeny p1_0 = p.next();
8239 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8240 System.out.println( p1_0.toNewHampshire() );
8243 if ( !p.hasNext() ) {
8246 final Phylogeny p1_1 = p.next();
8247 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8248 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8251 if ( !p.hasNext() ) {
8254 final Phylogeny p1_2 = p.next();
8255 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8256 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8259 if ( !p.hasNext() ) {
8262 final Phylogeny p1_3 = p.next();
8263 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8264 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8267 if ( p.hasNext() ) {
8270 if ( p.next() != null ) {
8274 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8275 p.setSource( p2_str );
8276 if ( !p.hasNext() ) {
8279 Phylogeny p2_0 = p.next();
8280 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8281 System.out.println( p2_0.toNewHampshire() );
8284 if ( !p.hasNext() ) {
8287 Phylogeny p2_1 = p.next();
8288 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8289 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8292 if ( !p.hasNext() ) {
8295 Phylogeny p2_2 = p.next();
8296 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8297 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8300 if ( !p.hasNext() ) {
8303 Phylogeny p2_3 = p.next();
8304 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8305 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8308 if ( !p.hasNext() ) {
8311 Phylogeny p2_4 = p.next();
8312 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8313 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8316 if ( p.hasNext() ) {
8319 if ( p.next() != null ) {
8324 if ( !p.hasNext() ) {
8328 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8329 System.out.println( p2_0.toNewHampshire() );
8332 if ( !p.hasNext() ) {
8336 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8337 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8340 if ( !p.hasNext() ) {
8344 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8345 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8348 if ( !p.hasNext() ) {
8352 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8353 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8356 if ( !p.hasNext() ) {
8360 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8361 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8364 if ( p.hasNext() ) {
8367 if ( p.next() != null ) {
8371 final String p3_str = "((A,B),C)abc";
8372 p.setSource( p3_str );
8373 if ( !p.hasNext() ) {
8376 final Phylogeny p3_0 = p.next();
8377 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8380 if ( p.hasNext() ) {
8383 if ( p.next() != null ) {
8387 final String p4_str = "((A,B)ab,C)abc";
8388 p.setSource( p4_str );
8389 if ( !p.hasNext() ) {
8392 final Phylogeny p4_0 = p.next();
8393 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8396 if ( p.hasNext() ) {
8399 if ( p.next() != null ) {
8403 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8404 p.setSource( p5_str );
8405 if ( !p.hasNext() ) {
8408 final Phylogeny p5_0 = p.next();
8409 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8412 if ( p.hasNext() ) {
8415 if ( p.next() != null ) {
8419 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8420 p.setSource( p6_str );
8421 if ( !p.hasNext() ) {
8424 Phylogeny p6_0 = p.next();
8425 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8428 if ( p.hasNext() ) {
8431 if ( p.next() != null ) {
8435 if ( !p.hasNext() ) {
8439 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8442 if ( p.hasNext() ) {
8445 if ( p.next() != null ) {
8449 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8450 p.setSource( p7_str );
8451 if ( !p.hasNext() ) {
8454 Phylogeny p7_0 = p.next();
8455 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8458 if ( p.hasNext() ) {
8461 if ( p.next() != null ) {
8465 if ( !p.hasNext() ) {
8469 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8472 if ( p.hasNext() ) {
8475 if ( p.next() != null ) {
8479 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8480 p.setSource( p8_str );
8481 if ( !p.hasNext() ) {
8484 Phylogeny p8_0 = p.next();
8485 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8488 if ( !p.hasNext() ) {
8491 if ( !p.hasNext() ) {
8494 Phylogeny p8_1 = p.next();
8495 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8498 if ( p.hasNext() ) {
8501 if ( p.next() != null ) {
8505 if ( !p.hasNext() ) {
8509 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8512 if ( !p.hasNext() ) {
8516 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8519 if ( p.hasNext() ) {
8522 if ( p.next() != null ) {
8528 if ( p.hasNext() ) {
8532 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8533 if ( !p.hasNext() ) {
8536 Phylogeny p_27 = p.next();
8537 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8538 System.out.println( p_27.toNewHampshireX() );
8542 if ( p.hasNext() ) {
8545 if ( p.next() != null ) {
8549 if ( !p.hasNext() ) {
8553 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8554 System.out.println( p_27.toNewHampshireX() );
8558 if ( p.hasNext() ) {
8561 if ( p.next() != null ) {
8565 final String p30_str = "(A,B);(C,D)";
8566 final NHXParser p30 = new NHXParser();
8567 p30.setSource( p30_str );
8568 if ( !p30.hasNext() ) {
8571 Phylogeny phy30 = p30.next();
8572 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8573 System.out.println( phy30.toNewHampshire() );
8576 if ( !p30.hasNext() ) {
8579 Phylogeny phy301 = p30.next();
8580 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8581 System.out.println( phy301.toNewHampshire() );
8584 if ( p30.hasNext() ) {
8587 if ( p30.hasNext() ) {
8590 if ( p30.next() != null ) {
8593 if ( p30.next() != null ) {
8597 if ( !p30.hasNext() ) {
8601 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8602 System.out.println( phy30.toNewHampshire() );
8605 if ( !p30.hasNext() ) {
8608 phy301 = p30.next();
8609 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8610 System.out.println( phy301.toNewHampshire() );
8613 if ( p30.hasNext() ) {
8616 if ( p30.hasNext() ) {
8619 if ( p30.next() != null ) {
8622 if ( p30.next() != null ) {
8626 catch ( final Exception e ) {
8627 e.printStackTrace( System.out );
8633 private static boolean testNHXconversion() {
8635 final PhylogenyNode n1 = new PhylogenyNode();
8636 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8637 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8638 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8639 final PhylogenyNode n5 = PhylogenyNode
8640 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8641 final PhylogenyNode n6 = PhylogenyNode
8642 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8643 if ( !n1.toNewHampshireX().equals( "" ) ) {
8646 if ( !n2.toNewHampshireX().equals( "" ) ) {
8649 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8652 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8655 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8658 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8659 System.out.println( n6.toNewHampshireX() );
8662 final PhylogenyNode n7 = new PhylogenyNode();
8663 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
8664 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8665 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
8666 System.out.println( n7
8667 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
8671 catch ( final Exception e ) {
8672 e.printStackTrace( System.out );
8678 private static boolean testNHXNodeParsing() {
8680 final PhylogenyNode n1 = new PhylogenyNode();
8681 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8682 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8683 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8684 final PhylogenyNode n5 = PhylogenyNode
8685 .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]" );
8686 if ( !n3.getName().equals( "n3" ) ) {
8689 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8692 if ( n3.isDuplication() ) {
8695 if ( n3.isHasAssignedEvent() ) {
8698 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8701 if ( !n4.getName().equals( "n4" ) ) {
8704 if ( n4.getDistanceToParent() != 0.01 ) {
8707 if ( !n5.getName().equals( "n5" ) ) {
8710 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8713 if ( n5.getDistanceToParent() != 0.1 ) {
8716 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8719 if ( !n5.isDuplication() ) {
8722 if ( !n5.isHasAssignedEvent() ) {
8725 final PhylogenyNode n8 = PhylogenyNode
8726 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8727 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8728 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8731 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8734 final PhylogenyNode n9 = PhylogenyNode
8735 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8736 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8737 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8740 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8743 final PhylogenyNode n10 = PhylogenyNode
8744 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8745 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8748 final PhylogenyNode n20 = PhylogenyNode
8749 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8750 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8753 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8756 final PhylogenyNode n20x = PhylogenyNode
8757 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8758 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8761 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8764 final PhylogenyNode n20xx = PhylogenyNode
8765 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8766 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8769 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8772 final PhylogenyNode n20xxx = PhylogenyNode
8773 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8774 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8777 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8780 final PhylogenyNode n20xxxx = PhylogenyNode
8781 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8782 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8785 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8788 final PhylogenyNode n21 = PhylogenyNode
8789 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8790 if ( !n21.getName().equals( "N21_PIG" ) ) {
8793 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8796 final PhylogenyNode n21x = PhylogenyNode
8797 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8798 if ( !n21x.getName().equals( "n21_PIG" ) ) {
8801 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8804 final PhylogenyNode n22 = PhylogenyNode
8805 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8806 if ( !n22.getName().equals( "n22/PIG" ) ) {
8809 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8812 final PhylogenyNode n23 = PhylogenyNode
8813 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8814 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8817 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
8820 final PhylogenyNode a = PhylogenyNode
8821 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8822 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8825 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
8828 final PhylogenyNode c1 = PhylogenyNode
8829 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
8830 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8831 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
8834 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
8837 final PhylogenyNode c2 = PhylogenyNode
8838 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
8839 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8840 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
8843 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
8846 final PhylogenyNode e3 = PhylogenyNode
8847 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8848 if ( !e3.getName().equals( "n10_RAT~" ) ) {
8851 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
8854 final PhylogenyNode n11 = PhylogenyNode
8855 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
8856 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8857 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
8860 if ( n11.getDistanceToParent() != 0.4 ) {
8863 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
8866 final PhylogenyNode n12 = PhylogenyNode
8867 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
8868 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8869 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
8872 if ( n12.getDistanceToParent() != 0.4 ) {
8875 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
8878 final PhylogenyNode o = PhylogenyNode
8879 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8880 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
8883 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
8886 if ( n1.getName().compareTo( "" ) != 0 ) {
8889 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8892 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8895 if ( n2.getName().compareTo( "" ) != 0 ) {
8898 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8901 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8904 final PhylogenyNode n00 = PhylogenyNode
8905 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
8906 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
8909 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
8912 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
8913 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
8916 final PhylogenyNode n13 = PhylogenyNode
8917 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8918 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
8921 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
8924 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8927 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8930 final PhylogenyNode n14 = PhylogenyNode
8931 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8932 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
8935 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
8938 final PhylogenyNode n15 = PhylogenyNode
8939 .createInstanceFromNhxString( "something_wicked[123]",
8940 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8941 if ( !n15.getName().equals( "something_wicked" ) ) {
8944 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
8947 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
8950 final PhylogenyNode n16 = PhylogenyNode
8951 .createInstanceFromNhxString( "something_wicked2[9]",
8952 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8953 if ( !n16.getName().equals( "something_wicked2" ) ) {
8956 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
8959 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
8962 final PhylogenyNode n17 = PhylogenyNode
8963 .createInstanceFromNhxString( "something_wicked3[a]",
8964 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8965 if ( !n17.getName().equals( "something_wicked3" ) ) {
8968 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
8971 final PhylogenyNode n18 = PhylogenyNode
8972 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8973 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
8976 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
8979 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
8982 final PhylogenyNode n19 = PhylogenyNode
8983 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8984 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
8987 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8990 final PhylogenyNode n30 = PhylogenyNode
8991 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
8992 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8993 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
8996 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8999 final PhylogenyNode n31 = PhylogenyNode
9000 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9001 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9002 if ( n31.getNodeData().isHasTaxonomy() ) {
9005 final PhylogenyNode n32 = PhylogenyNode
9006 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9007 if ( n32.getNodeData().isHasTaxonomy() ) {
9010 final PhylogenyNode n40 = PhylogenyNode
9011 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9012 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9015 final PhylogenyNode n41 = PhylogenyNode
9016 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9017 if ( n41.getNodeData().isHasTaxonomy() ) {
9020 final PhylogenyNode n42 = PhylogenyNode
9021 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9022 if ( n42.getNodeData().isHasTaxonomy() ) {
9025 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9026 NHXParser.TAXONOMY_EXTRACTION.NO );
9027 if ( n43.getNodeData().isHasTaxonomy() ) {
9030 final PhylogenyNode n44 = PhylogenyNode
9031 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9032 if ( n44.getNodeData().isHasTaxonomy() ) {
9036 catch ( final Exception e ) {
9037 e.printStackTrace( System.out );
9043 private static boolean testNHXParsing() {
9045 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9046 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9047 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9050 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]";
9051 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9052 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9055 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]";
9056 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9057 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9060 final Phylogeny[] p3 = factory
9061 .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]",
9063 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9066 final Phylogeny[] p4 = factory
9067 .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(]",
9069 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9072 final Phylogeny[] p5 = factory
9073 .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(((]",
9075 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9078 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)";
9079 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)";
9080 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9081 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9084 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)))";
9085 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)))";
9086 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9087 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9090 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]) ))[,,, ])))))))";
9091 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9092 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9093 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9096 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9097 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9100 final Phylogeny p10 = factory
9101 .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]",
9102 new NHXParser() )[ 0 ];
9103 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9106 final Phylogeny p11 = factory
9107 .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]",
9108 new NHXParser() )[ 0 ];
9109 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9113 catch ( final Exception e ) {
9114 e.printStackTrace( System.out );
9120 private static boolean testNHXParsingMB() {
9122 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9123 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9124 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9125 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9126 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9127 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9128 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9129 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9130 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9131 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9132 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9135 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9138 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9139 0.1100000000000000e+00 ) ) {
9142 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9145 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9148 final Phylogeny p2 = factory
9149 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9150 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9151 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9152 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9153 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9154 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9155 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9156 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9157 + "7.369400000000000e-02}])",
9158 new NHXParser() )[ 0 ];
9159 if ( p2.getNode( "1" ) == null ) {
9162 if ( p2.getNode( "2" ) == null ) {
9166 catch ( final Exception e ) {
9167 e.printStackTrace( System.out );
9174 private static boolean testNHXParsingQuotes() {
9176 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9177 final NHXParser p = new NHXParser();
9178 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9179 if ( phylogenies_0.length != 5 ) {
9182 final Phylogeny phy = phylogenies_0[ 4 ];
9183 if ( phy.getNumberOfExternalNodes() != 7 ) {
9186 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9189 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9192 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9193 .getScientificName().equals( "hsapiens" ) ) {
9196 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9199 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9202 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9205 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9208 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9211 final NHXParser p1p = new NHXParser();
9212 p1p.setIgnoreQuotes( true );
9213 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9214 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9217 final NHXParser p2p = new NHXParser();
9218 p1p.setIgnoreQuotes( false );
9219 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9220 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9223 final NHXParser p3p = new NHXParser();
9224 p3p.setIgnoreQuotes( false );
9225 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9226 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9229 final NHXParser p4p = new NHXParser();
9230 p4p.setIgnoreQuotes( false );
9231 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9232 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9235 final Phylogeny p10 = factory
9236 .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]",
9237 new NHXParser() )[ 0 ];
9238 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]";
9239 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9242 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9243 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9246 final Phylogeny p12 = factory
9247 .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]",
9248 new NHXParser() )[ 0 ];
9249 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]";
9250 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9253 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9254 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9257 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;";
9258 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9261 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9262 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9266 catch ( final Exception e ) {
9267 e.printStackTrace( System.out );
9273 private static boolean testNodeRemoval() {
9275 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9276 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9277 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9278 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9281 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9282 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9283 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9286 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9287 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9288 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9292 catch ( final Exception e ) {
9293 e.printStackTrace( System.out );
9299 private static boolean testPhylogenyBranch() {
9301 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9302 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9303 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9304 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9305 if ( !a1b1.equals( a1b1 ) ) {
9308 if ( !a1b1.equals( b1a1 ) ) {
9311 if ( !b1a1.equals( a1b1 ) ) {
9314 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9315 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9316 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9317 if ( a1_b1.equals( b1_a1 ) ) {
9320 if ( a1_b1.equals( a1_b1_ ) ) {
9323 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9324 if ( !a1_b1.equals( b1_a1_ ) ) {
9327 if ( a1_b1_.equals( b1_a1_ ) ) {
9330 if ( !a1_b1_.equals( b1_a1 ) ) {
9334 catch ( final Exception e ) {
9335 e.printStackTrace( System.out );
9341 private static boolean testPhyloXMLparsingOfDistributionElement() {
9343 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9344 PhyloXmlParser xml_parser = null;
9346 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9348 catch ( final Exception e ) {
9349 // Do nothing -- means were not running from jar.
9351 if ( xml_parser == null ) {
9352 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9353 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9354 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9357 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9360 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9362 if ( xml_parser.getErrorCount() > 0 ) {
9363 System.out.println( xml_parser.getErrorMessages().toString() );
9366 if ( phylogenies_0.length != 1 ) {
9369 final Phylogeny t1 = phylogenies_0[ 0 ];
9370 PhylogenyNode n = null;
9371 Distribution d = null;
9372 n = t1.getNode( "root node" );
9373 if ( !n.getNodeData().isHasDistribution() ) {
9376 if ( n.getNodeData().getDistributions().size() != 1 ) {
9379 d = n.getNodeData().getDistribution();
9380 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9383 if ( d.getPoints().size() != 1 ) {
9386 if ( d.getPolygons() != null ) {
9389 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9392 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9395 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9398 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9401 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9404 n = t1.getNode( "node a" );
9405 if ( !n.getNodeData().isHasDistribution() ) {
9408 if ( n.getNodeData().getDistributions().size() != 2 ) {
9411 d = n.getNodeData().getDistribution( 1 );
9412 if ( !d.getDesc().equals( "San Diego" ) ) {
9415 if ( d.getPoints().size() != 1 ) {
9418 if ( d.getPolygons() != null ) {
9421 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9424 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9427 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9430 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9433 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9436 n = t1.getNode( "node bb" );
9437 if ( !n.getNodeData().isHasDistribution() ) {
9440 if ( n.getNodeData().getDistributions().size() != 1 ) {
9443 d = n.getNodeData().getDistribution( 0 );
9444 if ( d.getPoints().size() != 3 ) {
9447 if ( d.getPolygons().size() != 2 ) {
9450 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9453 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9456 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9459 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9462 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9465 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9468 Polygon p = d.getPolygons().get( 0 );
9469 if ( p.getPoints().size() != 3 ) {
9472 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9475 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9478 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9481 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9484 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9487 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9490 p = d.getPolygons().get( 1 );
9491 if ( p.getPoints().size() != 3 ) {
9494 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9497 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9500 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9504 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9505 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9506 if ( rt.length != 1 ) {
9509 final Phylogeny t1_rt = rt[ 0 ];
9510 n = t1_rt.getNode( "root node" );
9511 if ( !n.getNodeData().isHasDistribution() ) {
9514 if ( n.getNodeData().getDistributions().size() != 1 ) {
9517 d = n.getNodeData().getDistribution();
9518 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9521 if ( d.getPoints().size() != 1 ) {
9524 if ( d.getPolygons() != null ) {
9527 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9530 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9533 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9536 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9539 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9542 n = t1_rt.getNode( "node a" );
9543 if ( !n.getNodeData().isHasDistribution() ) {
9546 if ( n.getNodeData().getDistributions().size() != 2 ) {
9549 d = n.getNodeData().getDistribution( 1 );
9550 if ( !d.getDesc().equals( "San Diego" ) ) {
9553 if ( d.getPoints().size() != 1 ) {
9556 if ( d.getPolygons() != null ) {
9559 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9562 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9565 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9568 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9571 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9574 n = t1_rt.getNode( "node bb" );
9575 if ( !n.getNodeData().isHasDistribution() ) {
9578 if ( n.getNodeData().getDistributions().size() != 1 ) {
9581 d = n.getNodeData().getDistribution( 0 );
9582 if ( d.getPoints().size() != 3 ) {
9585 if ( d.getPolygons().size() != 2 ) {
9588 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9591 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9594 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9597 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9600 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9603 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9606 p = d.getPolygons().get( 0 );
9607 if ( p.getPoints().size() != 3 ) {
9610 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9613 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9616 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9619 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9622 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9625 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9628 p = d.getPolygons().get( 1 );
9629 if ( p.getPoints().size() != 3 ) {
9632 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9635 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9638 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9642 catch ( final Exception e ) {
9643 e.printStackTrace( System.out );
9649 private static boolean testPostOrderIterator() {
9651 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9652 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9653 PhylogenyNodeIterator it0;
9654 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9657 for( it0.reset(); it0.hasNext(); ) {
9660 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9661 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9662 if ( !it.next().getName().equals( "A" ) ) {
9665 if ( !it.next().getName().equals( "B" ) ) {
9668 if ( !it.next().getName().equals( "ab" ) ) {
9671 if ( !it.next().getName().equals( "C" ) ) {
9674 if ( !it.next().getName().equals( "D" ) ) {
9677 if ( !it.next().getName().equals( "cd" ) ) {
9680 if ( !it.next().getName().equals( "abcd" ) ) {
9683 if ( !it.next().getName().equals( "E" ) ) {
9686 if ( !it.next().getName().equals( "F" ) ) {
9689 if ( !it.next().getName().equals( "ef" ) ) {
9692 if ( !it.next().getName().equals( "G" ) ) {
9695 if ( !it.next().getName().equals( "H" ) ) {
9698 if ( !it.next().getName().equals( "gh" ) ) {
9701 if ( !it.next().getName().equals( "efgh" ) ) {
9704 if ( !it.next().getName().equals( "r" ) ) {
9707 if ( it.hasNext() ) {
9711 catch ( final Exception e ) {
9712 e.printStackTrace( System.out );
9718 private static boolean testPreOrderIterator() {
9720 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9721 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9722 PhylogenyNodeIterator it0;
9723 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9726 for( it0.reset(); it0.hasNext(); ) {
9729 PhylogenyNodeIterator it = t0.iteratorPreorder();
9730 if ( !it.next().getName().equals( "r" ) ) {
9733 if ( !it.next().getName().equals( "ab" ) ) {
9736 if ( !it.next().getName().equals( "A" ) ) {
9739 if ( !it.next().getName().equals( "B" ) ) {
9742 if ( !it.next().getName().equals( "cd" ) ) {
9745 if ( !it.next().getName().equals( "C" ) ) {
9748 if ( !it.next().getName().equals( "D" ) ) {
9751 if ( it.hasNext() ) {
9754 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9755 it = t1.iteratorPreorder();
9756 if ( !it.next().getName().equals( "r" ) ) {
9759 if ( !it.next().getName().equals( "abcd" ) ) {
9762 if ( !it.next().getName().equals( "ab" ) ) {
9765 if ( !it.next().getName().equals( "A" ) ) {
9768 if ( !it.next().getName().equals( "B" ) ) {
9771 if ( !it.next().getName().equals( "cd" ) ) {
9774 if ( !it.next().getName().equals( "C" ) ) {
9777 if ( !it.next().getName().equals( "D" ) ) {
9780 if ( !it.next().getName().equals( "efgh" ) ) {
9783 if ( !it.next().getName().equals( "ef" ) ) {
9786 if ( !it.next().getName().equals( "E" ) ) {
9789 if ( !it.next().getName().equals( "F" ) ) {
9792 if ( !it.next().getName().equals( "gh" ) ) {
9795 if ( !it.next().getName().equals( "G" ) ) {
9798 if ( !it.next().getName().equals( "H" ) ) {
9801 if ( it.hasNext() ) {
9805 catch ( final Exception e ) {
9806 e.printStackTrace( System.out );
9812 private static boolean testPropertiesMap() {
9814 final PropertiesMap pm = new PropertiesMap();
9815 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9816 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9817 final Property p2 = new Property( "something:else",
9819 "improbable:research",
9822 pm.addProperty( p0 );
9823 pm.addProperty( p1 );
9824 pm.addProperty( p2 );
9825 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
9828 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
9831 if ( pm.getProperties().size() != 3 ) {
9834 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
9837 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9840 if ( pm.getProperties().size() != 3 ) {
9843 pm.removeProperty( "dimensions:diameter" );
9844 if ( pm.getProperties().size() != 2 ) {
9847 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
9850 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9854 catch ( final Exception e ) {
9855 e.printStackTrace( System.out );
9861 private static boolean testProteinId() {
9863 final ProteinId id1 = new ProteinId( "a" );
9864 final ProteinId id2 = new ProteinId( "a" );
9865 final ProteinId id3 = new ProteinId( "A" );
9866 final ProteinId id4 = new ProteinId( "b" );
9867 if ( !id1.equals( id1 ) ) {
9870 if ( id1.getId().equals( "x" ) ) {
9873 if ( id1.getId().equals( null ) ) {
9876 if ( !id1.equals( id2 ) ) {
9879 if ( id1.equals( id3 ) ) {
9882 if ( id1.hashCode() != id1.hashCode() ) {
9885 if ( id1.hashCode() != id2.hashCode() ) {
9888 if ( id1.hashCode() == id3.hashCode() ) {
9891 if ( id1.compareTo( id1 ) != 0 ) {
9894 if ( id1.compareTo( id2 ) != 0 ) {
9897 if ( id1.compareTo( id3 ) != 0 ) {
9900 if ( id1.compareTo( id4 ) >= 0 ) {
9903 if ( id4.compareTo( id1 ) <= 0 ) {
9906 if ( !id4.getId().equals( "b" ) ) {
9909 final ProteinId id5 = new ProteinId( " C " );
9910 if ( !id5.getId().equals( "C" ) ) {
9913 if ( id5.equals( id1 ) ) {
9917 catch ( final Exception e ) {
9918 e.printStackTrace( System.out );
9924 private static boolean testReIdMethods() {
9926 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9927 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
9928 final long count = PhylogenyNode.getNodeCount();
9930 if ( p.getNode( "r" ).getId() != count ) {
9933 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
9936 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
9939 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
9942 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
9945 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
9948 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
9951 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
9954 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
9957 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
9960 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
9963 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
9966 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
9969 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
9972 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
9976 catch ( final Exception e ) {
9977 e.printStackTrace( System.out );
9983 private static boolean testRerooting() {
9985 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9986 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",
9987 new NHXParser() )[ 0 ];
9988 if ( !t1.isRooted() ) {
9991 t1.reRoot( t1.getNode( "D" ) );
9992 t1.reRoot( t1.getNode( "CD" ) );
9993 t1.reRoot( t1.getNode( "A" ) );
9994 t1.reRoot( t1.getNode( "B" ) );
9995 t1.reRoot( t1.getNode( "AB" ) );
9996 t1.reRoot( t1.getNode( "D" ) );
9997 t1.reRoot( t1.getNode( "C" ) );
9998 t1.reRoot( t1.getNode( "CD" ) );
9999 t1.reRoot( t1.getNode( "A" ) );
10000 t1.reRoot( t1.getNode( "B" ) );
10001 t1.reRoot( t1.getNode( "AB" ) );
10002 t1.reRoot( t1.getNode( "D" ) );
10003 t1.reRoot( t1.getNode( "D" ) );
10004 t1.reRoot( t1.getNode( "C" ) );
10005 t1.reRoot( t1.getNode( "A" ) );
10006 t1.reRoot( t1.getNode( "B" ) );
10007 t1.reRoot( t1.getNode( "AB" ) );
10008 t1.reRoot( t1.getNode( "C" ) );
10009 t1.reRoot( t1.getNode( "D" ) );
10010 t1.reRoot( t1.getNode( "CD" ) );
10011 t1.reRoot( t1.getNode( "D" ) );
10012 t1.reRoot( t1.getNode( "A" ) );
10013 t1.reRoot( t1.getNode( "B" ) );
10014 t1.reRoot( t1.getNode( "AB" ) );
10015 t1.reRoot( t1.getNode( "C" ) );
10016 t1.reRoot( t1.getNode( "D" ) );
10017 t1.reRoot( t1.getNode( "CD" ) );
10018 t1.reRoot( t1.getNode( "D" ) );
10019 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10022 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10025 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10028 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10031 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10034 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10037 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",
10038 new NHXParser() )[ 0 ];
10039 t2.reRoot( t2.getNode( "A" ) );
10040 t2.reRoot( t2.getNode( "D" ) );
10041 t2.reRoot( t2.getNode( "ABC" ) );
10042 t2.reRoot( t2.getNode( "A" ) );
10043 t2.reRoot( t2.getNode( "B" ) );
10044 t2.reRoot( t2.getNode( "D" ) );
10045 t2.reRoot( t2.getNode( "C" ) );
10046 t2.reRoot( t2.getNode( "ABC" ) );
10047 t2.reRoot( t2.getNode( "A" ) );
10048 t2.reRoot( t2.getNode( "B" ) );
10049 t2.reRoot( t2.getNode( "AB" ) );
10050 t2.reRoot( t2.getNode( "AB" ) );
10051 t2.reRoot( t2.getNode( "D" ) );
10052 t2.reRoot( t2.getNode( "C" ) );
10053 t2.reRoot( t2.getNode( "B" ) );
10054 t2.reRoot( t2.getNode( "AB" ) );
10055 t2.reRoot( t2.getNode( "D" ) );
10056 t2.reRoot( t2.getNode( "D" ) );
10057 t2.reRoot( t2.getNode( "ABC" ) );
10058 t2.reRoot( t2.getNode( "A" ) );
10059 t2.reRoot( t2.getNode( "B" ) );
10060 t2.reRoot( t2.getNode( "AB" ) );
10061 t2.reRoot( t2.getNode( "D" ) );
10062 t2.reRoot( t2.getNode( "C" ) );
10063 t2.reRoot( t2.getNode( "ABC" ) );
10064 t2.reRoot( t2.getNode( "A" ) );
10065 t2.reRoot( t2.getNode( "B" ) );
10066 t2.reRoot( t2.getNode( "AB" ) );
10067 t2.reRoot( t2.getNode( "D" ) );
10068 t2.reRoot( t2.getNode( "D" ) );
10069 t2.reRoot( t2.getNode( "C" ) );
10070 t2.reRoot( t2.getNode( "A" ) );
10071 t2.reRoot( t2.getNode( "B" ) );
10072 t2.reRoot( t2.getNode( "AB" ) );
10073 t2.reRoot( t2.getNode( "C" ) );
10074 t2.reRoot( t2.getNode( "D" ) );
10075 t2.reRoot( t2.getNode( "ABC" ) );
10076 t2.reRoot( t2.getNode( "D" ) );
10077 t2.reRoot( t2.getNode( "A" ) );
10078 t2.reRoot( t2.getNode( "B" ) );
10079 t2.reRoot( t2.getNode( "AB" ) );
10080 t2.reRoot( t2.getNode( "C" ) );
10081 t2.reRoot( t2.getNode( "D" ) );
10082 t2.reRoot( t2.getNode( "ABC" ) );
10083 t2.reRoot( t2.getNode( "D" ) );
10084 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10087 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10090 t2.reRoot( t2.getNode( "ABC" ) );
10091 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10094 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10097 t2.reRoot( t2.getNode( "AB" ) );
10098 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10101 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10104 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10107 t2.reRoot( t2.getNode( "AB" ) );
10108 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10111 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10114 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10117 t2.reRoot( t2.getNode( "D" ) );
10118 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10121 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10124 t2.reRoot( t2.getNode( "ABC" ) );
10125 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10128 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10131 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10132 new NHXParser() )[ 0 ];
10133 t3.reRoot( t3.getNode( "B" ) );
10134 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10137 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10140 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10143 t3.reRoot( t3.getNode( "B" ) );
10144 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10147 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10150 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10153 t3.reRoot( t3.getRoot() );
10154 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10157 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10160 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10164 catch ( final Exception e ) {
10165 e.printStackTrace( System.out );
10171 private static boolean testSDIse() {
10173 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10174 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10175 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10176 gene1.setRooted( true );
10177 species1.setRooted( true );
10178 final SDI sdi = new SDI( gene1, species1 );
10179 if ( !gene1.getRoot().isDuplication() ) {
10182 final Phylogeny species2 = factory
10183 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10184 new NHXParser() )[ 0 ];
10185 final Phylogeny gene2 = factory
10186 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10187 new NHXParser() )[ 0 ];
10188 species2.setRooted( true );
10189 gene2.setRooted( true );
10190 final SDI sdi2 = new SDI( gene2, species2 );
10191 if ( sdi2.getDuplicationsSum() != 0 ) {
10194 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10197 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10200 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10203 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10206 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10209 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10212 final Phylogeny species3 = factory
10213 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10214 new NHXParser() )[ 0 ];
10215 final Phylogeny gene3 = factory
10216 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10217 new NHXParser() )[ 0 ];
10218 species3.setRooted( true );
10219 gene3.setRooted( true );
10220 final SDI sdi3 = new SDI( gene3, species3 );
10221 if ( sdi3.getDuplicationsSum() != 1 ) {
10224 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10227 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10230 final Phylogeny species4 = factory
10231 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10232 new NHXParser() )[ 0 ];
10233 final Phylogeny gene4 = factory
10234 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10235 new NHXParser() )[ 0 ];
10236 species4.setRooted( true );
10237 gene4.setRooted( true );
10238 final SDI sdi4 = new SDI( gene4, species4 );
10239 if ( sdi4.getDuplicationsSum() != 1 ) {
10242 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10245 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10248 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10251 if ( species4.getNumberOfExternalNodes() != 6 ) {
10254 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10257 final Phylogeny species5 = factory
10258 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10259 new NHXParser() )[ 0 ];
10260 final Phylogeny gene5 = factory
10261 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10262 new NHXParser() )[ 0 ];
10263 species5.setRooted( true );
10264 gene5.setRooted( true );
10265 final SDI sdi5 = new SDI( gene5, species5 );
10266 if ( sdi5.getDuplicationsSum() != 2 ) {
10269 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10272 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10275 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10278 if ( species5.getNumberOfExternalNodes() != 6 ) {
10281 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10284 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10285 // Conjecture for Comparing Molecular Phylogenies"
10286 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10287 final Phylogeny species6 = factory
10288 .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,"
10289 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10290 new NHXParser() )[ 0 ];
10291 final Phylogeny gene6 = factory
10292 .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,"
10293 + "((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,"
10294 + "(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;",
10295 new NHXParser() )[ 0 ];
10296 species6.setRooted( true );
10297 gene6.setRooted( true );
10298 final SDI sdi6 = new SDI( gene6, species6 );
10299 if ( sdi6.getDuplicationsSum() != 3 ) {
10302 if ( !gene6.getNode( "r" ).isDuplication() ) {
10305 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10308 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10311 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10314 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10317 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10320 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10323 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10326 sdi6.computeMappingCostL();
10327 if ( sdi6.computeMappingCostL() != 17 ) {
10330 if ( species6.getNumberOfExternalNodes() != 9 ) {
10333 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10336 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10337 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10338 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10339 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10340 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10341 species7.setRooted( true );
10342 final Phylogeny gene7_1 = Test
10343 .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])" );
10344 gene7_1.setRooted( true );
10345 final SDI sdi7 = new SDI( gene7_1, species7 );
10346 if ( sdi7.getDuplicationsSum() != 0 ) {
10349 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10352 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10355 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10358 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10361 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10364 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10367 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10370 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10373 final Phylogeny gene7_2 = Test
10374 .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])" );
10375 gene7_2.setRooted( true );
10376 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10377 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10380 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10383 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10386 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10389 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10392 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10395 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10398 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10401 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10404 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10408 catch ( final Exception e ) {
10414 private static boolean testSDIunrooted() {
10416 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10417 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10418 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10419 final Iterator<PhylogenyBranch> iter = l.iterator();
10420 PhylogenyBranch br = iter.next();
10421 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10424 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10428 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10431 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10435 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10438 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10442 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10445 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10449 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10452 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10456 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10459 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10463 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10466 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10470 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10473 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10477 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10480 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10484 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10487 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10491 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10494 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10498 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10501 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10505 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10508 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10512 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10515 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10519 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10522 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10525 if ( iter.hasNext() ) {
10528 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10529 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10530 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10532 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10535 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10539 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10542 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10546 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10549 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10552 if ( iter1.hasNext() ) {
10555 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10556 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10557 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10559 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10562 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10566 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10569 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10573 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10576 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10579 if ( iter2.hasNext() ) {
10582 final Phylogeny species0 = factory
10583 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10584 new NHXParser() )[ 0 ];
10585 final Phylogeny gene1 = factory
10586 .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])",
10587 new NHXParser() )[ 0 ];
10588 species0.setRooted( true );
10589 gene1.setRooted( true );
10590 final SDIR sdi_unrooted = new SDIR();
10591 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10592 if ( sdi_unrooted.getCount() != 1 ) {
10595 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10598 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10601 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10604 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10607 final Phylogeny gene2 = factory
10608 .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])",
10609 new NHXParser() )[ 0 ];
10610 gene2.setRooted( true );
10611 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10612 if ( sdi_unrooted.getCount() != 1 ) {
10615 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10618 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10621 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10624 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10627 final Phylogeny species6 = factory
10628 .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,"
10629 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10630 new NHXParser() )[ 0 ];
10631 final Phylogeny gene6 = factory
10632 .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],"
10633 + "(((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],"
10634 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10635 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10636 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10637 new NHXParser() )[ 0 ];
10638 species6.setRooted( true );
10639 gene6.setRooted( true );
10640 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10641 if ( sdi_unrooted.getCount() != 1 ) {
10644 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10647 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10650 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10653 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10656 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10659 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10662 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10665 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10668 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10671 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10674 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10677 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10681 final Phylogeny species7 = factory
10682 .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,"
10683 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10684 new NHXParser() )[ 0 ];
10685 final Phylogeny gene7 = factory
10686 .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],"
10687 + "(((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],"
10688 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10689 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10690 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10691 new NHXParser() )[ 0 ];
10692 species7.setRooted( true );
10693 gene7.setRooted( true );
10694 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10695 if ( sdi_unrooted.getCount() != 1 ) {
10698 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10701 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10704 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10707 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10710 if ( !p7[ 0 ].getRoot().isDuplication() ) {
10713 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10716 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10719 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10722 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10725 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10728 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10731 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10735 final Phylogeny species8 = factory
10736 .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,"
10737 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10738 new NHXParser() )[ 0 ];
10739 final Phylogeny gene8 = factory
10740 .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],"
10741 + "(((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],"
10742 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10743 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10744 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10745 new NHXParser() )[ 0 ];
10746 species8.setRooted( true );
10747 gene8.setRooted( true );
10748 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10749 if ( sdi_unrooted.getCount() != 1 ) {
10752 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10755 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10758 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10761 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10764 if ( !p8[ 0 ].getRoot().isDuplication() ) {
10767 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10770 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10773 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10776 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10779 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10782 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10785 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10790 catch ( final Exception e ) {
10791 e.printStackTrace( System.out );
10797 private static boolean testSequenceDbWsTools1() {
10799 final PhylogenyNode n = new PhylogenyNode();
10800 n.setName( "NP_001025424" );
10801 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10802 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10803 || !acc.getValue().equals( "NP_001025424" ) ) {
10806 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10807 acc = SequenceDbWsTools.obtainSeqAccession( n );
10808 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10809 || !acc.getValue().equals( "NP_001025424" ) ) {
10812 n.setName( "NP_001025424.1" );
10813 acc = SequenceDbWsTools.obtainSeqAccession( n );
10814 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10815 || !acc.getValue().equals( "NP_001025424" ) ) {
10818 n.setName( "NM_001030253" );
10819 acc = SequenceDbWsTools.obtainSeqAccession( n );
10820 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10821 || !acc.getValue().equals( "NM_001030253" ) ) {
10824 n.setName( "BCL2_HUMAN" );
10825 acc = SequenceDbWsTools.obtainSeqAccession( n );
10826 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10827 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10828 System.out.println( acc.toString() );
10831 n.setName( "P10415" );
10832 acc = SequenceDbWsTools.obtainSeqAccession( n );
10833 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10834 || !acc.getValue().equals( "P10415" ) ) {
10835 System.out.println( acc.toString() );
10838 n.setName( " P10415 " );
10839 acc = SequenceDbWsTools.obtainSeqAccession( n );
10840 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10841 || !acc.getValue().equals( "P10415" ) ) {
10842 System.out.println( acc.toString() );
10845 n.setName( "_P10415|" );
10846 acc = SequenceDbWsTools.obtainSeqAccession( n );
10847 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10848 || !acc.getValue().equals( "P10415" ) ) {
10849 System.out.println( acc.toString() );
10852 n.setName( "AY695820" );
10853 acc = SequenceDbWsTools.obtainSeqAccession( n );
10854 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10855 || !acc.getValue().equals( "AY695820" ) ) {
10856 System.out.println( acc.toString() );
10859 n.setName( "_AY695820_" );
10860 acc = SequenceDbWsTools.obtainSeqAccession( n );
10861 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10862 || !acc.getValue().equals( "AY695820" ) ) {
10863 System.out.println( acc.toString() );
10866 n.setName( "AAA59452" );
10867 acc = SequenceDbWsTools.obtainSeqAccession( n );
10868 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10869 || !acc.getValue().equals( "AAA59452" ) ) {
10870 System.out.println( acc.toString() );
10873 n.setName( "_AAA59452_" );
10874 acc = SequenceDbWsTools.obtainSeqAccession( n );
10875 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10876 || !acc.getValue().equals( "AAA59452" ) ) {
10877 System.out.println( acc.toString() );
10880 n.setName( "AAA59452.1" );
10881 acc = SequenceDbWsTools.obtainSeqAccession( n );
10882 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10883 || !acc.getValue().equals( "AAA59452.1" ) ) {
10884 System.out.println( acc.toString() );
10887 n.setName( "_AAA59452.1_" );
10888 acc = SequenceDbWsTools.obtainSeqAccession( n );
10889 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10890 || !acc.getValue().equals( "AAA59452.1" ) ) {
10891 System.out.println( acc.toString() );
10894 n.setName( "GI:94894583" );
10895 acc = SequenceDbWsTools.obtainSeqAccession( n );
10896 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10897 || !acc.getValue().equals( "94894583" ) ) {
10898 System.out.println( acc.toString() );
10901 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10902 acc = SequenceDbWsTools.obtainSeqAccession( n );
10903 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10904 || !acc.getValue().equals( "71845847" ) ) {
10905 System.out.println( acc.toString() );
10908 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10909 acc = SequenceDbWsTools.obtainSeqAccession( n );
10910 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10911 || !acc.getValue().equals( "AAZ45343.1" ) ) {
10912 System.out.println( acc.toString() );
10916 catch ( final Exception e ) {
10922 private static boolean testSequenceDbWsTools2() {
10924 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
10925 SequenceDbWsTools.obtainSeqInformation( n1 );
10926 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
10929 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10932 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10935 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
10938 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
10939 SequenceDbWsTools.obtainSeqInformation( n2 );
10940 if ( !n2.getNodeData().getSequence().getName()
10941 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
10944 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10947 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10950 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
10953 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
10954 SequenceDbWsTools.obtainSeqInformation( n3 );
10955 if ( !n3.getNodeData().getSequence().getName()
10956 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
10959 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
10962 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10965 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
10969 catch ( final IOException e ) {
10970 System.out.println();
10971 System.out.println( "the following might be due to absence internet connection:" );
10972 e.printStackTrace( System.out );
10975 catch ( final Exception e ) {
10976 e.printStackTrace();
10982 private static boolean testSequenceIdParsing() {
10984 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
10985 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10986 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10987 if ( id != null ) {
10988 System.out.println( "value =" + id.getValue() );
10989 System.out.println( "provider=" + id.getSource() );
10994 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
10995 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10996 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10997 if ( id != null ) {
10998 System.out.println( "value =" + id.getValue() );
10999 System.out.println( "provider=" + id.getSource() );
11004 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11005 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11006 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11007 if ( id != null ) {
11008 System.out.println( "value =" + id.getValue() );
11009 System.out.println( "provider=" + id.getSource() );
11014 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11015 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11016 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11017 if ( id != null ) {
11018 System.out.println( "value =" + id.getValue() );
11019 System.out.println( "provider=" + id.getSource() );
11024 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11025 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11026 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11027 if ( id != null ) {
11028 System.out.println( "value =" + id.getValue() );
11029 System.out.println( "provider=" + id.getSource() );
11034 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11035 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11036 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11037 if ( id != null ) {
11038 System.out.println( "value =" + id.getValue() );
11039 System.out.println( "provider=" + id.getSource() );
11044 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11045 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11046 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11047 if ( id != null ) {
11048 System.out.println( "value =" + id.getValue() );
11049 System.out.println( "provider=" + id.getSource() );
11054 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11055 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11056 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11057 if ( id != null ) {
11058 System.out.println( "value =" + id.getValue() );
11059 System.out.println( "provider=" + id.getSource() );
11064 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11065 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11066 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11067 if ( id != null ) {
11068 System.out.println( "value =" + id.getValue() );
11069 System.out.println( "provider=" + id.getSource() );
11074 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11075 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11076 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11077 if ( id != null ) {
11078 System.out.println( "value =" + id.getValue() );
11079 System.out.println( "provider=" + id.getSource() );
11083 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11084 if ( id != null ) {
11085 System.out.println( "value =" + id.getValue() );
11086 System.out.println( "provider=" + id.getSource() );
11090 catch ( final Exception e ) {
11091 e.printStackTrace( System.out );
11097 private static boolean testSequenceWriter() {
11099 final String n = ForesterUtil.LINE_SEPARATOR;
11100 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11103 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11106 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11109 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11112 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11113 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11116 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11117 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11121 catch ( final Exception e ) {
11122 e.printStackTrace();
11128 private static boolean testSpecies() {
11130 final Species s1 = new BasicSpecies( "a" );
11131 final Species s2 = new BasicSpecies( "a" );
11132 final Species s3 = new BasicSpecies( "A" );
11133 final Species s4 = new BasicSpecies( "b" );
11134 if ( !s1.equals( s1 ) ) {
11137 if ( s1.getSpeciesId().equals( "x" ) ) {
11140 if ( s1.getSpeciesId().equals( null ) ) {
11143 if ( !s1.equals( s2 ) ) {
11146 if ( s1.equals( s3 ) ) {
11149 if ( s1.hashCode() != s1.hashCode() ) {
11152 if ( s1.hashCode() != s2.hashCode() ) {
11155 if ( s1.hashCode() == s3.hashCode() ) {
11158 if ( s1.compareTo( s1 ) != 0 ) {
11161 if ( s1.compareTo( s2 ) != 0 ) {
11164 if ( s1.compareTo( s3 ) != 0 ) {
11167 if ( s1.compareTo( s4 ) >= 0 ) {
11170 if ( s4.compareTo( s1 ) <= 0 ) {
11173 if ( !s4.getSpeciesId().equals( "b" ) ) {
11176 final Species s5 = new BasicSpecies( " C " );
11177 if ( !s5.getSpeciesId().equals( "C" ) ) {
11180 if ( s5.equals( s1 ) ) {
11184 catch ( final Exception e ) {
11185 e.printStackTrace( System.out );
11191 private static boolean testSplit() {
11193 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11194 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11195 //Archaeopteryx.createApplication( p0 );
11196 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11197 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11198 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11199 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11200 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11201 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11202 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11203 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11204 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11205 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11206 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11207 // System.out.println( s0.toString() );
11209 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11210 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11211 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11212 if ( s0.match( query_nodes ) ) {
11215 query_nodes = new HashSet<PhylogenyNode>();
11216 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11217 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11218 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11219 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11220 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11221 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11222 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11223 if ( !s0.match( query_nodes ) ) {
11227 query_nodes = new HashSet<PhylogenyNode>();
11228 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11229 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11230 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11231 if ( !s0.match( query_nodes ) ) {
11235 query_nodes = new HashSet<PhylogenyNode>();
11236 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11237 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11238 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11239 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11240 if ( !s0.match( query_nodes ) ) {
11244 query_nodes = new HashSet<PhylogenyNode>();
11245 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11246 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11247 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11248 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11249 if ( !s0.match( query_nodes ) ) {
11253 query_nodes = new HashSet<PhylogenyNode>();
11254 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11255 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11256 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11257 if ( !s0.match( query_nodes ) ) {
11261 query_nodes = new HashSet<PhylogenyNode>();
11262 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11263 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11264 if ( !s0.match( query_nodes ) ) {
11268 query_nodes = new HashSet<PhylogenyNode>();
11269 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11270 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11271 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11272 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11273 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11274 if ( !s0.match( query_nodes ) ) {
11278 query_nodes = new HashSet<PhylogenyNode>();
11279 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11280 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11281 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11282 if ( !s0.match( query_nodes ) ) {
11286 query_nodes = new HashSet<PhylogenyNode>();
11287 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11288 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11289 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11290 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11291 if ( !s0.match( query_nodes ) ) {
11295 query_nodes = new HashSet<PhylogenyNode>();
11296 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11297 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11298 if ( s0.match( query_nodes ) ) {
11302 query_nodes = new HashSet<PhylogenyNode>();
11303 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11304 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11305 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11306 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11307 if ( s0.match( query_nodes ) ) {
11311 query_nodes = new HashSet<PhylogenyNode>();
11312 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11313 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11314 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11315 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11316 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11317 if ( s0.match( query_nodes ) ) {
11321 query_nodes = new HashSet<PhylogenyNode>();
11322 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11323 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11324 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11325 if ( s0.match( query_nodes ) ) {
11329 query_nodes = new HashSet<PhylogenyNode>();
11330 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11331 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11332 if ( s0.match( query_nodes ) ) {
11336 query_nodes = new HashSet<PhylogenyNode>();
11337 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11338 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11339 if ( s0.match( query_nodes ) ) {
11343 query_nodes = new HashSet<PhylogenyNode>();
11344 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11345 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11346 if ( s0.match( query_nodes ) ) {
11350 query_nodes = new HashSet<PhylogenyNode>();
11351 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11352 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
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( "F" ) );
11360 if ( s0.match( query_nodes ) ) {
11364 query_nodes = new HashSet<PhylogenyNode>();
11365 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11366 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11367 if ( s0.match( query_nodes ) ) {
11371 query_nodes = new HashSet<PhylogenyNode>();
11372 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11373 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11374 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11375 if ( s0.match( query_nodes ) ) {
11379 query_nodes = new HashSet<PhylogenyNode>();
11380 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11381 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11382 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11383 if ( s0.match( query_nodes ) ) {
11387 query_nodes = new HashSet<PhylogenyNode>();
11388 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11389 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11390 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11391 if ( s0.match( query_nodes ) ) {
11395 query_nodes = new HashSet<PhylogenyNode>();
11396 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11397 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11398 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11399 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11400 if ( s0.match( query_nodes ) ) {
11404 // query_nodes = new HashSet<PhylogenyNode>();
11405 // query_nodes.add( new PhylogenyNode( "X" ) );
11406 // query_nodes.add( new PhylogenyNode( "Y" ) );
11407 // query_nodes.add( new PhylogenyNode( "A" ) );
11408 // query_nodes.add( new PhylogenyNode( "B" ) );
11409 // query_nodes.add( new PhylogenyNode( "C" ) );
11410 // query_nodes.add( new PhylogenyNode( "D" ) );
11411 // query_nodes.add( new PhylogenyNode( "E" ) );
11412 // query_nodes.add( new PhylogenyNode( "F" ) );
11413 // query_nodes.add( new PhylogenyNode( "G" ) );
11414 // if ( !s0.match( query_nodes ) ) {
11417 // query_nodes = new HashSet<PhylogenyNode>();
11418 // query_nodes.add( new PhylogenyNode( "X" ) );
11419 // query_nodes.add( new PhylogenyNode( "Y" ) );
11420 // query_nodes.add( new PhylogenyNode( "A" ) );
11421 // query_nodes.add( new PhylogenyNode( "B" ) );
11422 // query_nodes.add( new PhylogenyNode( "C" ) );
11423 // if ( !s0.match( query_nodes ) ) {
11427 // query_nodes = new HashSet<PhylogenyNode>();
11428 // query_nodes.add( new PhylogenyNode( "X" ) );
11429 // query_nodes.add( new PhylogenyNode( "Y" ) );
11430 // query_nodes.add( new PhylogenyNode( "D" ) );
11431 // query_nodes.add( new PhylogenyNode( "E" ) );
11432 // query_nodes.add( new PhylogenyNode( "F" ) );
11433 // query_nodes.add( new PhylogenyNode( "G" ) );
11434 // if ( !s0.match( query_nodes ) ) {
11438 // query_nodes = new HashSet<PhylogenyNode>();
11439 // query_nodes.add( new PhylogenyNode( "X" ) );
11440 // query_nodes.add( new PhylogenyNode( "Y" ) );
11441 // query_nodes.add( new PhylogenyNode( "A" ) );
11442 // query_nodes.add( new PhylogenyNode( "B" ) );
11443 // query_nodes.add( new PhylogenyNode( "C" ) );
11444 // query_nodes.add( new PhylogenyNode( "D" ) );
11445 // if ( !s0.match( query_nodes ) ) {
11449 // query_nodes = new HashSet<PhylogenyNode>();
11450 // query_nodes.add( new PhylogenyNode( "X" ) );
11451 // query_nodes.add( new PhylogenyNode( "Y" ) );
11452 // query_nodes.add( new PhylogenyNode( "E" ) );
11453 // query_nodes.add( new PhylogenyNode( "F" ) );
11454 // query_nodes.add( new PhylogenyNode( "G" ) );
11455 // if ( !s0.match( query_nodes ) ) {
11459 // query_nodes = new HashSet<PhylogenyNode>();
11460 // query_nodes.add( new PhylogenyNode( "X" ) );
11461 // query_nodes.add( new PhylogenyNode( "Y" ) );
11462 // query_nodes.add( new PhylogenyNode( "F" ) );
11463 // query_nodes.add( new PhylogenyNode( "G" ) );
11464 // if ( !s0.match( query_nodes ) ) {
11468 query_nodes = new HashSet<PhylogenyNode>();
11469 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11470 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11471 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11472 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11473 if ( s0.match( query_nodes ) ) {
11477 query_nodes = new HashSet<PhylogenyNode>();
11478 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11479 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11480 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11481 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11482 if ( s0.match( query_nodes ) ) {
11485 ///////////////////////////
11487 query_nodes = new HashSet<PhylogenyNode>();
11488 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11489 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11490 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11491 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11492 if ( s0.match( query_nodes ) ) {
11496 query_nodes = new HashSet<PhylogenyNode>();
11497 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11498 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11499 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11500 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11501 if ( s0.match( query_nodes ) ) {
11505 query_nodes = new HashSet<PhylogenyNode>();
11506 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11507 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11508 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11509 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11510 if ( s0.match( query_nodes ) ) {
11514 query_nodes = new HashSet<PhylogenyNode>();
11515 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11516 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11517 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11518 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11519 if ( s0.match( query_nodes ) ) {
11523 query_nodes = new HashSet<PhylogenyNode>();
11524 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11525 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11526 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11527 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11528 if ( s0.match( query_nodes ) ) {
11532 query_nodes = new HashSet<PhylogenyNode>();
11533 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11534 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11535 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11536 if ( s0.match( query_nodes ) ) {
11540 query_nodes = new HashSet<PhylogenyNode>();
11541 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11542 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11543 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11544 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11545 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11546 if ( s0.match( query_nodes ) ) {
11550 query_nodes = new HashSet<PhylogenyNode>();
11551 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11552 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11553 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11554 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11555 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11556 if ( s0.match( query_nodes ) ) {
11560 query_nodes = new HashSet<PhylogenyNode>();
11561 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11562 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11563 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11564 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11565 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11566 if ( s0.match( query_nodes ) ) {
11570 query_nodes = new HashSet<PhylogenyNode>();
11571 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11572 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11573 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11574 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11575 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11576 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11577 if ( s0.match( query_nodes ) ) {
11581 catch ( final Exception e ) {
11582 e.printStackTrace();
11588 private static boolean testSplitStrict() {
11590 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11591 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11592 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11593 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11594 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11595 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11596 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11597 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11598 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11599 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11600 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11601 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11602 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11603 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11604 if ( s0.match( query_nodes ) ) {
11607 query_nodes = new HashSet<PhylogenyNode>();
11608 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11609 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11610 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11611 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11612 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11613 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11614 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11615 if ( !s0.match( query_nodes ) ) {
11619 query_nodes = new HashSet<PhylogenyNode>();
11620 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11621 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
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( "D" ) );
11629 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11630 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11632 if ( !s0.match( query_nodes ) ) {
11636 query_nodes = new HashSet<PhylogenyNode>();
11637 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11638 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11639 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11640 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11641 if ( !s0.match( query_nodes ) ) {
11645 query_nodes = new HashSet<PhylogenyNode>();
11646 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11647 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
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( "F" ) );
11655 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11656 if ( !s0.match( query_nodes ) ) {
11660 query_nodes = new HashSet<PhylogenyNode>();
11661 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11662 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11663 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11664 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11665 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11666 if ( !s0.match( query_nodes ) ) {
11670 query_nodes = new HashSet<PhylogenyNode>();
11671 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11672 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11673 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11674 if ( !s0.match( query_nodes ) ) {
11678 query_nodes = new HashSet<PhylogenyNode>();
11679 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11680 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11681 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11682 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11683 if ( !s0.match( query_nodes ) ) {
11687 query_nodes = new HashSet<PhylogenyNode>();
11688 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11689 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11690 if ( s0.match( query_nodes ) ) {
11694 query_nodes = new HashSet<PhylogenyNode>();
11695 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11696 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11697 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11698 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11699 if ( s0.match( query_nodes ) ) {
11703 query_nodes = new HashSet<PhylogenyNode>();
11704 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11705 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11706 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11707 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11708 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11709 if ( s0.match( query_nodes ) ) {
11713 query_nodes = new HashSet<PhylogenyNode>();
11714 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11715 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11716 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11717 if ( s0.match( query_nodes ) ) {
11721 query_nodes = new HashSet<PhylogenyNode>();
11722 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11723 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11724 if ( s0.match( query_nodes ) ) {
11728 query_nodes = new HashSet<PhylogenyNode>();
11729 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11730 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11731 if ( s0.match( query_nodes ) ) {
11735 query_nodes = new HashSet<PhylogenyNode>();
11736 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11737 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11738 if ( s0.match( query_nodes ) ) {
11742 query_nodes = new HashSet<PhylogenyNode>();
11743 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11744 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
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( "F" ) );
11752 if ( s0.match( query_nodes ) ) {
11756 query_nodes = new HashSet<PhylogenyNode>();
11757 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11758 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11759 if ( s0.match( query_nodes ) ) {
11763 query_nodes = new HashSet<PhylogenyNode>();
11764 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11765 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11766 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11767 if ( s0.match( query_nodes ) ) {
11771 query_nodes = new HashSet<PhylogenyNode>();
11772 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11773 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11774 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11775 if ( s0.match( query_nodes ) ) {
11779 query_nodes = new HashSet<PhylogenyNode>();
11780 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11781 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11782 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11783 if ( s0.match( query_nodes ) ) {
11787 query_nodes = new HashSet<PhylogenyNode>();
11788 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11789 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11790 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11791 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11792 if ( s0.match( query_nodes ) ) {
11796 catch ( final Exception e ) {
11797 e.printStackTrace();
11803 private static boolean testSubtreeDeletion() {
11805 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11806 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11807 t1.deleteSubtree( t1.getNode( "A" ), false );
11808 if ( t1.getNumberOfExternalNodes() != 5 ) {
11811 t1.toNewHampshireX();
11812 t1.deleteSubtree( t1.getNode( "E" ), false );
11813 if ( t1.getNumberOfExternalNodes() != 4 ) {
11816 t1.toNewHampshireX();
11817 t1.deleteSubtree( t1.getNode( "F" ), false );
11818 if ( t1.getNumberOfExternalNodes() != 3 ) {
11821 t1.toNewHampshireX();
11822 t1.deleteSubtree( t1.getNode( "D" ), false );
11823 t1.toNewHampshireX();
11824 if ( t1.getNumberOfExternalNodes() != 3 ) {
11827 t1.deleteSubtree( t1.getNode( "def" ), false );
11828 t1.toNewHampshireX();
11829 if ( t1.getNumberOfExternalNodes() != 2 ) {
11832 t1.deleteSubtree( t1.getNode( "B" ), false );
11833 t1.toNewHampshireX();
11834 if ( t1.getNumberOfExternalNodes() != 1 ) {
11837 t1.deleteSubtree( t1.getNode( "C" ), false );
11838 t1.toNewHampshireX();
11839 if ( t1.getNumberOfExternalNodes() != 1 ) {
11842 t1.deleteSubtree( t1.getNode( "abc" ), false );
11843 t1.toNewHampshireX();
11844 if ( t1.getNumberOfExternalNodes() != 1 ) {
11847 t1.deleteSubtree( t1.getNode( "r" ), false );
11848 if ( t1.getNumberOfExternalNodes() != 0 ) {
11851 if ( !t1.isEmpty() ) {
11854 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11855 t2.deleteSubtree( t2.getNode( "A" ), false );
11856 t2.toNewHampshireX();
11857 if ( t2.getNumberOfExternalNodes() != 5 ) {
11860 t2.deleteSubtree( t2.getNode( "abc" ), false );
11861 t2.toNewHampshireX();
11862 if ( t2.getNumberOfExternalNodes() != 3 ) {
11865 t2.deleteSubtree( t2.getNode( "def" ), false );
11866 t2.toNewHampshireX();
11867 if ( t2.getNumberOfExternalNodes() != 1 ) {
11871 catch ( final Exception e ) {
11872 e.printStackTrace( System.out );
11878 private static boolean testSupportCount() {
11880 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11881 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
11882 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
11883 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
11884 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
11885 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
11886 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
11888 SupportCount.count( t0_1, phylogenies_1, true, false );
11889 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
11890 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
11891 + "(((((A,B),C),D),E),((F,G),X))"
11892 + "(((((A,Y),B),C),D),((F,G),E))"
11893 + "(((((A,B),C),D),E),(F,G))"
11894 + "(((((A,B),C),D),E),(F,G))"
11895 + "(((((A,B),C),D),E),(F,G))"
11896 + "(((((A,B),C),D),E),(F,G),Z)"
11897 + "(((((A,B),C),D),E),(F,G))"
11898 + "((((((A,B),C),D),E),F),G)"
11899 + "(((((X,Y),F,G),E),((A,B),C)),D)",
11901 SupportCount.count( t0_2, phylogenies_2, true, false );
11902 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
11903 while ( it.hasNext() ) {
11904 final PhylogenyNode n = it.next();
11905 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
11909 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
11910 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
11911 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
11912 SupportCount.count( t0_3, phylogenies_3, true, false );
11913 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
11914 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
11917 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
11920 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
11923 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
11926 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
11929 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
11932 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
11935 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
11938 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
11941 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
11944 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11945 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
11946 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
11947 SupportCount.count( t0_4, phylogenies_4, true, false );
11948 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
11949 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
11952 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
11955 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
11958 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
11961 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
11964 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
11967 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
11970 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
11973 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
11976 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
11979 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11980 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11981 double d = SupportCount.compare( b1, a, true, true, true );
11982 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
11985 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11986 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11987 d = SupportCount.compare( b2, a, true, true, true );
11988 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
11991 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11992 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
11993 d = SupportCount.compare( b3, a, true, true, true );
11994 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
11997 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
11998 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
11999 d = SupportCount.compare( b4, a, true, true, false );
12000 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12004 catch ( final Exception e ) {
12005 e.printStackTrace( System.out );
12011 private static boolean testSupportTransfer() {
12013 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12014 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)",
12015 new NHXParser() )[ 0 ];
12016 final Phylogeny p2 = factory
12017 .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 ];
12018 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12021 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12024 support_transfer.moveBranchLengthsToBootstrap( p1 );
12025 support_transfer.transferSupportValues( p1, p2 );
12026 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12029 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12032 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12035 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12038 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12041 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12044 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12047 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12051 catch ( final Exception e ) {
12052 e.printStackTrace( System.out );
12058 private static boolean testTaxonomyExtraction() {
12060 final PhylogenyNode n0 = PhylogenyNode
12061 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12062 if ( n0.getNodeData().isHasTaxonomy() ) {
12065 final PhylogenyNode n1 = PhylogenyNode
12066 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12067 if ( n1.getNodeData().isHasTaxonomy() ) {
12068 System.out.println( n1.toString() );
12071 final PhylogenyNode n2x = PhylogenyNode
12072 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12073 if ( n2x.getNodeData().isHasTaxonomy() ) {
12076 final PhylogenyNode n3 = PhylogenyNode
12077 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12078 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12079 System.out.println( n3.toString() );
12082 final PhylogenyNode n4 = PhylogenyNode
12083 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12084 if ( n4.getNodeData().isHasTaxonomy() ) {
12085 System.out.println( n4.toString() );
12088 final PhylogenyNode n5 = PhylogenyNode
12089 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12090 if ( n5.getNodeData().isHasTaxonomy() ) {
12091 System.out.println( n5.toString() );
12094 final PhylogenyNode n6 = PhylogenyNode
12095 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12096 if ( n6.getNodeData().isHasTaxonomy() ) {
12097 System.out.println( n6.toString() );
12100 final PhylogenyNode n7 = PhylogenyNode
12101 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12102 if ( n7.getNodeData().isHasTaxonomy() ) {
12103 System.out.println( n7.toString() );
12106 final PhylogenyNode n8 = PhylogenyNode
12107 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12108 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12109 System.out.println( n8.toString() );
12112 final PhylogenyNode n9 = PhylogenyNode
12113 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12114 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12115 System.out.println( n9.toString() );
12118 final PhylogenyNode n10x = PhylogenyNode
12119 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12120 if ( n10x.getNodeData().isHasTaxonomy() ) {
12121 System.out.println( n10x.toString() );
12124 final PhylogenyNode n10xx = PhylogenyNode
12125 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12126 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12127 System.out.println( n10xx.toString() );
12130 final PhylogenyNode n10 = PhylogenyNode
12131 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12132 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12133 System.out.println( n10.toString() );
12136 final PhylogenyNode n11 = PhylogenyNode
12137 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12138 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12139 System.out.println( n11.toString() );
12142 final PhylogenyNode n12 = PhylogenyNode
12143 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12144 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12145 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12146 System.out.println( n12.toString() );
12149 final PhylogenyNode n13 = PhylogenyNode
12150 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12151 if ( n13.getNodeData().isHasTaxonomy() ) {
12152 System.out.println( n13.toString() );
12155 final PhylogenyNode n14 = PhylogenyNode
12156 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12157 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12158 System.out.println( n14.toString() );
12161 final PhylogenyNode n15 = PhylogenyNode
12162 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12163 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12164 System.out.println( n15.toString() );
12167 final PhylogenyNode n16 = PhylogenyNode
12168 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12169 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12170 System.out.println( n16.toString() );
12173 final PhylogenyNode n17 = PhylogenyNode
12174 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12175 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12176 System.out.println( n17.toString() );
12180 final PhylogenyNode n18 = PhylogenyNode
12181 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12182 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12183 System.out.println( n18.toString() );
12186 final PhylogenyNode n19 = PhylogenyNode
12187 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12188 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12189 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12190 System.out.println( n19.toString() );
12193 final PhylogenyNode n20 = PhylogenyNode
12194 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12195 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12196 System.out.println( n20.toString() );
12199 final PhylogenyNode n21 = PhylogenyNode
12200 .createInstanceFromNhxString( "Mus musculus musculus K392",
12201 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12202 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12203 System.out.println( n21.toString() );
12207 catch ( final Exception e ) {
12208 e.printStackTrace( System.out );
12214 private static boolean testTreeCopy() {
12216 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12217 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12218 final Phylogeny t1 = t0.copy();
12219 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12222 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12225 t0.deleteSubtree( t0.getNode( "c" ), true );
12226 t0.deleteSubtree( t0.getNode( "a" ), true );
12227 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12228 t0.getNode( "b" ).setName( "Bee" );
12229 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12232 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12235 t0.deleteSubtree( t0.getNode( "e" ), true );
12236 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12237 t0.deleteSubtree( t0.getNode( "d" ), true );
12238 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12242 catch ( final Exception e ) {
12243 e.printStackTrace();
12249 private static boolean testTreeMethods() {
12251 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12252 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12253 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12254 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12255 System.out.println( t0.toNewHampshireX() );
12258 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12259 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12260 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12263 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12266 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12270 catch ( final Exception e ) {
12271 e.printStackTrace( System.out );
12277 private static boolean testUniprotEntryRetrieval() {
12279 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
12280 if ( !entry.getAccession().equals( "P12345" ) ) {
12283 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12286 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12289 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12292 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12295 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12299 catch ( final IOException e ) {
12300 System.out.println();
12301 System.out.println( "the following might be due to absence internet connection:" );
12302 e.printStackTrace( System.out );
12305 catch ( final Exception e ) {
12311 private static boolean testUniprotTaxonomySearch() {
12313 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12315 if ( results.size() != 1 ) {
12318 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12321 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12324 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12327 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12330 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12334 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12335 if ( results.size() != 1 ) {
12338 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12341 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12344 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12347 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12350 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12354 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12355 if ( results.size() != 1 ) {
12358 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12361 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12364 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12367 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12370 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12374 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12375 if ( results.size() != 1 ) {
12378 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12381 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12384 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12387 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12390 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12393 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12396 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12399 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12400 .equals( "Nematostella vectensis" ) ) {
12401 System.out.println( results.get( 0 ).getLineage() );
12406 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12407 if ( results.size() != 1 ) {
12410 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12413 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12416 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12419 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12422 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12425 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12426 .equals( "Xenopus tropicalis" ) ) {
12427 System.out.println( results.get( 0 ).getLineage() );
12432 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12433 if ( results.size() != 1 ) {
12436 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12439 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12442 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12445 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12448 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12451 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12452 .equals( "Xenopus tropicalis" ) ) {
12453 System.out.println( results.get( 0 ).getLineage() );
12458 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12459 if ( results.size() != 1 ) {
12462 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12465 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12468 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12471 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12474 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12477 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12478 .equals( "Xenopus tropicalis" ) ) {
12479 System.out.println( results.get( 0 ).getLineage() );
12483 catch ( final IOException e ) {
12484 System.out.println();
12485 System.out.println( "the following might be due to absence internet connection:" );
12486 e.printStackTrace( System.out );
12489 catch ( final Exception e ) {
12495 private static boolean testWabiTxSearch() {
12497 String result = "";
12498 result = TxSearch.searchSimple( "nematostella" );
12499 result = TxSearch.getTxId( "nematostella" );
12500 if ( !result.equals( "45350" ) ) {
12503 result = TxSearch.getTxName( "45350" );
12504 if ( !result.equals( "Nematostella" ) ) {
12507 result = TxSearch.getTxId( "nematostella vectensis" );
12508 if ( !result.equals( "45351" ) ) {
12511 result = TxSearch.getTxName( "45351" );
12512 if ( !result.equals( "Nematostella vectensis" ) ) {
12515 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12516 if ( !result.equals( "536089" ) ) {
12519 result = TxSearch.getTxName( "536089" );
12520 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12523 final List<String> queries = new ArrayList<String>();
12524 queries.add( "Campylobacter coli" );
12525 queries.add( "Escherichia coli" );
12526 queries.add( "Arabidopsis" );
12527 queries.add( "Trichoplax" );
12528 queries.add( "Samanea saman" );
12529 queries.add( "Kluyveromyces marxianus" );
12530 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12531 queries.add( "Bornavirus parrot/PDD/2008" );
12532 final List<RANKS> ranks = new ArrayList<RANKS>();
12533 ranks.add( RANKS.SUPERKINGDOM );
12534 ranks.add( RANKS.KINGDOM );
12535 ranks.add( RANKS.FAMILY );
12536 ranks.add( RANKS.GENUS );
12537 ranks.add( RANKS.TRIBE );
12538 result = TxSearch.searchLineage( queries, ranks );
12539 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12540 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12542 catch ( final Exception e ) {
12543 System.out.println();
12544 System.out.println( "the following might be due to absence internet connection:" );
12545 e.printStackTrace( System.out );