2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2014 Christian M. Zmasek
6 // Copyright (C) 2014 Sanford-Burnham Medical Research Institute
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.test;
27 import java.io.ByteArrayInputStream;
29 import java.io.FileInputStream;
30 import java.io.IOException;
31 import java.io.StringWriter;
32 import java.io.Writer;
34 import java.util.ArrayList;
35 import java.util.Date;
36 import java.util.HashSet;
37 import java.util.Iterator;
38 import java.util.List;
39 import java.util.Locale;
41 import java.util.SortedSet;
43 import org.forester.application.support_transfer;
44 import org.forester.archaeopteryx.AptxUtil;
45 import org.forester.archaeopteryx.TreePanelUtil;
46 import org.forester.archaeopteryx.webservices.WebserviceUtil;
47 import org.forester.clade_analysis.CladeAnalysisTest;
48 import org.forester.development.DevelopmentTools;
49 import org.forester.evoinference.TestPhylogenyReconstruction;
50 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
51 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
52 import org.forester.go.TestGo;
53 import org.forester.io.parsers.FastaParser;
54 import org.forester.io.parsers.GeneralMsaParser;
55 import org.forester.io.parsers.HmmscanPerDomainTableParser;
56 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
57 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
58 import org.forester.io.parsers.nexus.NexusCharactersParser;
59 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
60 import org.forester.io.parsers.nhx.NHXParser;
61 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
62 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
63 import org.forester.io.parsers.tol.TolParser;
64 import org.forester.io.parsers.util.ParserUtils;
65 import org.forester.io.writers.PhylogenyWriter;
66 import org.forester.io.writers.SequenceWriter;
67 import org.forester.msa.BasicMsa;
68 import org.forester.msa.DeleteableMsa;
69 import org.forester.msa.Mafft;
70 import org.forester.msa.Msa;
71 import org.forester.msa.Msa.MSA_FORMAT;
72 import org.forester.msa.MsaInferrer;
73 import org.forester.msa.MsaMethods;
74 import org.forester.pccx.TestPccx;
75 import org.forester.phylogeny.Phylogeny;
76 import org.forester.phylogeny.PhylogenyBranch;
77 import org.forester.phylogeny.PhylogenyMethods;
78 import org.forester.phylogeny.PhylogenyNode;
79 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
80 import org.forester.phylogeny.data.Accession;
81 import org.forester.phylogeny.data.Accession.Source;
82 import org.forester.phylogeny.data.BinaryCharacters;
83 import org.forester.phylogeny.data.BranchWidth;
84 import org.forester.phylogeny.data.Confidence;
85 import org.forester.phylogeny.data.Distribution;
86 import org.forester.phylogeny.data.DomainArchitecture;
87 import org.forester.phylogeny.data.Event;
88 import org.forester.phylogeny.data.Identifier;
89 import org.forester.phylogeny.data.PhylogenyData;
90 import org.forester.phylogeny.data.PhylogenyDataUtil;
91 import org.forester.phylogeny.data.Polygon;
92 import org.forester.phylogeny.data.PropertiesList;
93 import org.forester.phylogeny.data.Property;
94 import org.forester.phylogeny.data.Property.AppliesTo;
95 import org.forester.phylogeny.data.ProteinDomain;
96 import org.forester.phylogeny.data.Taxonomy;
97 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
98 import org.forester.phylogeny.factories.PhylogenyFactory;
99 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
100 import org.forester.protein.BasicDomain;
101 import org.forester.protein.BasicProtein;
102 import org.forester.protein.Domain;
103 import org.forester.protein.Protein;
104 import org.forester.protein.ProteinId;
105 import org.forester.rio.TestRIO;
106 import org.forester.sdi.SDI;
107 import org.forester.sdi.SDIR;
108 import org.forester.sdi.TestGSDI;
109 import org.forester.sequence.BasicSequence;
110 import org.forester.sequence.MolecularSequence;
111 import org.forester.species.BasicSpecies;
112 import org.forester.species.Species;
113 import org.forester.surfacing.TestSurfacing;
114 import org.forester.tools.ConfidenceAssessor;
115 import org.forester.tools.SupportCount;
116 import org.forester.tools.TreeSplitMatrix;
117 import org.forester.util.AsciiHistogram;
118 import org.forester.util.BasicDescriptiveStatistics;
119 import org.forester.util.BasicTable;
120 import org.forester.util.BasicTableParser;
121 import org.forester.util.DescriptiveStatistics;
122 import org.forester.util.ForesterConstants;
123 import org.forester.util.ForesterUtil;
124 import org.forester.util.GeneralTable;
125 import org.forester.util.SequenceAccessionTools;
126 import org.forester.ws.seqdb.SequenceDatabaseEntry;
127 import org.forester.ws.seqdb.SequenceDbWsTools;
128 import org.forester.ws.seqdb.UniProtTaxonomy;
130 @SuppressWarnings( "unused")
131 public final class Test {
133 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
134 + ForesterUtil.getFileSeparator() + "resources" + ForesterUtil.getFileSeparator();
135 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
136 + ForesterUtil.getFileSeparator() + "test_data" + ForesterUtil.getFileSeparator();
137 private final static boolean PERFORM_DB_TESTS = false;
138 private static final boolean PERFORM_WEB_TREE_ACCESS = false;
139 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
140 + ForesterConstants.PHYLO_XML_VERSION + "/" + ForesterConstants.PHYLO_XML_XSD;
141 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
142 + ForesterConstants.PHYLO_XML_VERSION + "/" + ForesterConstants.PHYLO_XML_XSD;
143 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
144 private final static double ZERO_DIFF = 1.0E-9;
146 private static boolean isEqual( final double a, final double b ) {
147 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
150 public static void main( final String[] args ) {
151 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
152 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
154 Locale.setDefault( Locale.US );
155 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
158 System.out.print( "[Test if directory with files for testing exists/is readable: " );
159 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
160 System.out.println( "OK.]" );
163 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
164 System.out.println( "Testing aborted." );
167 System.out.print( "[Test if resources directory exists/is readable: " );
168 if ( testDir( PATH_TO_RESOURCES ) ) {
169 System.out.println( "OK.]" );
172 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
173 System.out.println( "Testing aborted." );
176 final long start_time = new Date().getTime();
177 System.out.print( "Basic node methods: " );
178 if ( Test.testBasicNodeMethods() ) {
179 System.out.println( "OK." );
183 System.out.println( "failed." );
186 System.out.print( "Protein id: " );
187 if ( !testProteinId() ) {
188 System.out.println( "failed." );
194 System.out.println( "OK." );
195 System.out.print( "Species: " );
196 if ( !testSpecies() ) {
197 System.out.println( "failed." );
203 System.out.println( "OK." );
204 System.out.print( "Basic domain: " );
205 if ( !testBasicDomain() ) {
206 System.out.println( "failed." );
212 System.out.println( "OK." );
213 System.out.print( "Basic protein: " );
214 if ( !testBasicProtein() ) {
215 System.out.println( "failed." );
221 System.out.println( "OK." );
223 System.out.print( "Common prefix: " );
224 if ( !testCommonPrefix() ) {
225 System.out.println( "failed." );
231 System.out.println( "OK." );
233 System.out.print( "Common prefix sep: " );
234 if ( !testCommonPrefixSep() ) {
235 System.out.println( "failed." );
241 System.out.println( "OK." );
244 System.out.print( "Sequence writer: " );
245 if ( testSequenceWriter() ) {
246 System.out.println( "OK." );
250 System.out.println( "failed." );
253 System.out.print( "Sequence id parsing: " );
254 if ( testSequenceIdParsing() ) {
255 System.out.println( "OK." );
259 System.out.println( "failed." );
262 System.out.print( "UniProtKB id extraction: " );
263 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
264 System.out.println( "OK." );
268 System.out.println( "failed." );
271 System.out.print( "Sequence DB tools 1: " );
272 if ( testSequenceDbWsTools1() ) {
273 System.out.println( "OK." );
277 System.out.println( "failed." );
280 System.out.print( "Hmmscan output parser: " );
281 if ( testHmmscanOutputParser() ) {
282 System.out.println( "OK." );
286 System.out.println( "failed." );
289 System.out.print( "Overlap removal: " );
290 if ( !org.forester.test.Test.testOverlapRemoval() ) {
291 System.out.println( "failed." );
297 System.out.println( "OK." );
298 System.out.print( "Engulfing overlap removal: " );
299 if ( !Test.testEngulfingOverlapRemoval() ) {
300 System.out.println( "failed." );
306 System.out.println( "OK." );
307 System.out.print( "Taxonomy data extraction: " );
308 if ( Test.testExtractTaxonomyDataFromNodeName() ) {
309 System.out.println( "OK." );
313 System.out.println( "failed." );
316 System.out.print( "Taxonomy code extraction: " );
317 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
318 System.out.println( "OK." );
322 System.out.println( "failed." );
325 System.out.print( "SN extraction: " );
326 if ( Test.testExtractSNFromNodeName() ) {
327 System.out.println( "OK." );
331 System.out.println( "failed." );
334 System.out.print( "Taxonomy extraction (general): " );
335 if ( Test.testTaxonomyExtraction() ) {
336 System.out.println( "OK." );
340 System.out.println( "failed." );
343 System.out.print( "Uri for Aptx web sequence accession: " );
344 if ( Test.testCreateUriForSeqWeb() ) {
345 System.out.println( "OK." );
349 System.out.println( "failed." );
352 System.out.print( "Basic node construction and parsing of NHX (node level): " );
353 if ( Test.testNHXNodeParsing() ) {
354 System.out.println( "OK." );
358 System.out.println( "failed." );
361 System.out.print( "Node construction and parsing of NHX (node level): " );
362 if ( Test.testNHXNodeParsing2() ) {
363 System.out.println( "OK." );
367 System.out.println( "failed." );
370 System.out.print( "NHX parsing iterating: " );
371 if ( Test.testNHParsingIter() ) {
372 System.out.println( "OK." );
376 System.out.println( "failed." );
379 System.out.print( "NH parsing: " );
380 if ( Test.testNHParsing() ) {
381 System.out.println( "OK." );
385 System.out.println( "failed." );
388 System.out.print( "NH parsing - special chars: " );
389 if ( Test.testNHParsingSpecialChars() ) {
390 System.out.println( "OK." );
394 System.out.println( "failed." );
397 System.out.print( "Conversion to NHX (node level): " );
398 if ( Test.testNHXconversion() ) {
399 System.out.println( "OK." );
403 System.out.println( "failed." );
406 System.out.print( "NHX parsing: " );
407 if ( Test.testNHXParsing() ) {
408 System.out.println( "OK." );
412 System.out.println( "failed." );
415 System.out.print( "NHX parsing with quotes: " );
416 if ( Test.testNHXParsingQuotes() ) {
417 System.out.println( "OK." );
421 System.out.println( "failed." );
424 System.out.print( "NHX parsing (MrBayes): " );
425 if ( Test.testNHXParsingMB() ) {
426 System.out.println( "OK." );
430 System.out.println( "failed." );
433 System.out.print( "Nexus characters parsing: " );
434 if ( Test.testNexusCharactersParsing() ) {
435 System.out.println( "OK." );
439 System.out.println( "failed." );
442 System.out.print( "Nexus tree parsing iterating: " );
443 if ( Test.testNexusTreeParsingIterating() ) {
444 System.out.println( "OK." );
448 System.out.println( "failed." );
451 System.out.print( "Nexus tree parsing: " );
452 if ( Test.testNexusTreeParsing() ) {
453 System.out.println( "OK." );
457 System.out.println( "failed." );
460 System.out.print( "Nexus tree parsing (translating): " );
461 if ( Test.testNexusTreeParsingTranslating() ) {
462 System.out.println( "OK." );
466 System.out.println( "failed." );
469 System.out.print( "Nexus matrix parsing: " );
470 if ( Test.testNexusMatrixParsing() ) {
471 System.out.println( "OK." );
475 System.out.println( "failed." );
478 System.out.print( "Basic phyloXML parsing: " );
479 if ( Test.testBasicPhyloXMLparsing() ) {
480 System.out.println( "OK." );
484 System.out.println( "failed." );
487 System.out.print( "Basic phyloXML parsing (validating against schema): " );
488 if ( testBasicPhyloXMLparsingValidating() ) {
489 System.out.println( "OK." );
493 System.out.println( "failed." );
496 System.out.print( "phyloXML parsing (validating against schema): " );
497 if ( testPhyloXMLparsingValidating() ) {
498 System.out.println( "OK." );
502 System.out.println( "failed." );
505 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
506 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
507 System.out.println( "OK." );
511 System.out.println( "failed." );
514 System.out.print( "phyloXML Distribution Element: " );
515 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
516 System.out.println( "OK." );
520 System.out.println( "failed." );
523 System.out.print( "Tol XML parsing: " );
524 if ( Test.testBasicTolXMLparsing() ) {
525 System.out.println( "OK." );
529 System.out.println( "failed." );
532 System.out.print( "UTF-8 parsing from file: " );
533 if ( Test.testUTF8ParsingFromFile() ) {
534 System.out.println( "OK." );
538 System.out.println( "failed." );
541 System.out.print( "Copying of node data: " );
542 if ( Test.testCopyOfNodeData() ) {
543 System.out.println( "OK." );
547 System.out.println( "failed." );
550 System.out.print( "Tree copy: " );
551 if ( Test.testTreeCopy() ) {
552 System.out.println( "OK." );
556 System.out.println( "failed." );
559 System.out.print( "Basic tree methods: " );
560 if ( Test.testBasicTreeMethods() ) {
561 System.out.println( "OK." );
565 System.out.println( "failed." );
568 System.out.print( "Tree methods: " );
569 if ( Test.testTreeMethods() ) {
570 System.out.println( "OK." );
574 System.out.println( "failed." );
577 System.out.print( "Phylogeny methods:" );
578 if ( Test.testPhylogenyMethods() ) {
579 System.out.println( "OK." );
583 System.out.println( "failed." );
586 System.out.print( "Postorder Iterator: " );
587 if ( Test.testPostOrderIterator() ) {
588 System.out.println( "OK." );
592 System.out.println( "failed." );
595 System.out.print( "Preorder Iterator: " );
596 if ( Test.testPreOrderIterator() ) {
597 System.out.println( "OK." );
601 System.out.println( "failed." );
604 System.out.print( "Levelorder Iterator: " );
605 if ( Test.testLevelOrderIterator() ) {
606 System.out.println( "OK." );
610 System.out.println( "failed." );
613 System.out.print( "Re-id methods: " );
614 if ( Test.testReIdMethods() ) {
615 System.out.println( "OK." );
619 System.out.println( "failed." );
622 System.out.print( "Methods on last external nodes: " );
623 if ( Test.testLastExternalNodeMethods() ) {
624 System.out.println( "OK." );
628 System.out.println( "failed." );
631 System.out.print( "Methods on external nodes: " );
632 if ( Test.testExternalNodeRelatedMethods() ) {
633 System.out.println( "OK." );
637 System.out.println( "failed." );
640 System.out.print( "Deletion of external nodes: " );
641 if ( Test.testDeletionOfExternalNodes() ) {
642 System.out.println( "OK." );
646 System.out.println( "failed." );
649 System.out.print( "Subtree deletion: " );
650 if ( Test.testSubtreeDeletion() ) {
651 System.out.println( "OK." );
655 System.out.println( "failed." );
658 System.out.print( "Phylogeny branch: " );
659 if ( Test.testPhylogenyBranch() ) {
660 System.out.println( "OK." );
664 System.out.println( "failed." );
667 System.out.print( "Rerooting: " );
668 if ( Test.testRerooting() ) {
669 System.out.println( "OK." );
673 System.out.println( "failed." );
676 System.out.print( "Mipoint rooting: " );
677 if ( Test.testMidpointrooting() ) {
678 System.out.println( "OK." );
682 System.out.println( "failed." );
685 System.out.print( "Node removal: " );
686 if ( Test.testNodeRemoval() ) {
687 System.out.println( "OK." );
691 System.out.println( "failed." );
694 System.out.print( "Support count: " );
695 if ( Test.testSupportCount() ) {
696 System.out.println( "OK." );
700 System.out.println( "failed." );
703 System.out.print( "Support transfer: " );
704 if ( Test.testSupportTransfer() ) {
705 System.out.println( "OK." );
709 System.out.println( "failed." );
712 System.out.print( "Finding of LCA: " );
713 if ( Test.testGetLCA() ) {
714 System.out.println( "OK." );
718 System.out.println( "failed." );
721 System.out.print( "Finding of LCA 2: " );
722 if ( Test.testGetLCA2() ) {
723 System.out.println( "OK." );
727 System.out.println( "failed." );
730 System.out.print( "Calculation of distance between nodes: " );
731 if ( Test.testGetDistance() ) {
732 System.out.println( "OK." );
736 System.out.println( "failed." );
739 System.out.print( "Descriptive statistics: " );
740 if ( Test.testDescriptiveStatistics() ) {
741 System.out.println( "OK." );
745 System.out.println( "failed." );
748 System.out.print( "Data objects and methods: " );
749 if ( Test.testDataObjects() ) {
750 System.out.println( "OK." );
754 System.out.println( "failed." );
757 System.out.print( "Properties map: " );
758 if ( Test.testPropertiesMap() ) {
759 System.out.println( "OK." );
763 System.out.println( "failed." );
766 System.out.print( "SDIse: " );
767 if ( Test.testSDIse() ) {
768 System.out.println( "OK." );
772 System.out.println( "failed." );
775 System.out.print( "SDIunrooted: " );
776 if ( Test.testSDIunrooted() ) {
777 System.out.println( "OK." );
781 System.out.println( "failed." );
784 System.out.print( "GSDI: " );
785 if ( TestGSDI.test() ) {
786 System.out.println( "OK." );
790 System.out.println( "failed." );
793 System.out.print( "RIO: " );
794 if ( TestRIO.test() ) {
795 System.out.println( "OK." );
799 System.out.println( "failed." );
802 System.out.print( "Clade analyis: " );
803 if ( CladeAnalysisTest.test() ) {
804 System.out.println( "OK." );
808 System.out.println( "failed." );
811 System.out.print( "Phylogeny reconstruction:" );
812 System.out.println();
813 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
814 System.out.println( "OK." );
818 System.out.println( "failed." );
821 System.out.print( "Analysis of domain architectures: " );
822 System.out.println();
823 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
824 System.out.println( "OK." );
828 System.out.println( "failed." );
831 System.out.print( "GO: " );
832 System.out.println();
833 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
834 System.out.println( "OK." );
838 System.out.println( "failed." );
841 System.out.print( "Modeling tools: " );
842 if ( TestPccx.test() ) {
843 System.out.println( "OK." );
847 System.out.println( "failed." );
850 System.out.print( "Split Matrix strict: " );
851 if ( Test.testSplitStrict() ) {
852 System.out.println( "OK." );
856 System.out.println( "failed." );
859 System.out.print( "Split Matrix: " );
860 if ( Test.testSplit() ) {
861 System.out.println( "OK." );
865 System.out.println( "failed." );
868 System.out.print( "Confidence Assessor: " );
869 if ( Test.testConfidenceAssessor() ) {
870 System.out.println( "OK." );
874 System.out.println( "failed." );
877 System.out.print( "Basic table: " );
878 if ( Test.testBasicTable() ) {
879 System.out.println( "OK." );
883 System.out.println( "failed." );
886 System.out.print( "General table: " );
887 if ( Test.testGeneralTable() ) {
888 System.out.println( "OK." );
892 System.out.println( "failed." );
895 System.out.print( "Amino acid sequence: " );
896 if ( Test.testAminoAcidSequence() ) {
897 System.out.println( "OK." );
901 System.out.println( "failed." );
904 System.out.print( "General MSA parser: " );
905 if ( Test.testGeneralMsaParser() ) {
906 System.out.println( "OK." );
910 System.out.println( "failed." );
913 System.out.print( "Fasta parser for msa: " );
914 if ( Test.testFastaParser() ) {
915 System.out.println( "OK." );
919 System.out.println( "failed." );
922 System.out.print( "Creation of balanced phylogeny: " );
923 if ( Test.testCreateBalancedPhylogeny() ) {
924 System.out.println( "OK." );
928 System.out.println( "failed." );
931 System.out.print( "Genbank accessor parsing: " );
932 if ( Test.testGenbankAccessorParsing() ) {
933 System.out.println( "OK." );
937 System.out.println( "failed." );
941 final String os = ForesterUtil.OS_NAME.toLowerCase();
942 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
943 path = "/usr/local/bin/mafft";
945 else if ( os.indexOf( "win" ) >= 0 ) {
946 path = "C:\\Program Files\\mafft-win\\mafft.bat";
950 if ( !MsaInferrer.isInstalled( path ) ) {
951 path = "/usr/bin/mafft";
953 if ( !MsaInferrer.isInstalled( path ) ) {
954 path = "/usr/local/bin/mafft";
957 if ( MsaInferrer.isInstalled( path ) ) {
958 System.out.print( "MAFFT (external program): " );
959 if ( Test.testMafft( path ) ) {
960 System.out.println( "OK." );
964 System.out.println( "failed [will not count towards failed tests]" );
967 System.out.print( "Next nodes with collapsed: " );
968 if ( Test.testNextNodeWithCollapsing() ) {
969 System.out.println( "OK." );
973 System.out.println( "failed." );
976 System.out.print( "Simple MSA quality: " );
977 if ( Test.testMsaQualityMethod() ) {
978 System.out.println( "OK." );
982 System.out.println( "failed." );
985 System.out.print( "Deleteable MSA: " );
986 if ( Test.testDeleteableMsa() ) {
987 System.out.println( "OK." );
991 System.out.println( "failed." );
994 System.out.print( "MSA entropy: " );
995 if ( Test.testMsaEntropy() ) {
996 System.out.println( "OK." );
1000 System.out.println( "failed." );
1003 if ( PERFORM_DB_TESTS ) {
1004 System.out.print( "Uniprot Entry Retrieval: " );
1005 if ( Test.testUniprotEntryRetrieval() ) {
1006 System.out.println( "OK." );
1010 System.out.println( "failed." );
1013 System.out.print( "Ebi Entry Retrieval: " );
1014 if ( Test.testEbiEntryRetrieval() ) {
1015 System.out.println( "OK." );
1019 System.out.println( "failed." );
1022 System.out.print( "Sequence DB tools 2: " );
1023 if ( testSequenceDbWsTools2() ) {
1024 System.out.println( "OK." );
1028 System.out.println( "failed." );
1032 System.out.print( "Uniprot Taxonomy Search: " );
1033 if ( Test.testUniprotTaxonomySearch() ) {
1034 System.out.println( "OK." );
1038 System.out.println( "failed." );
1042 if ( PERFORM_WEB_TREE_ACCESS ) {
1043 System.out.print( "TreeBase acccess: " );
1044 if ( Test.testTreeBaseReading() ) {
1045 System.out.println( "OK." );
1049 System.out.println( "failed." );
1052 System.out.print( "ToL access: " );
1053 if ( Test.testToLReading() ) {
1054 System.out.println( "OK." );
1058 System.out.println( "failed." );
1061 System.out.print( "NHX parsing from URL: " );
1062 if ( Test.testNHXparsingFromURL() ) {
1063 System.out.println( "OK." );
1067 System.out.println( "failed." );
1070 System.out.print( "NHX parsing from URL 2: " );
1071 if ( Test.testNHXparsingFromURL2() ) {
1072 System.out.println( "OK." );
1076 System.out.println( "failed." );
1079 System.out.print( "phyloXML parsing from URL: " );
1080 if ( Test.testPhyloXMLparsingFromURL() ) {
1081 System.out.println( "OK." );
1085 System.out.println( "failed." );
1088 System.out.print( "TreeFam access: " );
1089 if ( Test.testTreeFamReading() ) {
1090 System.out.println( "OK." );
1094 System.out.println( "failed." );
1097 System.out.print( "Pfam tree access: " );
1098 if ( Test.testPfamTreeReading() ) {
1099 System.out.println( "OK." );
1103 System.out.println( "failed." );
1107 System.out.println();
1108 final Runtime rt = java.lang.Runtime.getRuntime();
1109 final long free_memory = rt.freeMemory() / 1000000;
1110 final long total_memory = rt.totalMemory() / 1000000;
1111 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1112 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1113 System.out.println();
1114 System.out.println( "Successful tests: " + succeeded );
1115 System.out.println( "Failed tests: " + failed );
1116 System.out.println();
1118 System.out.println( "OK." );
1121 System.out.println( "Not OK." );
1126 private static boolean testEngulfingOverlapRemoval() {
1128 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1129 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1130 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1131 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1132 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1133 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1134 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1135 final List<Boolean> covered = new ArrayList<Boolean>();
1136 covered.add( true ); // 0
1137 covered.add( false ); // 1
1138 covered.add( true ); // 2
1139 covered.add( false ); // 3
1140 covered.add( true ); // 4
1141 covered.add( true ); // 5
1142 covered.add( false ); // 6
1143 covered.add( true ); // 7
1144 covered.add( true ); // 8
1145 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1148 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1151 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1154 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1157 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1160 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1163 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1166 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1167 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1168 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1169 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1170 abc.addProteinDomain( a );
1171 abc.addProteinDomain( b );
1172 abc.addProteinDomain( c );
1173 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1174 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1175 if ( abc.getNumberOfProteinDomains() != 3 ) {
1178 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1181 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1184 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1187 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1190 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1191 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1192 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1193 final Protein def = new BasicProtein( "def", "nemve", 0 );
1194 def.addProteinDomain( d );
1195 def.addProteinDomain( e );
1196 def.addProteinDomain( f );
1197 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1198 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1199 if ( def.getNumberOfProteinDomains() != 3 ) {
1202 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1205 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1208 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1211 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1214 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1218 catch ( final Exception e ) {
1219 e.printStackTrace( System.out );
1225 private static final boolean testNHXparsingFromURL2() {
1227 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1228 final Phylogeny phys[] = AptxUtil
1229 .readPhylogeniesFromUrl( new URL( s ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1230 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1233 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1234 System.out.println( phys[ 0 ].toNewHampshire() );
1237 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1238 System.out.println( phys[ 1 ].toNewHampshire() );
1241 final Phylogeny phys2[] = AptxUtil
1242 .readPhylogeniesFromUrl( new URL( s ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1243 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1246 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1247 System.out.println( phys2[ 0 ].toNewHampshire() );
1250 if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1251 System.out.println( phys2[ 1 ].toNewHampshire() );
1254 final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1255 + "SwissTree/ST001/consensus_tree.nhx" ),
1259 TAXONOMY_EXTRACTION.NO,
1261 if ( ( phys3 == null ) || ( phys3.length != 1 ) ) {
1264 if ( !phys3[ 0 ].toNewHampshire()
1265 .equals( "((((POP23a_CIOIN_ENSCING00000016202,POP23b_CIOIN_ENSCING00000016169),POP23_CIOSA_ENSCSAVG00000000248),((POP23a_BRAFL_C3ZMF1,POP23b_BRAFL_121417),(((POP3_ORYLA_ENSORLG00000019669,POP3_GASAC_ENSGACG00000014023,POP3_DANRE_Q6JWW1),(POP3_XENTR_B1H1F6,(POP3_CHICK_Q9DG25,(POP3_ORNAN_ENSOANG00000004179,POP3_MONDO_ENSMODG00000018033,((POP3_MOUSE_Q9ES81,POP3_RAT_Q3BCU3),POP3_RABIT_ENSOCUG00000025973,POP3_MACMU_ENSMMUG00000014473,POP3_HUMAN_Q9HBV1))))),(((POP2_GASAC_ENSGACG00000001420,POP2_ORYLA_ENSORLG00000008627,POP2_TAKRU_ENSTRUG00000015933),POP2_DANRE_ENSDARG00000069922),POP2_XENTR_ENSXETG00000018064,(((POP2_TAEGU_ENSTGUG00000013383,POP2_CHICK_Q6T9Z5),POP2_ANOCA_ENSACAG00000003557),((POP2_MACEU_ENSMEUG00000015825,POP2_MONDO_ENSMODG00000018205),((POP2_RABIT_ENSOCUG00000009515,(POP2_RAT_Q6P722,POP2_MOUSE_Q9ES82)),(POP2_MACMU_ENSMMUG00000000905,POP2_HUMAN_Q9HBU9)))))))),((POP1_CIOSA_ENSCSAVG00000000247,POP1_CIOIN_ENSCING00000000496),((POP1_DANRE_Q5PQZ7,(POP1_ORYLA_ENSORLG00000019663,POP1_GASAC_ENSGACG00000014015,POP1_TAKRU_ENSORLG00000019663)),(POP1_XENTR_B1H1G2,(POP1_ANOCA_ENSACAG00000003910,(POP1_TAEGU_ENSTGUG00000012218,POP1_CHICK_Q9DG23)),POP1_ORNAN_ENSOANG00000004180,POP1_MONDO_ENSMODG00000018034,(POP1_RABIT_ENSOCUG00000016944,(POP1_RAT_Q3BCU4,POP1_MOUSE_Q9ES83),(POP1_HUMAN_Q8NE79,POP1_MACMU_ENSMMUG00000014471))))));" ) ) {
1266 System.out.println( phys3[ 0 ].toNewHampshire() );
1269 final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1270 + "SwissTree/ST001/consensus_tree.nhx" ),
1274 TAXONOMY_EXTRACTION.NO,
1276 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1279 if ( !phys4[ 0 ].toNewHampshire()
1280 .equals( "((((POP23a_CIOIN_ENSCING00000016202,POP23b_CIOIN_ENSCING00000016169),POP23_CIOSA_ENSCSAVG00000000248),((POP23a_BRAFL_C3ZMF1,POP23b_BRAFL_121417),(((POP3_ORYLA_ENSORLG00000019669,POP3_GASAC_ENSGACG00000014023,POP3_DANRE_Q6JWW1),(POP3_XENTR_B1H1F6,(POP3_CHICK_Q9DG25,(POP3_ORNAN_ENSOANG00000004179,POP3_MONDO_ENSMODG00000018033,((POP3_MOUSE_Q9ES81,POP3_RAT_Q3BCU3),POP3_RABIT_ENSOCUG00000025973,POP3_MACMU_ENSMMUG00000014473,POP3_HUMAN_Q9HBV1))))),(((POP2_GASAC_ENSGACG00000001420,POP2_ORYLA_ENSORLG00000008627,POP2_TAKRU_ENSTRUG00000015933),POP2_DANRE_ENSDARG00000069922),POP2_XENTR_ENSXETG00000018064,(((POP2_TAEGU_ENSTGUG00000013383,POP2_CHICK_Q6T9Z5),POP2_ANOCA_ENSACAG00000003557),((POP2_MACEU_ENSMEUG00000015825,POP2_MONDO_ENSMODG00000018205),((POP2_RABIT_ENSOCUG00000009515,(POP2_RAT_Q6P722,POP2_MOUSE_Q9ES82)),(POP2_MACMU_ENSMMUG00000000905,POP2_HUMAN_Q9HBU9)))))))),((POP1_CIOSA_ENSCSAVG00000000247,POP1_CIOIN_ENSCING00000000496),((POP1_DANRE_Q5PQZ7,(POP1_ORYLA_ENSORLG00000019663,POP1_GASAC_ENSGACG00000014015,POP1_TAKRU_ENSORLG00000019663)),(POP1_XENTR_B1H1G2,(POP1_ANOCA_ENSACAG00000003910,(POP1_TAEGU_ENSTGUG00000012218,POP1_CHICK_Q9DG23)),POP1_ORNAN_ENSOANG00000004180,POP1_MONDO_ENSMODG00000018034,(POP1_RABIT_ENSOCUG00000016944,(POP1_RAT_Q3BCU4,POP1_MOUSE_Q9ES83),(POP1_HUMAN_Q8NE79,POP1_MACMU_ENSMMUG00000014471))))));" ) ) {
1281 System.out.println( phys4[ 0 ].toNewHampshire() );
1285 catch ( final Exception e ) {
1286 e.printStackTrace();
1292 private static final boolean testNHXparsingFromURL() {
1294 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1295 final URL u = new URL( s );
1296 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1297 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1298 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1301 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1302 System.out.println( phys[ 0 ].toNewHampshire() );
1305 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1306 System.out.println( phys[ 1 ].toNewHampshire() );
1309 final URL u2 = new URL( s );
1310 final Phylogeny[] phys2 = factory.create( u2.openStream(), new NHXParser() );
1311 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1314 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1315 System.out.println( phys2[ 0 ].toNewHampshire() );
1318 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1319 final NHXParser p = new NHXParser();
1320 final URL u3 = new URL( s );
1322 if ( !p.hasNext() ) {
1325 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1328 if ( !p.hasNext() ) {
1332 if ( !p.hasNext() ) {
1335 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1338 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1342 if ( !p.hasNext() ) {
1345 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1348 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1352 catch ( final Exception e ) {
1353 System.out.println( e.toString() );
1354 e.printStackTrace();
1360 private static boolean testOverlapRemoval() {
1362 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1363 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1364 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1365 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1366 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1367 final List<Boolean> covered = new ArrayList<Boolean>();
1368 covered.add( true ); // 0
1369 covered.add( false ); // 1
1370 covered.add( true ); // 2
1371 covered.add( false ); // 3
1372 covered.add( true ); // 4
1373 covered.add( true ); // 5
1374 covered.add( false ); // 6
1375 covered.add( true ); // 7
1376 covered.add( true ); // 8
1377 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1380 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1383 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1386 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1389 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1392 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1393 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1394 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1395 ab.addProteinDomain( a );
1396 ab.addProteinDomain( b );
1397 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1398 if ( ab.getNumberOfProteinDomains() != 2 ) {
1401 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1404 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1407 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1408 if ( ab.getNumberOfProteinDomains() != 2 ) {
1411 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1414 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1415 final Domain d = new BasicDomain( "d",
1422 final Domain e = new BasicDomain( "e",
1429 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1430 cde.addProteinDomain( c );
1431 cde.addProteinDomain( d );
1432 cde.addProteinDomain( e );
1433 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1434 if ( cde.getNumberOfProteinDomains() != 3 ) {
1437 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1440 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1441 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1442 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1443 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1444 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1445 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1446 fghi.addProteinDomain( f );
1447 fghi.addProteinDomain( g );
1448 fghi.addProteinDomain( h );
1449 fghi.addProteinDomain( i );
1450 fghi.addProteinDomain( i );
1451 fghi.addProteinDomain( i );
1452 fghi.addProteinDomain( i2 );
1453 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1454 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1457 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1460 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1463 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1464 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1467 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1470 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1471 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1472 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1473 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1474 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1475 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1476 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1477 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1478 jklm.addProteinDomain( j );
1479 jklm.addProteinDomain( k );
1480 jklm.addProteinDomain( l );
1481 jklm.addProteinDomain( m );
1482 jklm.addProteinDomain( m0 );
1483 jklm.addProteinDomain( m1 );
1484 jklm.addProteinDomain( m2 );
1485 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1486 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1489 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1492 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1495 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1496 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1499 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1502 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1503 final Protein od = new BasicProtein( "od", "varanus", 0 );
1504 od.addProteinDomain( only );
1505 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1506 if ( od.getNumberOfProteinDomains() != 1 ) {
1509 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1513 catch ( final Exception e ) {
1514 e.printStackTrace( System.out );
1520 private static final boolean testPfamTreeReading() {
1522 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1523 final NHXParser parser = new NHXParser();
1524 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1525 parser.setReplaceUnderscores( false );
1526 parser.setGuessRootedness( true );
1527 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1528 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1531 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1535 catch ( final Exception e ) {
1536 e.printStackTrace();
1542 private static final boolean testPhyloXMLparsingFromURL() {
1544 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1545 final URL u = new URL( s );
1546 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1547 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1550 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1551 if ( ( phys2 == null ) || ( phys2.length != 2 ) ) {
1555 catch ( final Exception e ) {
1556 e.printStackTrace();
1562 private static final boolean testToLReading() {
1564 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1565 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, new TolParser() );
1566 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1569 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1572 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName()
1573 .equals( "Protacanthopterygii" ) ) {
1576 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1580 final URL u2 = new URL( WebserviceUtil.TOL_URL_BASE + "17706" );
1581 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, new TolParser() );
1582 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
1585 if ( !phys2[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "17706" ) ) {
1588 if ( phys2[ 0 ].getNumberOfExternalNodes() < 5 ) {
1592 catch ( final Exception e ) {
1593 e.printStackTrace();
1599 private static final boolean testTreeBaseReading() {
1601 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "72557?format=nexus" );
1602 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1603 parser.setReplaceUnderscores( true );
1604 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1605 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1608 final URL u_1 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2406?format=nexus" );
1609 final NexusPhylogeniesParser parser_1 = new NexusPhylogeniesParser();
1610 final Phylogeny[] phys_1 = ForesterUtil.readPhylogeniesFromUrl( u_1, parser_1 );
1611 if ( ( phys_1 == null ) || ( phys_1.length != 1 ) ) {
1614 final URL u_2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "422?format=nexus" );
1615 final NexusPhylogeniesParser parser_2 = new NexusPhylogeniesParser();
1616 final Phylogeny[] phys_2 = ForesterUtil.readPhylogeniesFromUrl( u_2, parser_2 );
1617 if ( ( phys_2 == null ) || ( phys_2.length != 1 ) ) {
1620 final URL u_3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2654?format=nexus" );
1621 final NexusPhylogeniesParser parser_3 = new NexusPhylogeniesParser();
1622 final Phylogeny[] phys_3 = ForesterUtil.readPhylogeniesFromUrl( u_3, parser_3 );
1623 if ( ( phys_3 == null ) || ( phys_3.length != 1 ) ) {
1626 final URL u_4 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1627 final NexusPhylogeniesParser parser_4 = new NexusPhylogeniesParser();
1628 final Phylogeny[] phys_4 = ForesterUtil.readPhylogeniesFromUrl( u_4, parser_4 );
1629 if ( ( phys_4 == null ) || ( phys_4.length != 1 ) ) {
1632 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1633 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1634 parser2.setReplaceUnderscores( true );
1635 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, parser2 );
1636 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1639 final URL u3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14909?format=nexus" );
1640 final NexusPhylogeniesParser parser3 = new NexusPhylogeniesParser();
1641 final Phylogeny[] phys3 = ForesterUtil.readPhylogeniesFromUrl( u3, parser3 );
1642 if ( ( phys3 == null ) || ( phys3.length != 2 ) ) {
1645 final Phylogeny[] phys4 = ForesterUtil.readPhylogeniesFromUrl(
1646 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1647 + "14525?format=nexus" ),
1648 new NexusPhylogeniesParser() );
1649 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1652 final Phylogeny[] phys5 = ForesterUtil.readPhylogeniesFromUrl(
1653 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1654 + "15632?format=nexus" ),
1655 new NexusPhylogeniesParser() );
1656 if ( ( phys5 == null ) || ( phys5.length != 1 ) ) {
1659 final Phylogeny[] phys6 = ForesterUtil.readPhylogeniesFromUrl(
1660 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1661 + "10190?format=nexus" ),
1662 new NexusPhylogeniesParser() );
1663 if ( ( phys6 == null ) || ( phys6.length != 1 ) ) {
1666 final Phylogeny[] phys7 = ForesterUtil.readPhylogeniesFromUrl(
1667 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1668 + "13246?format=nexus" ),
1669 new NexusPhylogeniesParser() );
1670 if ( ( phys7 == null ) || ( phys7.length != 2 ) ) {
1673 final Phylogeny[] phys8 = ForesterUtil.readPhylogeniesFromUrl(
1674 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1675 + "11662?format=nexus" ),
1676 new NexusPhylogeniesParser() );
1677 if ( ( phys8 == null ) || ( phys8.length != 2 ) ) {
1680 final Phylogeny[] phys9 = ForesterUtil.readPhylogeniesFromUrl(
1681 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1682 + "562?format=nexus" ),
1683 new NexusPhylogeniesParser() );
1684 if ( ( phys9 == null ) || ( phys9.length != 4 ) ) {
1687 final Phylogeny[] phys16424 = ForesterUtil.readPhylogeniesFromUrl(
1688 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1689 + "16424?format=nexus" ),
1690 new NexusPhylogeniesParser() );
1691 if ( ( phys16424 == null ) || ( phys16424.length != 1 ) ) {
1694 final Phylogeny[] phys17878 = ForesterUtil.readPhylogeniesFromUrl(
1695 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1696 + "17878?format=nexus" ),
1697 new NexusPhylogeniesParser() );
1698 if ( ( phys17878 == null ) || ( phys17878.length != 17 ) ) {
1701 final Phylogeny[] phys18804 = ForesterUtil.readPhylogeniesFromUrl(
1702 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1703 + "18804?format=nexus" ),
1704 new NexusPhylogeniesParser() );
1705 if ( ( phys18804 == null ) || ( phys18804.length != 2 ) ) {
1708 final Phylogeny[] phys346 = ForesterUtil.readPhylogeniesFromUrl(
1709 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1710 + "346?format=nexus" ),
1711 new NexusPhylogeniesParser() );
1712 if ( ( phys346 == null ) || ( phys346.length != 1 ) ) {
1716 catch ( final Exception e ) {
1717 e.printStackTrace();
1723 private static final boolean testTreeFamReading() {
1725 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1726 final NHXParser parser = new NHXParser();
1727 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1728 parser.setReplaceUnderscores( false );
1729 parser.setGuessRootedness( true );
1730 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1731 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1734 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1738 catch ( final Exception e ) {
1739 e.printStackTrace();
1745 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1746 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1750 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1751 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1754 private static boolean testAminoAcidSequence() {
1756 final MolecularSequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1757 if ( aa1.getLength() != 13 ) {
1760 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1763 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1766 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1769 final MolecularSequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1770 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZOXU" ) ) {
1773 final MolecularSequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1774 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1777 final MolecularSequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1778 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1782 catch ( final Exception e ) {
1783 e.printStackTrace();
1789 private static boolean testBasicDomain() {
1791 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1792 if ( !pd.getDomainId().equals( "id" ) ) {
1795 if ( pd.getNumber() != 1 ) {
1798 if ( pd.getTotalCount() != 4 ) {
1801 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1804 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1805 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1806 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1807 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1808 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1809 if ( !a1.equals( a1 ) ) {
1812 if ( !a1.equals( a1_copy ) ) {
1815 if ( !a1.equals( a1_equal ) ) {
1818 if ( !a1.equals( a2 ) ) {
1821 if ( a1.equals( a3 ) ) {
1824 if ( a1.compareTo( a1 ) != 0 ) {
1827 if ( a1.compareTo( a1_copy ) != 0 ) {
1830 if ( a1.compareTo( a1_equal ) != 0 ) {
1833 if ( a1.compareTo( a2 ) != 0 ) {
1836 if ( a1.compareTo( a3 ) == 0 ) {
1840 catch ( final Exception e ) {
1841 e.printStackTrace( System.out );
1847 private static boolean testBasicNodeMethods() {
1849 if ( PhylogenyNode.getNodeCount() != 0 ) {
1852 final PhylogenyNode n1 = new PhylogenyNode();
1853 final PhylogenyNode n2 = PhylogenyNode
1854 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1855 final PhylogenyNode n3 = PhylogenyNode
1856 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1857 final PhylogenyNode n4 = PhylogenyNode
1858 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1859 if ( n1.isHasAssignedEvent() ) {
1862 if ( PhylogenyNode.getNodeCount() != 4 ) {
1865 if ( n3.getIndicator() != 0 ) {
1868 if ( n3.getNumberOfExternalNodes() != 1 ) {
1871 if ( !n3.isExternal() ) {
1874 if ( !n3.isRoot() ) {
1877 if ( !n4.getName().equals( "n4" ) ) {
1881 catch ( final Exception e ) {
1882 e.printStackTrace( System.out );
1889 private static boolean testCommonPrefix() {
1890 final List<String> l0 = new ArrayList<String>();
1892 if ( !ForesterUtil.greatestCommonPrefix( l0 ).equals( "abc" ) ) {
1896 final List<String> l1 = new ArrayList<String>();
1899 if ( !ForesterUtil.greatestCommonPrefix( l1 ).equals( "ab" ) ) {
1903 final List<String> l2 = new ArrayList<String>();
1907 if ( !ForesterUtil.greatestCommonPrefix( l2 ).equals( "a" ) ) {
1911 final List<String> l3 = new ArrayList<String>();
1912 l3.add( "abXsdfsdfsdfsdfsdfsd" );
1913 l3.add( "abXsdfsdfsdfsdfsdfsd" );
1915 l3.add( "abXsdfsdfsdfsdfsdfsd" );
1919 if ( !ForesterUtil.greatestCommonPrefix( l3 ).equals( "ab" ) ) {
1923 final List<String> l4 = new ArrayList<String>();
1924 l4.add( "abXsdfsdfsdfsdfsdfsd" );
1925 l4.add( "abXsdfsdfsdfsdfsdfsd" );
1927 l4.add( "Xsdfsdfsdfsdfsdfsd" );
1930 if ( !ForesterUtil.greatestCommonPrefix( l4 ).equals( "" ) ) {
1934 final List<String> l5 = new ArrayList<String>();
1936 if ( !ForesterUtil.greatestCommonPrefix( l5 ).equals( "" ) ) {
1940 final List<String> l6 = new ArrayList<String>();
1944 if ( !ForesterUtil.greatestCommonPrefix( l6 ).equals( "" ) ) {
1950 private static boolean testCommonPrefixSep() {
1951 final List<String> l0 = new ArrayList<String>();
1953 if ( !ForesterUtil.greatestCommonPrefix( l0, ".").equals( "a.b.c" ) ) {
1957 final List<String> l1 = new ArrayList<String>();
1960 if ( !ForesterUtil.greatestCommonPrefix( l1 , ".").equals( "a.b" ) ) {
1964 final List<String> l2 = new ArrayList<String>();
1968 if ( !ForesterUtil.greatestCommonPrefix( l2, ".").equals( "a" ) ) {
1972 final List<String> l3 = new ArrayList<String>();
1973 l3.add( "a/b/X/s/d/f/s/d/f/s/d/f/s/d/f/s/d/f/s/d/" );
1974 l3.add( "a/b/X/s/d/f/s/d/f/s/d/f/s/d/f/s/d/f/s/d" );
1976 l3.add( "a/b/X/s/d/f/s/d/f/s/d/f/s/d/f/s/d/f/s/d/" );
1979 l3.add( "a/b////////" );
1980 if ( !ForesterUtil.greatestCommonPrefix( l3, "/" ).equals( "a/b" ) ) {
1984 final List<String> l4 = new ArrayList<String>();
1985 l4.add( "a.b.X.s.d.f.s.d.f.s.d.f.s.d.f.s.d.f.s.d" );
1986 l4.add( "a.b.X.s.d.f.s.d.f.s.d.f.s.d.f.s.d.f.s.d" );
1988 l4.add( "X.s.d.f.s.d.f.s.d.f.s.d.f.s.d.f.s.d..." );
1991 if ( !ForesterUtil.greatestCommonPrefix( l4, "." ).equals( "" ) ) {
1995 final List<String> l5 = new ArrayList<String>();
1997 if ( !ForesterUtil.greatestCommonPrefix( l5, "_" ).equals( "" ) ) {
2001 final List<String> l6 = new ArrayList<String>();
2004 if ( !ForesterUtil.greatestCommonPrefix( l6, "_" ).equals( "" ) ) {
2008 final List<String> l7 = new ArrayList<String>();
2012 l7.add( ",,,,,,,,,," );
2013 if ( !ForesterUtil.greatestCommonPrefix( l7, "," ).equals( "" ) ) {
2017 final List<String> l8 = new ArrayList<String>();
2018 l8.add( "123.304.403.04" );
2019 l8.add( "123.304.403.04.02" );
2020 l8.add( "123.304.403.03.03" );
2021 if ( !ForesterUtil.greatestCommonPrefix( l8, "." ).equals( "123.304.403" ) ) {
2025 final List<String> l9 = new ArrayList<String>();
2026 l9.add( "123.304.403.04" );
2027 l9.add( "123.304.403.04.02" );
2028 l9.add( "123.304.402.03.03" );
2029 if ( !ForesterUtil.greatestCommonPrefix( l9, "." ).equals( "123.304" ) ) {
2036 private static boolean testUTF8ParsingFromFile() {
2038 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2039 final Phylogeny[] phylogenies_xml = ParserBasedPhylogenyFactory.getInstance()
2040 .create( new File( Test.PATH_TO_TEST_DATA + "chars.xml" ), xml_parser );
2041 if ( xml_parser.getErrorCount() > 0 ) {
2042 System.out.println( xml_parser.getErrorMessages().toString() );
2045 if ( phylogenies_xml.length != 1 ) {
2048 final Phylogeny[] phylogenies_xml2 = ParserBasedPhylogenyFactory.getInstance()
2049 .create( new StringBuffer( phylogenies_xml[ 0 ].toPhyloXML( 0 ) ), xml_parser );
2050 final Phylogeny[] phylogenies_nh = ParserBasedPhylogenyFactory.getInstance()
2051 .create( new File( Test.PATH_TO_TEST_DATA + "chars.nh" ), new NHXParser() );
2052 if ( phylogenies_nh.length != 1 ) {
2055 final Phylogeny[] phylogenies_nex = ParserBasedPhylogenyFactory.getInstance()
2056 .create( new File( Test.PATH_TO_TEST_DATA + "chars.nex" ), new NexusPhylogeniesParser() );
2057 if ( phylogenies_nex.length != 1 ) {
2060 final String[] xml_n = phylogenies_xml[ 0 ].getAllExternalNodeNames();
2061 final String[] xml_n2 = phylogenies_xml2[ 0 ].getAllExternalNodeNames();
2062 final String[] nh_n = phylogenies_nh[ 0 ].getAllExternalNodeNames();
2063 final String[] nex_n = phylogenies_nex[ 0 ].getAllExternalNodeNames();
2064 final String n0 = "AQ~!@#$%^&*()_+-=\\{}|;:\"<>?,./";
2065 final String n1 = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ";
2066 final String n2 = "漢字ひらがなカタカナ";
2067 final String n3 = "อักษรไทย";
2068 final String n4 = "繁體字";
2069 final String n5 = "한글";
2070 final String n6 = "देवनागरी";
2071 final String n7 = "chữ Quốc ngữ";
2072 final String n8 = "ру́сский язы́к";
2073 final String n9 = "អក្សរខ្មែរ";
2074 if ( !xml_n[ 0 ].equals( n0 ) ) {
2075 System.out.println( xml_n[ 0 ] );
2076 System.out.println( n0 );
2079 if ( !xml_n2[ 0 ].equals( n0 ) ) {
2080 System.out.println( xml_n2[ 0 ] );
2081 System.out.println( n0 );
2084 if ( !nh_n[ 0 ].equals( n0 ) ) {
2085 System.out.println( nh_n[ 0 ] );
2086 System.out.println( n0 );
2089 if ( !nex_n[ 0 ].equals( n0 ) ) {
2090 System.out.println( nex_n[ 0 ] );
2091 System.out.println( n0 );
2094 if ( !xml_n[ 1 ].equals( n1 ) ) {
2095 System.out.println( xml_n[ 1 ] );
2096 System.out.println( n1 );
2099 if ( !xml_n2[ 1 ].equals( n1 ) ) {
2100 System.out.println( xml_n2[ 1 ] );
2101 System.out.println( n1 );
2104 if ( !nh_n[ 1 ].equals( n1 ) ) {
2105 System.out.println( nh_n[ 1 ] );
2106 System.out.println( n1 );
2109 if ( !nex_n[ 1 ].equals( n1 ) ) {
2110 System.out.println( nex_n[ 1 ] );
2111 System.out.println( n1 );
2114 if ( !xml_n[ 2 ].equals( n2 ) ) {
2115 System.out.println( xml_n[ 2 ] );
2116 System.out.println( n2 );
2119 if ( !xml_n2[ 2 ].equals( n2 ) ) {
2120 System.out.println( xml_n2[ 2 ] );
2121 System.out.println( n2 );
2124 if ( !nh_n[ 2 ].equals( n2 ) ) {
2125 System.out.println( nh_n[ 2 ] );
2126 System.out.println( n2 );
2129 if ( !nex_n[ 2 ].equals( n2 ) ) {
2130 System.out.println( nex_n[ 2 ] );
2131 System.out.println( n2 );
2135 if ( !xml_n[ 3 ].equals( n3 ) ) {
2136 System.out.println( xml_n[ 3 ] );
2137 System.out.println( n3 );
2140 if ( !xml_n2[ 3 ].equals( n3 ) ) {
2141 System.out.println( xml_n2[ 3 ] );
2142 System.out.println( n3 );
2145 if ( !nh_n[ 3 ].equals( n3 ) ) {
2146 System.out.println( nh_n[ 3 ] );
2147 System.out.println( n3 );
2150 if ( !nex_n[ 3 ].equals( n3 ) ) {
2151 System.out.println( nex_n[ 3 ] );
2152 System.out.println( n3 );
2156 if ( !xml_n[ 4 ].equals( n4 ) ) {
2157 System.out.println( xml_n[ 4 ] );
2158 System.out.println( n4 );
2161 if ( !nh_n[ 4 ].equals( n4 ) ) {
2162 System.out.println( nh_n[ 4 ] );
2163 System.out.println( n4 );
2166 if ( !nex_n[ 4 ].equals( n4 ) ) {
2167 System.out.println( nex_n[ 4 ] );
2168 System.out.println( n4 );
2172 if ( !xml_n[ 5 ].equals( n5 ) ) {
2173 System.out.println( xml_n[ 5 ] );
2174 System.out.println( n5 );
2177 if ( !nh_n[ 5 ].equals( n5 ) ) {
2178 System.out.println( nh_n[ 5 ] );
2179 System.out.println( n5 );
2182 if ( !nex_n[ 5 ].equals( n5 ) ) {
2183 System.out.println( nex_n[ 5 ] );
2184 System.out.println( n5 );
2188 if ( !xml_n[ 6 ].equals( n6 ) ) {
2189 System.out.println( xml_n[ 6 ] );
2190 System.out.println( n6 );
2193 if ( !nh_n[ 6 ].equals( n6 ) ) {
2194 System.out.println( nh_n[ 6 ] );
2195 System.out.println( n6 );
2198 if ( !nex_n[ 6 ].equals( n6 ) ) {
2199 System.out.println( nex_n[ 6 ] );
2200 System.out.println( n6 );
2204 if ( !xml_n[ 7 ].equals( n7 ) ) {
2205 System.out.println( xml_n[ 7 ] );
2206 System.out.println( n7 );
2209 if ( !nh_n[ 7 ].equals( n7 ) ) {
2210 System.out.println( nh_n[ 7 ] );
2211 System.out.println( n7 );
2214 if ( !nex_n[ 7 ].equals( n7 ) ) {
2215 System.out.println( nex_n[ 7 ] );
2216 System.out.println( n7 );
2219 if ( !xml_n[ 8 ].equals( n8 ) ) {
2220 System.out.println( xml_n[ 8 ] );
2221 System.out.println( n8 );
2224 if ( !nh_n[ 8 ].equals( n8 ) ) {
2225 System.out.println( nh_n[ 8 ] );
2226 System.out.println( n8 );
2229 if ( !nex_n[ 8 ].equals( n8 ) ) {
2230 System.out.println( nex_n[ 8 ] );
2231 System.out.println( n8 );
2234 if ( !xml_n[ 9 ].equals( n9 ) ) {
2235 System.out.println( xml_n[ 9 ] );
2236 System.out.println( n9 );
2239 if ( !xml_n2[ 9 ].equals( n9 ) ) {
2240 System.out.println( xml_n2[ 9 ] );
2241 System.out.println( n9 );
2244 if ( !nh_n[ 9 ].equals( n9 ) ) {
2245 System.out.println( nh_n[ 9 ] );
2246 System.out.println( n9 );
2249 if ( !nex_n[ 9 ].equals( n9 ) ) {
2250 System.out.println( nex_n[ 9 ] );
2251 System.out.println( n9 );
2254 if ( !phylogenies_xml[ 0 ].toNewHampshire().equals( phylogenies_nh[ 0 ].toNewHampshire() ) ) {
2255 System.out.println( phylogenies_xml[ 0 ].toNewHampshire() );
2256 System.out.println( phylogenies_nh[ 0 ].toNewHampshire() );
2259 if ( !phylogenies_xml[ 0 ].toNewHampshire().equals( phylogenies_nex[ 0 ].toNewHampshire() ) ) {
2260 System.out.println( phylogenies_xml[ 0 ].toNewHampshire() );
2261 System.out.println( phylogenies_nex[ 0 ].toNewHampshire() );
2265 catch ( final Exception e ) {
2266 e.printStackTrace( System.out );
2272 private static boolean testBasicPhyloXMLparsing() {
2274 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2275 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2276 final Phylogeny[] phylogenies_0 = factory
2277 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2278 if ( xml_parser.getErrorCount() > 0 ) {
2279 System.out.println( xml_parser.getErrorMessages().toString() );
2282 if ( phylogenies_0.length != 4 ) {
2285 final Phylogeny t1 = phylogenies_0[ 0 ];
2286 final Phylogeny t2 = phylogenies_0[ 1 ];
2287 final Phylogeny t3 = phylogenies_0[ 2 ];
2288 final Phylogeny t4 = phylogenies_0[ 3 ];
2289 if ( t1.getNumberOfExternalNodes() != 1 ) {
2292 if ( !t1.isRooted() ) {
2295 if ( t1.isRerootable() ) {
2298 if ( !t1.getType().equals( "gene_tree" ) ) {
2301 if ( t2.getNumberOfExternalNodes() != 2 ) {
2304 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
2307 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
2310 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2313 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2316 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2319 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2322 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2323 .startsWith( "actgtgggggt" ) ) {
2326 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2327 .startsWith( "ctgtgatgcat" ) ) {
2330 if ( t3.getNumberOfExternalNodes() != 4 ) {
2333 if ( !t1.getName().equals( "t1" ) ) {
2336 if ( !t2.getName().equals( "t2" ) ) {
2339 if ( !t3.getName().equals( "t3" ) ) {
2342 if ( !t4.getName().equals( "t4" ) ) {
2345 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
2348 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
2351 if ( !t3.getNode( "root node" ).isDuplication() ) {
2354 if ( !t3.getNode( "node a" ).isDuplication() ) {
2357 if ( t3.getNode( "node a" ).isSpeciation() ) {
2360 if ( t3.getNode( "node bc" ).isDuplication() ) {
2363 if ( !t3.getNode( "node bc" ).isSpeciation() ) {
2366 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2369 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
2370 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2373 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2376 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2379 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2380 .equals( "UniProtKB" ) ) {
2383 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2384 .equals( "apoptosis" ) ) {
2387 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2388 .equals( "GO:0006915" ) ) {
2391 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2392 .equals( "UniProtKB" ) ) {
2395 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2396 .equals( "experimental" ) ) {
2399 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2400 .equals( "function" ) ) {
2403 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2404 .getValue() != 1 ) {
2407 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence().getType()
2411 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2412 .equals( "apoptosis" ) ) {
2415 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2416 .getProperties( "AFFY:expression" ).get( 0 ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2419 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2420 .getProperties( "AFFY:expression" ).get( 0 ).getDataType().equals( "xsd:double" ) ) {
2423 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2424 .getProperties( "AFFY:expression" ).get( 0 ).getRef().equals( "AFFY:expression" ) ) {
2427 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2428 .getProperties( "AFFY:expression" ).get( 0 ).getUnit().equals( "AFFY:x" ) ) {
2431 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2432 .getProperties( "AFFY:expression" ).get( 0 ).getValue().equals( "0.2" ) ) {
2435 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2436 .getProperties( "MED:disease" ).get( 0 ).getValue().equals( "lymphoma" ) ) {
2439 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2440 .equals( "GO:0005829" ) ) {
2443 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2444 .equals( "intracellular organelle" ) ) {
2447 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2450 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2451 .equals( "UniProt link" ) ) ) {
2454 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2457 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
2458 if ( x.size() != 4 ) {
2462 for( final Accession acc : x ) {
2464 if ( !acc.getSource().equals( "KEGG" ) ) {
2467 if ( !acc.getValue().equals( "hsa:596" ) ) {
2474 catch ( final Exception e ) {
2475 e.printStackTrace( System.out );
2481 private static boolean testBasicPhyloXMLparsingRoundtrip() {
2483 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2484 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2485 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2486 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2489 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2491 final Phylogeny[] phylogenies_0 = factory
2492 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2493 if ( xml_parser.getErrorCount() > 0 ) {
2494 System.out.println( xml_parser.getErrorMessages().toString() );
2497 if ( phylogenies_0.length != 4 ) {
2500 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
2501 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
2502 if ( phylogenies_t1.length != 1 ) {
2505 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
2506 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
2509 if ( !t1_rt.isRooted() ) {
2512 if ( t1_rt.isRerootable() ) {
2515 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
2518 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
2519 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
2520 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
2521 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2524 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2527 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2530 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2533 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2534 .startsWith( "actgtgggggt" ) ) {
2537 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2538 .startsWith( "ctgtgatgcat" ) ) {
2541 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
2542 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
2543 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
2544 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
2545 if ( phylogenies_1.length != 1 ) {
2548 final Phylogeny t3_rt = phylogenies_1[ 0 ];
2549 if ( !t3_rt.getName().equals( "t3" ) ) {
2552 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
2555 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
2558 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
2561 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2564 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
2565 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2568 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2571 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue()
2572 .equals( "Q9BZR8" ) ) {
2575 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2576 .equals( "UniProtKB" ) ) {
2579 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2580 .equals( "apoptosis" ) ) {
2583 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2584 .equals( "GO:0006915" ) ) {
2587 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2588 .equals( "UniProtKB" ) ) {
2591 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2592 .equals( "experimental" ) ) {
2595 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2596 .equals( "function" ) ) {
2599 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2600 .getValue() != 1 ) {
2603 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2604 .getType().equals( "ml" ) ) {
2607 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2608 .equals( "apoptosis" ) ) {
2611 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2612 .getProperties( "AFFY:expression" ).get( 0 ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2615 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2616 .getProperties( "AFFY:expression" ).get( 0 ).getDataType().equals( "xsd:double" ) ) {
2619 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2620 .getProperties( "AFFY:expression" ).get( 0 ).getRef().equals( "AFFY:expression" ) ) {
2623 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2624 .getProperties( "AFFY:expression" ).get( 0 ).getUnit().equals( "AFFY:x" ) ) {
2627 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2628 .getProperties( "AFFY:expression" ).get( 0 ).getValue().equals( "0.2" ) ) {
2631 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2632 .getProperties( "MED:disease" ).get( 0 ).getValue().equals( "lymphoma" ) ) {
2635 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2636 .equals( "GO:0005829" ) ) {
2639 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2640 .equals( "intracellular organelle" ) ) {
2643 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType()
2644 .equals( "source" ) ) ) {
2647 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2648 .equals( "UniProt link" ) ) ) {
2651 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2654 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi()
2655 .equals( "10.1038/387489a0" ) ) ) {
2658 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
2659 .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." ) ) ) {
2660 System.out.println( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription() );
2663 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
2666 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
2669 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName()
2670 .equals( "molting animals" ) ) {
2673 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
2676 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
2677 .equals( "ncbi" ) ) {
2680 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture()
2681 .getTotalLength() != 124 ) {
2684 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2685 .getName().equals( "B" ) ) {
2688 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2689 .getFrom() != 21 ) {
2692 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2696 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2697 .getLength() != 24 ) {
2700 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2701 .getConfidence() != 0 ) {
2704 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2705 .equals( "pfam" ) ) {
2708 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2711 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2714 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2717 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2720 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2721 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2724 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2727 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2730 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2733 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2736 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2739 if ( taxbb.getSynonyms().size() != 2 ) {
2742 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2745 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2748 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2751 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2754 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2757 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2758 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2761 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2764 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2767 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2770 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2773 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2776 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2779 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2782 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2785 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2786 .equalsIgnoreCase( "435" ) ) {
2789 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString()
2790 .equalsIgnoreCase( "416" ) ) {
2793 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2794 .equalsIgnoreCase( "443.7" ) ) {
2797 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2800 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2803 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2804 .equalsIgnoreCase( "433" ) ) {
2807 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2808 .getCrossReferences();
2809 if ( x.size() != 4 ) {
2813 for( final Accession acc : x ) {
2815 if ( !acc.getSource().equals( "KEGG" ) ) {
2818 if ( !acc.getValue().equals( "hsa:596" ) ) {
2825 catch ( final Exception e ) {
2826 e.printStackTrace( System.out );
2832 private static boolean testBasicPhyloXMLparsingValidating() {
2834 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2835 PhyloXmlParser xml_parser = null;
2837 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2839 catch ( final Exception e ) {
2840 // Do nothing -- means were not running from jar.
2842 if ( xml_parser == null ) {
2843 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2844 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2845 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2848 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2851 final Phylogeny[] phylogenies_0 = factory
2852 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2853 if ( xml_parser.getErrorCount() > 0 ) {
2854 System.out.println( xml_parser.getErrorMessages().toString() );
2857 if ( phylogenies_0.length != 4 ) {
2860 final Phylogeny t1 = phylogenies_0[ 0 ];
2861 final Phylogeny t2 = phylogenies_0[ 1 ];
2862 final Phylogeny t3 = phylogenies_0[ 2 ];
2863 final Phylogeny t4 = phylogenies_0[ 3 ];
2864 if ( !t1.getName().equals( "t1" ) ) {
2867 if ( !t2.getName().equals( "t2" ) ) {
2870 if ( !t3.getName().equals( "t3" ) ) {
2873 if ( !t4.getName().equals( "t4" ) ) {
2876 if ( t1.getNumberOfExternalNodes() != 1 ) {
2879 if ( t2.getNumberOfExternalNodes() != 2 ) {
2882 if ( t3.getNumberOfExternalNodes() != 4 ) {
2885 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2886 final Phylogeny[] phylogenies_1 = factory.create( new File( x2 ), xml_parser );
2887 if ( xml_parser.getErrorCount() > 0 ) {
2888 System.out.println( "errors:" );
2889 System.out.println( xml_parser.getErrorMessages().toString() );
2892 if ( phylogenies_1.length != 4 ) {
2895 final Phylogeny[] phylogenies_2 = factory
2896 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml" ), xml_parser );
2897 if ( xml_parser.getErrorCount() > 0 ) {
2898 System.out.println( "errors:" );
2899 System.out.println( xml_parser.getErrorMessages().toString() );
2902 if ( phylogenies_2.length != 1 ) {
2905 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2908 final Phylogeny[] phylogenies_3 = factory
2909 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml" ), xml_parser );
2910 if ( xml_parser.getErrorCount() > 0 ) {
2911 System.out.println( xml_parser.getErrorMessages().toString() );
2914 if ( phylogenies_3.length != 2 ) {
2917 final Phylogeny a = phylogenies_3[ 0 ];
2918 if ( !a.getName().equals( "tree 4" ) ) {
2921 if ( a.getNumberOfExternalNodes() != 3 ) {
2924 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2927 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2930 final Phylogeny[] phylogenies_4 = factory
2931 .create( new File( Test.PATH_TO_TEST_DATA + "special_characters.xml" ), xml_parser );
2932 if ( xml_parser.getErrorCount() > 0 ) {
2933 System.out.println( xml_parser.getErrorMessages().toString() );
2936 if ( phylogenies_4.length != 1 ) {
2939 final Phylogeny s = phylogenies_4[ 0 ];
2940 if ( s.getNumberOfExternalNodes() != 6 ) {
2943 s.getNode( "first" );
2945 s.getNode( "\"<a'b&c'd\">\"" );
2946 s.getNode( "'''\"" );
2947 s.getNode( "\"\"\"" );
2948 s.getNode( "dick & doof" );
2950 catch ( final Exception e ) {
2951 e.printStackTrace( System.out );
2957 private static boolean testPhyloXMLparsingValidating() {
2959 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2960 PhyloXmlParser xml_parser = null;
2962 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2964 catch ( final Exception e ) {
2965 // Do nothing -- means were not running from jar.
2967 if ( xml_parser == null ) {
2968 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2969 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2970 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2973 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2976 final Phylogeny[] phylogenies_0 = factory
2977 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_1.xml" ), xml_parser );
2978 if ( xml_parser.getErrorCount() > 0 ) {
2979 System.out.println( xml_parser.getErrorMessages().toString() );
2982 if ( phylogenies_0.length != 3 ) {
2986 catch ( final Exception e ) {
2987 e.printStackTrace( System.out );
2993 private static boolean testBasicProtein() {
2995 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2996 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2997 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2998 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2999 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
3000 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
3001 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
3002 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
3003 p0.addProteinDomain( y );
3004 p0.addProteinDomain( e );
3005 p0.addProteinDomain( b );
3006 p0.addProteinDomain( c );
3007 p0.addProteinDomain( d );
3008 p0.addProteinDomain( a );
3009 p0.addProteinDomain( x );
3010 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
3013 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
3017 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
3018 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
3019 aa0.addProteinDomain( a1 );
3020 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
3023 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
3027 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
3028 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
3029 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
3030 aa1.addProteinDomain( a11 );
3031 aa1.addProteinDomain( a12 );
3032 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
3035 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
3038 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
3039 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
3042 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
3045 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
3048 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
3049 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
3052 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
3055 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
3058 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
3061 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
3062 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
3065 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
3068 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
3071 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
3074 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
3075 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
3078 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
3081 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
3084 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
3088 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
3089 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
3090 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
3091 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
3092 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
3093 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
3094 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
3095 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
3096 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
3097 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
3098 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
3099 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
3100 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
3101 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
3102 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
3103 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
3104 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
3105 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
3106 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
3107 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
3108 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
3109 p00.addProteinDomain( y0 );
3110 p00.addProteinDomain( e0 );
3111 p00.addProteinDomain( b0 );
3112 p00.addProteinDomain( c0 );
3113 p00.addProteinDomain( d0 );
3114 p00.addProteinDomain( a0 );
3115 p00.addProteinDomain( x0 );
3116 p00.addProteinDomain( y1 );
3117 p00.addProteinDomain( y2 );
3118 p00.addProteinDomain( y3 );
3119 p00.addProteinDomain( e1 );
3120 p00.addProteinDomain( e2 );
3121 p00.addProteinDomain( e3 );
3122 p00.addProteinDomain( e4 );
3123 p00.addProteinDomain( e5 );
3124 p00.addProteinDomain( z0 );
3125 p00.addProteinDomain( z1 );
3126 p00.addProteinDomain( z2 );
3127 p00.addProteinDomain( zz0 );
3128 p00.addProteinDomain( zz1 );
3129 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
3132 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
3135 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
3138 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
3141 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" ) ) {
3144 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
3145 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3146 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
3147 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
3148 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
3149 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
3150 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
3151 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
3152 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
3153 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
3154 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
3155 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
3156 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
3157 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
3158 p.addProteinDomain( B15 );
3159 p.addProteinDomain( C50 );
3160 p.addProteinDomain( A60 );
3161 p.addProteinDomain( A30 );
3162 p.addProteinDomain( C70 );
3163 p.addProteinDomain( B35 );
3164 p.addProteinDomain( B40 );
3165 p.addProteinDomain( A0 );
3166 p.addProteinDomain( A10 );
3167 p.addProteinDomain( A20 );
3168 p.addProteinDomain( B25 );
3169 p.addProteinDomain( D80 );
3170 List<String> domains_ids = new ArrayList<String>();
3171 domains_ids.add( "A" );
3172 domains_ids.add( "B" );
3173 domains_ids.add( "C" );
3174 if ( !p.contains( domains_ids, false ) ) {
3177 if ( !p.contains( domains_ids, true ) ) {
3180 domains_ids.add( "X" );
3181 if ( p.contains( domains_ids, false ) ) {
3184 if ( p.contains( domains_ids, true ) ) {
3187 domains_ids = new ArrayList<String>();
3188 domains_ids.add( "A" );
3189 domains_ids.add( "C" );
3190 domains_ids.add( "D" );
3191 if ( !p.contains( domains_ids, false ) ) {
3194 if ( !p.contains( domains_ids, true ) ) {
3197 domains_ids = new ArrayList<String>();
3198 domains_ids.add( "A" );
3199 domains_ids.add( "D" );
3200 domains_ids.add( "C" );
3201 if ( !p.contains( domains_ids, false ) ) {
3204 if ( p.contains( domains_ids, true ) ) {
3207 domains_ids = new ArrayList<String>();
3208 domains_ids.add( "A" );
3209 domains_ids.add( "A" );
3210 domains_ids.add( "B" );
3211 if ( !p.contains( domains_ids, false ) ) {
3214 if ( !p.contains( domains_ids, true ) ) {
3217 domains_ids = new ArrayList<String>();
3218 domains_ids.add( "A" );
3219 domains_ids.add( "A" );
3220 domains_ids.add( "A" );
3221 domains_ids.add( "B" );
3222 domains_ids.add( "B" );
3223 if ( !p.contains( domains_ids, false ) ) {
3226 if ( !p.contains( domains_ids, true ) ) {
3229 domains_ids = new ArrayList<String>();
3230 domains_ids.add( "A" );
3231 domains_ids.add( "A" );
3232 domains_ids.add( "B" );
3233 domains_ids.add( "A" );
3234 domains_ids.add( "B" );
3235 domains_ids.add( "B" );
3236 domains_ids.add( "A" );
3237 domains_ids.add( "B" );
3238 domains_ids.add( "C" );
3239 domains_ids.add( "A" );
3240 domains_ids.add( "C" );
3241 domains_ids.add( "D" );
3242 if ( !p.contains( domains_ids, false ) ) {
3245 if ( p.contains( domains_ids, true ) ) {
3249 catch ( final Exception e ) {
3250 e.printStackTrace( System.out );
3256 private static boolean testBasicTable() {
3258 final BasicTable<String> t0 = new BasicTable<String>();
3259 if ( t0.getNumberOfColumns() != 0 ) {
3262 if ( t0.getNumberOfRows() != 0 ) {
3265 t0.setValue( 3, 2, "23" );
3266 t0.setValue( 10, 1, "error" );
3267 t0.setValue( 10, 1, "110" );
3268 t0.setValue( 9, 1, "19" );
3269 t0.setValue( 1, 10, "101" );
3270 t0.setValue( 10, 10, "1010" );
3271 t0.setValue( 100, 10, "10100" );
3272 t0.setValue( 0, 0, "00" );
3273 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3276 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3279 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3282 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3285 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3288 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3291 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3294 if ( t0.getNumberOfColumns() != 101 ) {
3297 if ( t0.getNumberOfRows() != 11 ) {
3300 if ( t0.getValueAsString( 49, 4 ) != null ) {
3303 final String l = ForesterUtil.getLineSeparator();
3304 final StringBuffer source = new StringBuffer();
3305 source.append( "" + l );
3306 source.append( "# 1 1 1 1 1 1 1 1" + l );
3307 source.append( " 00 01 02 03" + l );
3308 source.append( " 10 11 12 13 " + l );
3309 source.append( "20 21 22 23 " + l );
3310 source.append( " 30 31 32 33" + l );
3311 source.append( "40 41 42 43" + l );
3312 source.append( " # 1 1 1 1 1 " + l );
3313 source.append( "50 51 52 53 54" + l );
3314 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
3315 if ( t1.getNumberOfColumns() != 5 ) {
3318 if ( t1.getNumberOfRows() != 6 ) {
3321 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
3324 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
3327 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
3330 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
3333 final StringBuffer source1 = new StringBuffer();
3334 source1.append( "" + l );
3335 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3336 source1.append( " 00; 01 ;02;03" + l );
3337 source1.append( " 10; 11; 12; 13 " + l );
3338 source1.append( "20; 21; 22; 23 " + l );
3339 source1.append( " 30; 31; 32; 33" + l );
3340 source1.append( "40;41;42;43" + l );
3341 source1.append( " # 1 1 1 1 1 " + l );
3342 source1.append( ";;;50 ; ;52; 53;;54 " + l );
3343 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
3344 if ( t2.getNumberOfColumns() != 5 ) {
3347 if ( t2.getNumberOfRows() != 6 ) {
3350 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
3353 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
3356 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
3359 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
3362 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
3365 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
3368 final StringBuffer source2 = new StringBuffer();
3369 source2.append( "" + l );
3370 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3371 source2.append( " 00; 01 ;02;03" + l );
3372 source2.append( " 10; 11; 12; 13 " + l );
3373 source2.append( "20; 21; 22; 23 " + l );
3374 source2.append( " " + l );
3375 source2.append( " 30; 31; 32; 33" + l );
3376 source2.append( "40;41;42;43" + l );
3377 source2.append( " comment: 1 1 1 1 1 " + l );
3378 source2.append( ";;;50 ; 52; 53;;54 " + l );
3379 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
3385 if ( tl.size() != 2 ) {
3388 final BasicTable<String> t3 = tl.get( 0 );
3389 final BasicTable<String> t4 = tl.get( 1 );
3390 if ( t3.getNumberOfColumns() != 4 ) {
3393 if ( t3.getNumberOfRows() != 3 ) {
3396 if ( t4.getNumberOfColumns() != 4 ) {
3399 if ( t4.getNumberOfRows() != 3 ) {
3402 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
3405 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
3409 catch ( final Exception e ) {
3410 e.printStackTrace( System.out );
3416 private static boolean testBasicTolXMLparsing() {
3418 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3419 final TolParser parser = new TolParser();
3420 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
3421 if ( parser.getErrorCount() > 0 ) {
3422 System.out.println( parser.getErrorMessages().toString() );
3425 if ( phylogenies_0.length != 1 ) {
3428 final Phylogeny t1 = phylogenies_0[ 0 ];
3429 if ( t1.getNumberOfExternalNodes() != 5 ) {
3432 if ( !t1.isRooted() ) {
3435 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
3438 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
3441 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3442 .equals( "Rhombozoa" ) ) {
3445 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
3448 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
3449 if ( parser.getErrorCount() > 0 ) {
3450 System.out.println( parser.getErrorMessages().toString() );
3453 if ( phylogenies_1.length != 1 ) {
3456 final Phylogeny t2 = phylogenies_1[ 0 ];
3457 if ( t2.getNumberOfExternalNodes() != 664 ) {
3460 if ( !t2.isRooted() ) {
3463 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
3466 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
3469 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3472 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3475 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3476 .equals( "Aquificae" ) ) {
3479 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3480 .equals( "Aquifex" ) ) {
3483 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
3484 if ( parser.getErrorCount() > 0 ) {
3485 System.out.println( parser.getErrorMessages().toString() );
3488 if ( phylogenies_2.length != 1 ) {
3491 final Phylogeny t3 = phylogenies_2[ 0 ];
3492 if ( t3.getNumberOfExternalNodes() != 184 ) {
3495 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
3498 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
3501 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
3504 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
3505 if ( parser.getErrorCount() > 0 ) {
3506 System.out.println( parser.getErrorMessages().toString() );
3509 if ( phylogenies_3.length != 1 ) {
3512 final Phylogeny t4 = phylogenies_3[ 0 ];
3513 if ( t4.getNumberOfExternalNodes() != 1 ) {
3516 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
3519 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
3522 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
3525 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
3526 if ( parser.getErrorCount() > 0 ) {
3527 System.out.println( parser.getErrorMessages().toString() );
3530 if ( phylogenies_4.length != 1 ) {
3533 final Phylogeny t5 = phylogenies_4[ 0 ];
3534 if ( t5.getNumberOfExternalNodes() != 13 ) {
3537 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
3540 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
3543 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
3547 catch ( final Exception e ) {
3548 e.printStackTrace( System.out );
3554 private static boolean testBasicTreeMethods() {
3556 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3557 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
3558 if ( t2.getNumberOfExternalNodes() != 4 ) {
3561 if ( t2.calculateHeight( false ) != 8.5 ) {
3564 if ( !t2.isCompletelyBinary() ) {
3567 if ( t2.isEmpty() ) {
3570 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
3571 if ( t3.getNumberOfExternalNodes() != 5 ) {
3574 if ( t3.calculateHeight( true ) != 11 ) {
3577 if ( t3.isCompletelyBinary() ) {
3580 final PhylogenyNode n = t3.getNode( "ABC" );
3581 final Phylogeny t4 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3,(F,G,H,I))",
3582 new NHXParser() )[ 0 ];
3583 if ( t4.getNumberOfExternalNodes() != 9 ) {
3586 if ( t4.calculateHeight( false ) != 11 ) {
3589 if ( t4.isCompletelyBinary() ) {
3592 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)" );
3593 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
3594 if ( t5.getNumberOfExternalNodes() != 8 ) {
3597 if ( t5.calculateHeight( false ) != 15 ) {
3600 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)" );
3601 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
3602 if ( t6.calculateHeight( true ) != 15 ) {
3605 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)" );
3606 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
3607 if ( t7.calculateHeight( true ) != 15 ) {
3610 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)" );
3611 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
3612 if ( t8.getNumberOfExternalNodes() != 10 ) {
3615 if ( t8.calculateHeight( true ) != 15 ) {
3618 final char[] a9 = new char[] { 'a' };
3619 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
3620 if ( t9.calculateHeight( true ) != 0 ) {
3623 final char[] a10 = new char[] { 'a', ':', '6' };
3624 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
3625 if ( t10.calculateHeight( true ) != 6 ) {
3629 catch ( final Exception e ) {
3630 e.printStackTrace( System.out );
3636 private static boolean testConfidenceAssessor() {
3638 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3639 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3640 final Phylogeny[] ev0 = factory.create(
3641 "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
3643 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
3644 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3647 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3650 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3651 final Phylogeny[] ev1 = factory.create(
3652 "((((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)));",
3654 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
3655 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
3658 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3661 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3662 final Phylogeny[] ev_b = factory.create(
3663 "((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",
3665 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
3666 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
3669 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3673 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3674 final Phylogeny[] ev1x = factory.create(
3675 "((((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)));",
3677 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
3678 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3681 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3684 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3685 final Phylogeny[] ev_bx = factory.create(
3686 "((((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",
3688 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
3689 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3692 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3695 final Phylogeny[] t2 = factory.create(
3696 "((((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);",
3698 final Phylogeny[] ev2 = factory.create(
3699 "((((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);",
3701 for( final Phylogeny target : t2 ) {
3702 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
3704 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
3705 new NHXParser() )[ 0 ];
3706 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
3707 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
3708 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3711 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
3714 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3718 catch ( final Exception e ) {
3719 e.printStackTrace();
3725 private static boolean testCopyOfNodeData() {
3727 final PhylogenyNode n1 = PhylogenyNode
3728 .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]" );
3729 final PhylogenyNode n2 = n1.copyNodeData();
3730 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3734 catch ( final Exception e ) {
3735 e.printStackTrace();
3741 private static boolean testCreateBalancedPhylogeny() {
3743 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3744 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3747 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3750 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3751 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3754 if ( p1.getNumberOfExternalNodes() != 100 ) {
3758 catch ( final Exception e ) {
3759 e.printStackTrace();
3765 private static boolean testCreateUriForSeqWeb() {
3767 final PhylogenyNode n = new PhylogenyNode();
3768 n.setName( "tr|B3RJ64" );
3769 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3772 n.setName( "B0LM41_HUMAN" );
3773 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3774 .equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3777 n.setName( "NP_001025424" );
3778 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3779 .equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3782 n.setName( "_NM_001030253-" );
3783 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3784 .equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3787 n.setName( "XM_002122186" );
3788 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3789 .equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3792 n.setName( "dgh_AAA34956_gdg" );
3793 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3796 n.setName( "AAA34956" );
3797 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3800 n.setName( "GI:394892" );
3801 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3802 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3805 n.setName( "gi_394892" );
3806 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3807 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3810 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3811 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3812 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3815 n.setName( "P12345" );
3816 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3817 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3820 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3821 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3822 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3826 catch ( final Exception e ) {
3827 e.printStackTrace( System.out );
3833 private static boolean testDataObjects() {
3835 final Confidence s0 = new Confidence();
3836 final Confidence s1 = new Confidence();
3837 if ( !s0.isEqual( s1 ) ) {
3840 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3841 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3842 if ( s2.isEqual( s1 ) ) {
3845 if ( !s2.isEqual( s3 ) ) {
3848 final Confidence s4 = ( Confidence ) s3.copy();
3849 if ( !s4.isEqual( s3 ) ) {
3856 final Taxonomy t1 = new Taxonomy();
3857 final Taxonomy t2 = new Taxonomy();
3858 final Taxonomy t3 = new Taxonomy();
3859 final Taxonomy t4 = new Taxonomy();
3860 final Taxonomy t5 = new Taxonomy();
3861 t1.setIdentifier( new Identifier( "ecoli" ) );
3862 t1.setTaxonomyCode( "ECOLI" );
3863 t1.setScientificName( "E. coli" );
3864 t1.setCommonName( "coli" );
3865 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3866 if ( !t1.isEqual( t0 ) ) {
3869 t2.setIdentifier( new Identifier( "ecoli" ) );
3870 t2.setTaxonomyCode( "OTHER" );
3871 t2.setScientificName( "what" );
3872 t2.setCommonName( "something" );
3873 if ( !t1.isEqual( t2 ) ) {
3876 t2.setIdentifier( new Identifier( "nemve" ) );
3877 if ( t1.isEqual( t2 ) ) {
3880 t1.setIdentifier( null );
3881 t3.setTaxonomyCode( "ECOLI" );
3882 t3.setScientificName( "what" );
3883 t3.setCommonName( "something" );
3884 if ( !t1.isEqual( t3 ) ) {
3887 t1.setIdentifier( null );
3888 t1.setTaxonomyCode( "" );
3889 t4.setScientificName( "E. ColI" );
3890 t4.setCommonName( "something" );
3891 if ( !t1.isEqual( t4 ) ) {
3894 t4.setScientificName( "B. subtilis" );
3895 t4.setCommonName( "something" );
3896 if ( t1.isEqual( t4 ) ) {
3899 t1.setIdentifier( null );
3900 t1.setTaxonomyCode( "" );
3901 t1.setScientificName( "" );
3902 t5.setCommonName( "COLI" );
3903 if ( !t1.isEqual( t5 ) ) {
3906 t5.setCommonName( "vibrio" );
3907 if ( t1.isEqual( t5 ) ) {
3912 final Identifier id0 = new Identifier( "123", "pfam" );
3913 final Identifier id1 = ( Identifier ) id0.copy();
3914 if ( !id1.isEqual( id1 ) ) {
3917 if ( !id1.isEqual( id0 ) ) {
3920 if ( !id0.isEqual( id1 ) ) {
3927 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3928 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3929 if ( !pd1.isEqual( pd1 ) ) {
3932 if ( !pd1.isEqual( pd0 ) ) {
3937 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3938 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3939 if ( !pd3.isEqual( pd3 ) ) {
3942 if ( !pd2.isEqual( pd3 ) ) {
3945 if ( !pd0.isEqual( pd3 ) ) {
3950 // DomainArchitecture
3951 // ------------------
3952 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3953 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3954 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3955 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3956 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3957 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3962 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3963 if ( ds0.getNumberOfDomains() != 4 ) {
3966 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3967 if ( !ds0.isEqual( ds0 ) ) {
3970 if ( !ds0.isEqual( ds1 ) ) {
3973 if ( ds1.getNumberOfDomains() != 4 ) {
3976 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3981 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3982 if ( ds0.isEqual( ds2 ) ) {
3988 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3989 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3990 System.out.println( ds3.toNHX() );
3993 if ( ds3.getNumberOfDomains() != 3 ) {
3998 final Event e1 = new Event( Event.EventType.fusion );
3999 if ( e1.isDuplication() ) {
4002 if ( !e1.isFusion() ) {
4005 if ( !e1.asText().toString().equals( "fusion" ) ) {
4008 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
4011 final Event e11 = new Event( Event.EventType.fusion );
4012 if ( !e11.isEqual( e1 ) ) {
4015 if ( !e11.toNHX().toString().equals( "" ) ) {
4018 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
4019 if ( e2.isDuplication() ) {
4022 if ( !e2.isSpeciationOrDuplication() ) {
4025 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
4028 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
4031 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
4034 if ( e11.isEqual( e2 ) ) {
4037 final Event e2c = ( Event ) e2.copy();
4038 if ( !e2c.isEqual( e2 ) ) {
4041 Event e3 = new Event( 1, 2, 3 );
4042 if ( e3.isDuplication() ) {
4045 if ( e3.isSpeciation() ) {
4048 if ( e3.isGeneLoss() ) {
4051 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
4054 final Event e3c = ( Event ) e3.copy();
4055 final Event e3cc = ( Event ) e3c.copy();
4056 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
4060 if ( !e3c.isEqual( e3cc ) ) {
4063 Event e4 = new Event( 1, 2, 3 );
4064 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
4067 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
4070 final Event e4c = ( Event ) e4.copy();
4072 final Event e4cc = ( Event ) e4c.copy();
4073 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
4076 if ( !e4c.isEqual( e4cc ) ) {
4079 final Event e5 = new Event();
4080 if ( !e5.isUnassigned() ) {
4083 if ( !e5.asText().toString().equals( "unassigned" ) ) {
4086 if ( !e5.asSimpleText().toString().equals( "" ) ) {
4089 final Event e6 = new Event( 1, 0, 0 );
4090 if ( !e6.asText().toString().equals( "duplication" ) ) {
4093 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
4096 final Event e7 = new Event( 0, 1, 0 );
4097 if ( !e7.asText().toString().equals( "speciation" ) ) {
4100 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
4103 final Event e8 = new Event( 0, 0, 1 );
4104 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
4107 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
4111 catch ( final Exception e ) {
4112 e.printStackTrace( System.out );
4118 private static boolean testDeletionOfExternalNodes() {
4120 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4121 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
4122 final PhylogenyWriter w = new PhylogenyWriter();
4123 if ( t0.isEmpty() ) {
4126 if ( t0.getNumberOfExternalNodes() != 1 ) {
4129 t0.deleteSubtree( t0.getNode( "A" ), false );
4130 if ( t0.getNumberOfExternalNodes() != 0 ) {
4133 if ( !t0.isEmpty() ) {
4136 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
4137 if ( t1.getNumberOfExternalNodes() != 2 ) {
4140 t1.deleteSubtree( t1.getNode( "A" ), false );
4141 if ( t1.getNumberOfExternalNodes() != 1 ) {
4144 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
4147 t1.deleteSubtree( t1.getNode( "B" ), false );
4148 if ( t1.getNumberOfExternalNodes() != 1 ) {
4151 t1.deleteSubtree( t1.getNode( "r" ), false );
4152 if ( !t1.isEmpty() ) {
4155 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
4156 if ( t2.getNumberOfExternalNodes() != 3 ) {
4159 t2.deleteSubtree( t2.getNode( "B" ), false );
4160 if ( t2.getNumberOfExternalNodes() != 2 ) {
4163 t2.toNewHampshireX();
4164 PhylogenyNode n = t2.getNode( "A" );
4165 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
4168 t2.deleteSubtree( t2.getNode( "A" ), false );
4169 if ( t2.getNumberOfExternalNodes() != 2 ) {
4172 t2.deleteSubtree( t2.getNode( "C" ), true );
4173 if ( t2.getNumberOfExternalNodes() != 1 ) {
4176 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4177 if ( t3.getNumberOfExternalNodes() != 4 ) {
4180 t3.deleteSubtree( t3.getNode( "B" ), true );
4181 if ( t3.getNumberOfExternalNodes() != 3 ) {
4184 n = t3.getNode( "A" );
4185 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
4188 n = n.getNextExternalNode();
4189 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
4192 t3.deleteSubtree( t3.getNode( "A" ), true );
4193 if ( t3.getNumberOfExternalNodes() != 2 ) {
4196 n = t3.getNode( "C" );
4197 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
4200 t3.deleteSubtree( t3.getNode( "C" ), true );
4201 if ( t3.getNumberOfExternalNodes() != 1 ) {
4204 t3.deleteSubtree( t3.getNode( "D" ), true );
4205 if ( t3.getNumberOfExternalNodes() != 0 ) {
4208 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4209 if ( t4.getNumberOfExternalNodes() != 6 ) {
4212 t4.deleteSubtree( t4.getNode( "B2" ), true );
4213 if ( t4.getNumberOfExternalNodes() != 5 ) {
4216 String s = w.toNewHampshire( t4, true ).toString();
4217 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4220 t4.deleteSubtree( t4.getNode( "B11" ), true );
4221 if ( t4.getNumberOfExternalNodes() != 4 ) {
4224 t4.deleteSubtree( t4.getNode( "C" ), true );
4225 if ( t4.getNumberOfExternalNodes() != 3 ) {
4228 n = t4.getNode( "A" );
4229 n = n.getNextExternalNode();
4230 if ( !n.getName().equals( "B12" ) ) {
4233 n = n.getNextExternalNode();
4234 if ( !n.getName().equals( "D" ) ) {
4237 s = w.toNewHampshire( t4, true ).toString();
4238 if ( !s.equals( "((A,B12),D);" ) ) {
4241 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4242 t5.deleteSubtree( t5.getNode( "A" ), true );
4243 if ( t5.getNumberOfExternalNodes() != 5 ) {
4246 s = w.toNewHampshire( t5, true ).toString();
4247 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
4250 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4251 t6.deleteSubtree( t6.getNode( "B11" ), true );
4252 if ( t6.getNumberOfExternalNodes() != 5 ) {
4255 s = w.toNewHampshire( t6, false ).toString();
4256 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
4259 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4260 t7.deleteSubtree( t7.getNode( "B12" ), true );
4261 if ( t7.getNumberOfExternalNodes() != 5 ) {
4264 s = w.toNewHampshire( t7, true ).toString();
4265 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
4268 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4269 t8.deleteSubtree( t8.getNode( "B2" ), true );
4270 if ( t8.getNumberOfExternalNodes() != 5 ) {
4273 s = w.toNewHampshire( t8, false ).toString();
4274 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4277 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4278 t9.deleteSubtree( t9.getNode( "C" ), true );
4279 if ( t9.getNumberOfExternalNodes() != 5 ) {
4282 s = w.toNewHampshire( t9, true ).toString();
4283 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
4286 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4287 t10.deleteSubtree( t10.getNode( "D" ), true );
4288 if ( t10.getNumberOfExternalNodes() != 5 ) {
4291 s = w.toNewHampshire( t10, true ).toString();
4292 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
4295 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
4296 t11.deleteSubtree( t11.getNode( "A" ), true );
4297 if ( t11.getNumberOfExternalNodes() != 2 ) {
4300 s = w.toNewHampshire( t11, true ).toString();
4301 if ( !s.equals( "(B,C);" ) ) {
4304 t11.deleteSubtree( t11.getNode( "C" ), true );
4305 if ( t11.getNumberOfExternalNodes() != 1 ) {
4308 s = w.toNewHampshire( t11, false ).toString();
4309 if ( !s.equals( "B;" ) ) {
4312 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
4313 t12.deleteSubtree( t12.getNode( "B2" ), true );
4314 if ( t12.getNumberOfExternalNodes() != 8 ) {
4317 s = w.toNewHampshire( t12, true ).toString();
4318 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
4321 t12.deleteSubtree( t12.getNode( "B3" ), true );
4322 if ( t12.getNumberOfExternalNodes() != 7 ) {
4325 s = w.toNewHampshire( t12, true ).toString();
4326 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
4329 t12.deleteSubtree( t12.getNode( "C3" ), true );
4330 if ( t12.getNumberOfExternalNodes() != 6 ) {
4333 s = w.toNewHampshire( t12, true ).toString();
4334 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
4337 t12.deleteSubtree( t12.getNode( "A1" ), true );
4338 if ( t12.getNumberOfExternalNodes() != 5 ) {
4341 s = w.toNewHampshire( t12, true ).toString();
4342 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
4345 t12.deleteSubtree( t12.getNode( "B1" ), true );
4346 if ( t12.getNumberOfExternalNodes() != 4 ) {
4349 s = w.toNewHampshire( t12, true ).toString();
4350 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
4353 t12.deleteSubtree( t12.getNode( "A3" ), true );
4354 if ( t12.getNumberOfExternalNodes() != 3 ) {
4357 s = w.toNewHampshire( t12, true ).toString();
4358 if ( !s.equals( "(A2,(C1,C2));" ) ) {
4361 t12.deleteSubtree( t12.getNode( "A2" ), true );
4362 if ( t12.getNumberOfExternalNodes() != 2 ) {
4365 s = w.toNewHampshire( t12, true ).toString();
4366 if ( !s.equals( "(C1,C2);" ) ) {
4369 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
4370 t13.deleteSubtree( t13.getNode( "D" ), true );
4371 if ( t13.getNumberOfExternalNodes() != 4 ) {
4374 s = w.toNewHampshire( t13, true ).toString();
4375 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
4378 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
4379 t14.deleteSubtree( t14.getNode( "E" ), true );
4380 if ( t14.getNumberOfExternalNodes() != 5 ) {
4383 s = w.toNewHampshire( t14, true ).toString();
4384 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
4387 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
4388 t15.deleteSubtree( t15.getNode( "B2" ), true );
4389 if ( t15.getNumberOfExternalNodes() != 11 ) {
4392 t15.deleteSubtree( t15.getNode( "B1" ), true );
4393 if ( t15.getNumberOfExternalNodes() != 10 ) {
4396 t15.deleteSubtree( t15.getNode( "B3" ), true );
4397 if ( t15.getNumberOfExternalNodes() != 9 ) {
4400 t15.deleteSubtree( t15.getNode( "B4" ), true );
4401 if ( t15.getNumberOfExternalNodes() != 8 ) {
4404 t15.deleteSubtree( t15.getNode( "A1" ), true );
4405 if ( t15.getNumberOfExternalNodes() != 7 ) {
4408 t15.deleteSubtree( t15.getNode( "C4" ), true );
4409 if ( t15.getNumberOfExternalNodes() != 6 ) {
4413 catch ( final Exception e ) {
4414 e.printStackTrace( System.out );
4420 private static boolean testDescriptiveStatistics() {
4422 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
4423 dss1.addValue( 82 );
4424 dss1.addValue( 78 );
4425 dss1.addValue( 70 );
4426 dss1.addValue( 58 );
4427 dss1.addValue( 42 );
4428 if ( dss1.getN() != 5 ) {
4431 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
4434 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
4437 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
4440 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
4443 if ( !Test.isEqual( dss1.median(), 70 ) ) {
4446 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
4449 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
4452 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
4455 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
4458 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
4461 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
4464 dss1.addValue( 123 );
4465 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
4468 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
4471 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
4474 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
4475 dss2.addValue( -1.85 );
4476 dss2.addValue( 57.5 );
4477 dss2.addValue( 92.78 );
4478 dss2.addValue( 57.78 );
4479 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
4482 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
4485 final double[] a = dss2.getDataAsDoubleArray();
4486 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
4489 dss2.addValue( -100 );
4490 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
4493 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
4496 final double[] ds = new double[ 14 ];
4511 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
4512 if ( bins.length != 4 ) {
4515 if ( bins[ 0 ] != 2 ) {
4518 if ( bins[ 1 ] != 3 ) {
4521 if ( bins[ 2 ] != 4 ) {
4524 if ( bins[ 3 ] != 5 ) {
4527 final double[] ds1 = new double[ 9 ];
4537 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
4538 if ( bins1.length != 4 ) {
4541 if ( bins1[ 0 ] != 2 ) {
4544 if ( bins1[ 1 ] != 3 ) {
4547 if ( bins1[ 2 ] != 0 ) {
4550 if ( bins1[ 3 ] != 4 ) {
4553 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
4554 if ( bins1_1.length != 3 ) {
4557 if ( bins1_1[ 0 ] != 3 ) {
4560 if ( bins1_1[ 1 ] != 2 ) {
4563 if ( bins1_1[ 2 ] != 4 ) {
4566 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
4567 if ( bins1_2.length != 3 ) {
4570 if ( bins1_2[ 0 ] != 2 ) {
4573 if ( bins1_2[ 1 ] != 2 ) {
4576 if ( bins1_2[ 2 ] != 2 ) {
4579 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
4593 dss3.addValue( 10 );
4594 dss3.addValue( 10 );
4595 dss3.addValue( 10 );
4596 final AsciiHistogram histo = new AsciiHistogram( dss3 );
4597 histo.toStringBuffer( 10, '=', 40, 5 );
4598 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
4600 catch ( final Exception e ) {
4601 e.printStackTrace( System.out );
4607 private static boolean testDir( final String file ) {
4609 final File f = new File( file );
4610 if ( !f.exists() ) {
4613 if ( !f.isDirectory() ) {
4616 if ( !f.canRead() ) {
4620 catch ( final Exception e ) {
4626 private static boolean testEbiEntryRetrieval() {
4628 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
4629 if ( !entry.getAccession().equals( "AAK41263" ) ) {
4630 System.out.println( entry.getAccession() );
4633 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
4634 System.out.println( entry.getTaxonomyScientificName() );
4637 if ( !entry.getSequenceName()
4638 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
4639 System.out.println( entry.getSequenceName() );
4642 if ( !entry.getGeneName().equals( "treX-like" ) ) {
4643 System.out.println( entry.getGeneName() );
4646 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
4647 System.out.println( entry.getTaxonomyIdentifier() );
4650 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
4651 System.out.println( entry.getAnnotations().first().getRefValue() );
4654 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
4655 System.out.println( entry.getAnnotations().first().getRefSource() );
4658 if ( entry.getCrossReferences().size() < 1 ) {
4661 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
4662 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
4665 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
4666 System.out.println( entry1.getTaxonomyScientificName() );
4669 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
4670 System.out.println( entry1.getSequenceName() );
4673 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
4674 System.out.println( entry1.getTaxonomyIdentifier() );
4677 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
4678 System.out.println( entry1.getGeneName() );
4681 if ( entry1.getCrossReferences().size() < 1 ) {
4684 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
4685 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
4688 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4689 System.out.println( entry2.getTaxonomyScientificName() );
4692 if ( !entry2.getSequenceName()
4693 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
4694 System.out.println( entry2.getSequenceName() );
4697 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
4698 System.out.println( entry2.getTaxonomyIdentifier() );
4701 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
4702 System.out.println( entry2.getGeneName() );
4705 if ( entry2.getCrossReferences().size() < 1 ) {
4708 if ( !entry2.getChromosome().equals( "20" ) ) {
4711 if ( !entry2.getMap().equals( "20q11.22" ) ) {
4714 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
4715 if ( !entry3.getAccession().equals( "HM043801" ) ) {
4718 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
4719 System.out.println( entry3.getTaxonomyScientificName() );
4722 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4723 System.out.println( entry3.getSequenceName() );
4726 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4727 System.out.println( entry3.getTaxonomyIdentifier() );
4730 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4731 System.out.println( entry3.getSequenceSymbol() );
4734 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4737 if ( entry3.getCrossReferences().size() < 1 ) {
4740 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4741 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4744 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4745 System.out.println( entry4.getTaxonomyScientificName() );
4748 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4749 System.out.println( entry4.getSequenceName() );
4752 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4753 System.out.println( entry4.getTaxonomyIdentifier() );
4756 if ( !entry4.getGeneName().equals( "ras" ) ) {
4757 System.out.println( entry4.getGeneName() );
4760 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4761 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4764 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4765 System.out.println( entry5.getTaxonomyScientificName() );
4768 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4769 System.out.println( entry5.getSequenceName() );
4772 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4773 System.out.println( entry5.getTaxonomyIdentifier() );
4776 final SequenceDatabaseEntry entry6 = SequenceDbWsTools.obtainEntry( "M30539" );
4777 if ( !entry6.getAccession().equals( "M30539" ) ) {
4780 if ( !entry6.getGeneName().equals( "ras" ) ) {
4783 if ( !entry6.getSequenceName().equals( "Human SK2 c-Ha-ras-1 oncogene-encoded protein gene, exon 1" ) ) {
4786 if ( !entry6.getTaxonomyIdentifier().equals( "9606" ) ) {
4789 if ( !entry6.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4792 if ( entry6.getCrossReferences().size() < 1 ) {
4796 catch ( final IOException e ) {
4797 System.out.println();
4798 System.out.println( "the following might be due to absence internet connection:" );
4799 e.printStackTrace( System.out );
4802 catch ( final Exception e ) {
4803 e.printStackTrace();
4809 private static boolean testExternalNodeRelatedMethods() {
4811 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4812 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4813 PhylogenyNode n = t1.getNode( "A" );
4814 n = n.getNextExternalNode();
4815 if ( !n.getName().equals( "B" ) ) {
4818 n = n.getNextExternalNode();
4819 if ( !n.getName().equals( "C" ) ) {
4822 n = n.getNextExternalNode();
4823 if ( !n.getName().equals( "D" ) ) {
4826 n = t1.getNode( "B" );
4827 while ( !n.isLastExternalNode() ) {
4828 n = n.getNextExternalNode();
4830 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4831 n = t2.getNode( "A" );
4832 n = n.getNextExternalNode();
4833 if ( !n.getName().equals( "B" ) ) {
4836 n = n.getNextExternalNode();
4837 if ( !n.getName().equals( "C" ) ) {
4840 n = n.getNextExternalNode();
4841 if ( !n.getName().equals( "D" ) ) {
4844 n = t2.getNode( "B" );
4845 while ( !n.isLastExternalNode() ) {
4846 n = n.getNextExternalNode();
4848 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4849 n = t3.getNode( "A" );
4850 n = n.getNextExternalNode();
4851 if ( !n.getName().equals( "B" ) ) {
4854 n = n.getNextExternalNode();
4855 if ( !n.getName().equals( "C" ) ) {
4858 n = n.getNextExternalNode();
4859 if ( !n.getName().equals( "D" ) ) {
4862 n = n.getNextExternalNode();
4863 if ( !n.getName().equals( "E" ) ) {
4866 n = n.getNextExternalNode();
4867 if ( !n.getName().equals( "F" ) ) {
4870 n = n.getNextExternalNode();
4871 if ( !n.getName().equals( "G" ) ) {
4874 n = n.getNextExternalNode();
4875 if ( !n.getName().equals( "H" ) ) {
4878 n = t3.getNode( "B" );
4879 while ( !n.isLastExternalNode() ) {
4880 n = n.getNextExternalNode();
4882 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4883 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4884 final PhylogenyNode node = iter.next();
4886 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4887 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4888 final PhylogenyNode node = iter.next();
4890 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))",
4891 new NHXParser() )[ 0 ];
4892 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4893 if ( !iter.next().getName().equals( "A" ) ) {
4896 if ( !iter.next().getName().equals( "B" ) ) {
4899 if ( !iter.next().getName().equals( "C" ) ) {
4902 if ( !iter.next().getName().equals( "D" ) ) {
4905 if ( !iter.next().getName().equals( "E" ) ) {
4908 if ( !iter.next().getName().equals( "F" ) ) {
4911 if ( iter.hasNext() ) {
4915 catch ( final Exception e ) {
4916 e.printStackTrace( System.out );
4922 private static boolean testExtractSNFromNodeName() {
4924 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4927 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4930 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4933 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4934 .equals( "Mus musculus musculus" ) ) {
4937 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4938 .equals( "Mus musculus musculus" ) ) {
4941 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4942 .equals( "Mus musculus musculus" ) ) {
4945 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4946 .equals( "Mus musculus musculus" ) ) {
4949 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4952 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4953 .equals( "Mus musculus musculus" ) ) {
4956 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4957 .equals( "Mus musculus musculus" ) ) {
4961 .extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4964 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4967 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4970 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4973 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4974 .equals( "Mus musculus musculus" ) ) {
4977 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4980 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4983 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4986 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4989 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4992 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4995 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4998 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
5001 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
5002 .equals( "Mus musculus" ) ) {
5005 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
5006 .equals( "Mus musculus" ) ) {
5009 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
5012 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
5013 .equals( "Mus musculus musculus" ) ) {
5016 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
5017 .equals( "Mus musculus musculus" ) ) {
5020 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
5021 .equals( "Mus musculus musculus" ) ) {
5024 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
5027 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
5028 .equals( "Pilostyles mexicana" ) ) {
5031 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
5032 .equals( "Escherichia coli strain K12/DH10B" ) ) {
5035 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
5036 .equals( "Escherichia coli str. K12/DH10B" ) ) {
5039 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
5040 .equals( "Escherichia coli str. K12/DH10B" ) ) {
5043 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
5044 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
5047 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
5048 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
5051 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
5052 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
5055 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
5056 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
5059 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
5060 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
5063 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
5064 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
5067 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
5068 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
5071 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
5072 .equals( "Escherichia coli (strain K12)" ) ) {
5075 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
5076 .equals( "Escherichia coli (strain K12)" ) ) {
5079 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
5080 .equals( "Escherichia coli (str. K12)" ) ) {
5083 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
5084 .equals( "Escherichia coli (str. K12)" ) ) {
5087 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
5088 .equals( "Escherichia coli (str. K12)" ) ) {
5091 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
5092 .equals( "Escherichia coli (var. K12)" ) ) {
5095 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
5096 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5099 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
5100 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5104 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
5105 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5108 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
5109 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5113 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
5114 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5117 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
5118 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5121 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
5122 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5125 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
5128 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
5131 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
5134 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
5135 .equals( "Macrocera sp." ) ) {
5138 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
5141 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
5142 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
5145 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
5146 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
5149 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
5150 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
5153 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
5154 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
5158 catch ( final Exception e ) {
5159 e.printStackTrace( System.out );
5165 private static boolean testExtractTaxonomyDataFromNodeName() {
5167 PhylogenyNode n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN" );
5168 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5171 n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN~1-2" );
5172 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5175 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN" );
5176 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5179 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN|" );
5180 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5183 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN~12" );
5184 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5187 n = new PhylogenyNode( "HNRPR_HUMAN" );
5188 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5191 n = new PhylogenyNode( "HNRPR_HUMAN_X" );
5192 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5196 catch ( final Exception e ) {
5197 e.printStackTrace( System.out );
5203 private static boolean testExtractTaxonomyCodeFromNodeName() {
5205 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE",
5206 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5209 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5210 .equals( "SOYBN" ) ) {
5213 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
5214 .equals( "ARATH" ) ) {
5217 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
5218 .equals( "ARATH" ) ) {
5221 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE )
5222 .equals( "RAT" ) ) {
5225 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE )
5226 .equals( "RAT" ) ) {
5229 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1",
5230 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5233 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5234 .equals( "SOYBN" ) ) {
5237 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5238 .equals( "SOYBN" ) ) {
5241 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5242 .equals( "SOYBN" ) ) {
5245 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5246 .equals( "SOYBN" ) ) {
5249 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5250 .equals( "SOYBN" ) ) {
5253 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5254 .equals( "SOYBN" ) ) {
5257 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
5258 .equals( "SOYBN" ) ) {
5261 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
5262 .equals( "SOYBN" ) ) {
5265 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx",
5266 TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
5269 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
5270 .equals( "SOYBN" ) ) {
5274 .extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5275 .equals( "ECOLI" ) ) {
5278 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blagg_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
5279 .equals( "9YX45" ) ) {
5282 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
5283 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5284 .equals( "MOUSE" ) ) {
5287 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
5288 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5289 .equals( "MOUSE" ) ) {
5292 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
5293 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5294 .equals( "MOUSE" ) ) {
5297 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
5298 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5301 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
5302 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5305 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5306 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5307 .equals( "RAT" ) ) {
5310 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5311 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5312 .equals( "RAT" ) ) {
5315 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
5316 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5317 .equals( "RAT" ) ) {
5320 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
5321 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5324 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
5325 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5328 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5329 .equals( "RAT" ) ) {
5332 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5333 .equals( "PIG" ) ) {
5337 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5338 .equals( "MOUSE" ) ) {
5341 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5342 .equals( "MOUSE" ) ) {
5345 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ",
5346 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5350 catch ( final Exception e ) {
5351 e.printStackTrace( System.out );
5357 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
5359 PhylogenyNode n = new PhylogenyNode();
5360 n.setName( "tr|B3RJ64" );
5361 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5364 n.setName( "tr.B3RJ64" );
5365 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5368 n.setName( "tr=B3RJ64" );
5369 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5372 n.setName( "tr-B3RJ64" );
5373 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5376 n.setName( "tr/B3RJ64" );
5377 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5380 n.setName( "tr\\B3RJ64" );
5381 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5384 n.setName( "tr_B3RJ64" );
5385 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5388 n.setName( " tr|B3RJ64 " );
5389 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5392 n.setName( "-tr|B3RJ64-" );
5393 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5396 n.setName( "-tr=B3RJ64-" );
5397 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5400 n.setName( "_tr=B3RJ64_" );
5401 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5404 n.setName( " tr_tr|B3RJ64_sp|123 " );
5405 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5408 n.setName( "B3RJ64" );
5409 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5412 n.setName( "sp|B3RJ64" );
5413 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5416 n.setName( "sp|B3RJ64C" );
5417 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5420 n.setName( "sp B3RJ64" );
5421 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5424 n.setName( "sp|B3RJ6X" );
5425 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5428 n.setName( "sp|B3RJ6" );
5429 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5432 n.setName( "K1PYK7_CRAGI" );
5433 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5436 n.setName( "K1PYK7_PEA" );
5437 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
5440 n.setName( "K1PYK7_RAT" );
5441 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
5444 n.setName( "K1PYK7_PIG" );
5445 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5448 n.setName( "~K1PYK7_PIG~" );
5449 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5452 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
5453 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5456 n.setName( "K1PYKX_CRAGI" );
5457 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5460 n.setName( "XXXXX_CRAGI" );
5461 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
5464 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
5465 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
5468 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
5469 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5472 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
5473 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
5476 n = new PhylogenyNode();
5477 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
5478 seq.setSymbol( "K1PYK7_CRAGI" );
5479 n.getNodeData().addSequence( seq );
5480 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5483 seq.setSymbol( "tr|B3RJ64" );
5484 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5487 n = new PhylogenyNode();
5488 seq = new org.forester.phylogeny.data.Sequence();
5489 seq.setName( "K1PYK7_CRAGI" );
5490 n.getNodeData().addSequence( seq );
5491 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5494 seq.setName( "tr|B3RJ64" );
5495 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5498 n = new PhylogenyNode();
5499 seq = new org.forester.phylogeny.data.Sequence();
5500 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
5501 n.getNodeData().addSequence( seq );
5502 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
5505 n = new PhylogenyNode();
5506 seq = new org.forester.phylogeny.data.Sequence();
5507 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
5508 n.getNodeData().addSequence( seq );
5509 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5513 n = new PhylogenyNode();
5514 n.setName( "ACP19736" );
5515 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5518 n = new PhylogenyNode();
5519 n.setName( "|ACP19736|" );
5520 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5524 catch ( final Exception e ) {
5525 e.printStackTrace( System.out );
5531 private static boolean testFastaParser() {
5533 final FileInputStream fis1 = new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" );
5534 if ( !FastaParser.isLikelyFasta( fis1 ) ) {
5541 final FileInputStream fis2 = new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" );
5542 if ( FastaParser.isLikelyFasta( fis2 ) ) {
5549 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
5550 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
5553 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
5556 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
5559 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPROWXERR" ) ) {
5562 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
5565 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
5569 catch ( final Exception e ) {
5570 e.printStackTrace();
5576 private static boolean testGenbankAccessorParsing() {
5577 //The format for GenBank Accession numbers are:
5578 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
5579 //Protein: 3 letters + 5 numerals
5580 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
5581 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
5584 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
5587 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" )
5588 .equals( "AY423861.24" ) ) {
5591 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
5594 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
5597 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
5600 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
5603 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
5606 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
5609 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
5612 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
5615 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
5618 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
5621 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
5627 private static boolean testGeneralMsaParser() {
5629 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
5630 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
5631 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
5632 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
5633 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
5634 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
5635 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
5636 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
5637 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5640 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5643 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5646 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5649 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5652 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5655 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5658 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5661 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5664 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5667 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5670 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5673 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
5674 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5677 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5680 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5683 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
5684 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
5687 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
5690 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
5693 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
5694 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5697 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5700 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5704 catch ( final Exception e ) {
5705 e.printStackTrace();
5711 private static boolean testGeneralTable() {
5713 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
5714 t0.setValue( 3, 2, "23" );
5715 t0.setValue( 10, 1, "error" );
5716 t0.setValue( 10, 1, "110" );
5717 t0.setValue( 9, 1, "19" );
5718 t0.setValue( 1, 10, "101" );
5719 t0.setValue( 10, 10, "1010" );
5720 t0.setValue( 100, 10, "10100" );
5721 t0.setValue( 0, 0, "00" );
5722 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
5725 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
5728 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
5731 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
5734 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
5737 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
5740 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
5743 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
5746 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
5749 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
5750 t1.setValue( "3", "2", "23" );
5751 t1.setValue( "10", "1", "error" );
5752 t1.setValue( "10", "1", "110" );
5753 t1.setValue( "9", "1", "19" );
5754 t1.setValue( "1", "10", "101" );
5755 t1.setValue( "10", "10", "1010" );
5756 t1.setValue( "100", "10", "10100" );
5757 t1.setValue( "0", "0", "00" );
5758 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
5759 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
5762 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
5765 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
5768 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
5771 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
5774 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
5777 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
5780 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
5783 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5786 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5790 catch ( final Exception e ) {
5791 e.printStackTrace( System.out );
5797 private static boolean testGetDistance() {
5799 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5800 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",
5801 new NHXParser() )[ 0 ];
5802 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5805 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5808 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5811 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5814 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5817 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5820 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5823 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5826 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5829 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5832 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5835 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5838 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5841 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5844 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5847 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5850 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5853 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5856 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5859 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5862 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5865 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5868 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5871 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5874 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5877 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5880 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5883 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5886 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5889 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5892 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5895 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",
5896 new NHXParser() )[ 0 ];
5897 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5900 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5903 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5906 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5909 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5912 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5915 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5918 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5921 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5924 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5927 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5931 catch ( final Exception e ) {
5932 e.printStackTrace( System.out );
5938 private static boolean testGetLCA() {
5940 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5941 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5942 new NHXParser() )[ 0 ];
5943 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5944 if ( !A.getName().equals( "A" ) ) {
5947 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5948 if ( !gh.getName().equals( "gh" ) ) {
5951 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5952 if ( !ab.getName().equals( "ab" ) ) {
5955 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5956 if ( !ab2.getName().equals( "ab" ) ) {
5959 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5960 if ( !gh2.getName().equals( "gh" ) ) {
5963 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5964 if ( !gh3.getName().equals( "gh" ) ) {
5967 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5968 if ( !abc.getName().equals( "abc" ) ) {
5971 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5972 if ( !abc2.getName().equals( "abc" ) ) {
5975 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5976 if ( !abcd.getName().equals( "abcd" ) ) {
5979 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5980 if ( !abcd2.getName().equals( "abcd" ) ) {
5983 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5984 if ( !abcdef.getName().equals( "abcdef" ) ) {
5987 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5988 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5991 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5992 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5995 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5996 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5999 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
6000 if ( !abcde.getName().equals( "abcde" ) ) {
6003 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
6004 if ( !abcde2.getName().equals( "abcde" ) ) {
6007 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
6008 if ( !r.getName().equals( "abcdefgh" ) ) {
6011 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
6012 if ( !r2.getName().equals( "abcdefgh" ) ) {
6015 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
6016 if ( !r3.getName().equals( "abcdefgh" ) ) {
6019 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
6020 if ( !abcde3.getName().equals( "abcde" ) ) {
6023 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
6024 if ( !abcde4.getName().equals( "abcde" ) ) {
6027 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
6028 if ( !ab3.getName().equals( "ab" ) ) {
6031 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
6032 if ( !ab4.getName().equals( "ab" ) ) {
6035 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
6036 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
6037 if ( !cd.getName().equals( "cd" ) ) {
6040 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
6041 if ( !cd2.getName().equals( "cd" ) ) {
6044 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
6045 if ( !cde.getName().equals( "cde" ) ) {
6048 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
6049 if ( !cde2.getName().equals( "cde" ) ) {
6052 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
6053 if ( !cdef.getName().equals( "cdef" ) ) {
6056 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
6057 if ( !cdef2.getName().equals( "cdef" ) ) {
6060 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
6061 if ( !cdef3.getName().equals( "cdef" ) ) {
6064 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
6065 if ( !rt.getName().equals( "r" ) ) {
6068 final Phylogeny p3 = factory.create(
6069 "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
6070 new NHXParser() )[ 0 ];
6071 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
6072 if ( !bc_3.getName().equals( "bc" ) ) {
6075 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
6076 if ( !ac_3.getName().equals( "abc" ) ) {
6079 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
6080 if ( !ad_3.getName().equals( "abcde" ) ) {
6083 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
6084 if ( !af_3.getName().equals( "abcdef" ) ) {
6087 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
6088 if ( !ag_3.getName().equals( "" ) ) {
6091 if ( !ag_3.isRoot() ) {
6094 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
6095 if ( !al_3.getName().equals( "" ) ) {
6098 if ( !al_3.isRoot() ) {
6101 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
6102 if ( !kl_3.getName().equals( "" ) ) {
6105 if ( !kl_3.isRoot() ) {
6108 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
6109 if ( !fl_3.getName().equals( "" ) ) {
6112 if ( !fl_3.isRoot() ) {
6115 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
6116 if ( !gk_3.getName().equals( "ghijk" ) ) {
6119 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
6120 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
6121 if ( !r_4.getName().equals( "r" ) ) {
6124 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
6125 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
6126 if ( !r_5.getName().equals( "root" ) ) {
6129 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
6130 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
6131 if ( !r_6.getName().equals( "rot" ) ) {
6134 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
6135 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
6136 if ( !r_7.getName().equals( "rott" ) ) {
6140 catch ( final Exception e ) {
6141 e.printStackTrace( System.out );
6147 private static boolean testGetLCA2() {
6149 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6150 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
6151 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
6152 PhylogenyMethods.preOrderReId( p_a );
6153 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
6154 p_a.getNode( "a" ) );
6155 if ( !p_a_1.getName().equals( "a" ) ) {
6158 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
6159 PhylogenyMethods.preOrderReId( p_b );
6160 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
6161 p_b.getNode( "a" ) );
6162 if ( !p_b_1.getName().equals( "b" ) ) {
6165 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
6166 p_b.getNode( "b" ) );
6167 if ( !p_b_2.getName().equals( "b" ) ) {
6170 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
6171 PhylogenyMethods.preOrderReId( p_c );
6172 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
6173 p_c.getNode( "a" ) );
6174 if ( !p_c_1.getName().equals( "b" ) ) {
6177 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
6178 p_c.getNode( "c" ) );
6179 if ( !p_c_2.getName().equals( "c" ) ) {
6180 System.out.println( p_c_2.getName() );
6184 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
6185 p_c.getNode( "b" ) );
6186 if ( !p_c_3.getName().equals( "b" ) ) {
6189 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
6190 p_c.getNode( "a" ) );
6191 if ( !p_c_4.getName().equals( "c" ) ) {
6194 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
6195 new NHXParser() )[ 0 ];
6196 PhylogenyMethods.preOrderReId( p1 );
6197 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6198 p1.getNode( "A" ) );
6199 if ( !A.getName().equals( "A" ) ) {
6202 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
6203 p1.getNode( "gh" ) );
6204 if ( !gh.getName().equals( "gh" ) ) {
6207 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6208 p1.getNode( "B" ) );
6209 if ( !ab.getName().equals( "ab" ) ) {
6212 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
6213 p1.getNode( "A" ) );
6214 if ( !ab2.getName().equals( "ab" ) ) {
6217 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
6218 p1.getNode( "G" ) );
6219 if ( !gh2.getName().equals( "gh" ) ) {
6222 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
6223 p1.getNode( "H" ) );
6224 if ( !gh3.getName().equals( "gh" ) ) {
6227 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
6228 p1.getNode( "A" ) );
6229 if ( !abc.getName().equals( "abc" ) ) {
6232 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6233 p1.getNode( "C" ) );
6234 if ( !abc2.getName().equals( "abc" ) ) {
6237 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6238 p1.getNode( "D" ) );
6239 if ( !abcd.getName().equals( "abcd" ) ) {
6242 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
6243 p1.getNode( "A" ) );
6244 if ( !abcd2.getName().equals( "abcd" ) ) {
6247 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6248 p1.getNode( "F" ) );
6249 if ( !abcdef.getName().equals( "abcdef" ) ) {
6252 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
6253 p1.getNode( "A" ) );
6254 if ( !abcdef2.getName().equals( "abcdef" ) ) {
6257 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6258 p1.getNode( "F" ) );
6259 if ( !abcdef3.getName().equals( "abcdef" ) ) {
6262 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
6263 p1.getNode( "ab" ) );
6264 if ( !abcdef4.getName().equals( "abcdef" ) ) {
6267 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6268 p1.getNode( "E" ) );
6269 if ( !abcde.getName().equals( "abcde" ) ) {
6272 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6273 p1.getNode( "A" ) );
6274 if ( !abcde2.getName().equals( "abcde" ) ) {
6277 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
6278 p1.getNode( "abcdefgh" ) );
6279 if ( !r.getName().equals( "abcdefgh" ) ) {
6282 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6283 p1.getNode( "H" ) );
6284 if ( !r2.getName().equals( "abcdefgh" ) ) {
6287 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
6288 p1.getNode( "A" ) );
6289 if ( !r3.getName().equals( "abcdefgh" ) ) {
6292 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6293 p1.getNode( "abcde" ) );
6294 if ( !abcde3.getName().equals( "abcde" ) ) {
6297 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
6298 p1.getNode( "E" ) );
6299 if ( !abcde4.getName().equals( "abcde" ) ) {
6302 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6303 p1.getNode( "B" ) );
6304 if ( !ab3.getName().equals( "ab" ) ) {
6307 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
6308 p1.getNode( "ab" ) );
6309 if ( !ab4.getName().equals( "ab" ) ) {
6312 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
6313 PhylogenyMethods.preOrderReId( p2 );
6314 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6315 p2.getNode( "d" ) );
6316 if ( !cd.getName().equals( "cd" ) ) {
6319 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6320 p2.getNode( "c" ) );
6321 if ( !cd2.getName().equals( "cd" ) ) {
6324 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6325 p2.getNode( "e" ) );
6326 if ( !cde.getName().equals( "cde" ) ) {
6329 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
6330 p2.getNode( "c" ) );
6331 if ( !cde2.getName().equals( "cde" ) ) {
6334 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6335 p2.getNode( "f" ) );
6336 if ( !cdef.getName().equals( "cdef" ) ) {
6339 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6340 p2.getNode( "f" ) );
6341 if ( !cdef2.getName().equals( "cdef" ) ) {
6344 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
6345 p2.getNode( "d" ) );
6346 if ( !cdef3.getName().equals( "cdef" ) ) {
6349 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6350 p2.getNode( "a" ) );
6351 if ( !rt.getName().equals( "r" ) ) {
6354 final Phylogeny p3 = factory.create(
6355 "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
6356 new NHXParser() )[ 0 ];
6357 PhylogenyMethods.preOrderReId( p3 );
6358 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
6359 p3.getNode( "c" ) );
6360 if ( !bc_3.getName().equals( "bc" ) ) {
6363 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6364 p3.getNode( "c" ) );
6365 if ( !ac_3.getName().equals( "abc" ) ) {
6368 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6369 p3.getNode( "d" ) );
6370 if ( !ad_3.getName().equals( "abcde" ) ) {
6373 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6374 p3.getNode( "f" ) );
6375 if ( !af_3.getName().equals( "abcdef" ) ) {
6378 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6379 p3.getNode( "g" ) );
6380 if ( !ag_3.getName().equals( "" ) ) {
6383 if ( !ag_3.isRoot() ) {
6386 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6387 p3.getNode( "l" ) );
6388 if ( !al_3.getName().equals( "" ) ) {
6391 if ( !al_3.isRoot() ) {
6394 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
6395 p3.getNode( "l" ) );
6396 if ( !kl_3.getName().equals( "" ) ) {
6399 if ( !kl_3.isRoot() ) {
6402 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
6403 p3.getNode( "l" ) );
6404 if ( !fl_3.getName().equals( "" ) ) {
6407 if ( !fl_3.isRoot() ) {
6410 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
6411 p3.getNode( "k" ) );
6412 if ( !gk_3.getName().equals( "ghijk" ) ) {
6415 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
6416 PhylogenyMethods.preOrderReId( p4 );
6417 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
6418 p4.getNode( "c" ) );
6419 if ( !r_4.getName().equals( "r" ) ) {
6422 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
6423 PhylogenyMethods.preOrderReId( p5 );
6424 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
6425 p5.getNode( "c" ) );
6426 if ( !r_5.getName().equals( "root" ) ) {
6429 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
6430 PhylogenyMethods.preOrderReId( p6 );
6431 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
6432 p6.getNode( "a" ) );
6433 if ( !r_6.getName().equals( "rot" ) ) {
6436 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
6437 PhylogenyMethods.preOrderReId( p7 );
6438 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
6439 p7.getNode( "e" ) );
6440 if ( !r_7.getName().equals( "rott" ) ) {
6443 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6444 p7.getNode( "a" ) );
6445 if ( !r_71.getName().equals( "rott" ) ) {
6448 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6449 p7.getNode( "rott" ) );
6450 if ( !r_72.getName().equals( "rott" ) ) {
6453 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6454 p7.getNode( "a" ) );
6455 if ( !r_73.getName().equals( "rott" ) ) {
6458 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6459 p7.getNode( "rott" ) );
6460 if ( !r_74.getName().equals( "rott" ) ) {
6463 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6464 p7.getNode( "e" ) );
6465 if ( !r_75.getName().equals( "e" ) ) {
6469 catch ( final Exception e ) {
6470 e.printStackTrace( System.out );
6476 private static boolean testHmmscanOutputParser() {
6477 final String test_dir = Test.PATH_TO_TEST_DATA;
6479 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
6480 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ),
6482 INDIVIDUAL_SCORE_CUTOFF.NONE );
6484 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
6485 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ),
6487 INDIVIDUAL_SCORE_CUTOFF.NONE );
6488 final List<Protein> proteins = parser2.parse();
6489 if ( parser2.getProteinsEncountered() != 4 ) {
6492 if ( proteins.size() != 4 ) {
6495 if ( parser2.getDomainsEncountered() != 69 ) {
6498 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
6501 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
6504 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
6507 final Protein p1 = proteins.get( 0 );
6508 if ( p1.getNumberOfProteinDomains() != 15 ) {
6511 if ( p1.getLength() != 850 ) {
6514 final Protein p2 = proteins.get( 1 );
6515 if ( p2.getNumberOfProteinDomains() != 51 ) {
6518 if ( p2.getLength() != 1291 ) {
6521 final Protein p3 = proteins.get( 2 );
6522 if ( p3.getNumberOfProteinDomains() != 2 ) {
6525 final Protein p4 = proteins.get( 3 );
6526 if ( p4.getNumberOfProteinDomains() != 1 ) {
6529 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
6532 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
6535 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
6538 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
6541 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
6544 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
6547 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
6551 catch ( final Exception e ) {
6552 e.printStackTrace( System.out );
6558 private static boolean testLastExternalNodeMethods() {
6560 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6561 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
6562 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
6563 final PhylogenyNode n1 = t0.getNode( "A" );
6564 if ( n1.isLastExternalNode() ) {
6567 final PhylogenyNode n2 = t0.getNode( "B" );
6568 if ( n2.isLastExternalNode() ) {
6571 final PhylogenyNode n3 = t0.getNode( "C" );
6572 if ( n3.isLastExternalNode() ) {
6575 final PhylogenyNode n4 = t0.getNode( "D" );
6576 if ( !n4.isLastExternalNode() ) {
6580 catch ( final Exception e ) {
6581 e.printStackTrace( System.out );
6587 private static boolean testLevelOrderIterator() {
6589 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6590 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
6591 PhylogenyNodeIterator it0;
6592 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
6595 for( it0.reset(); it0.hasNext(); ) {
6598 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
6599 if ( !it.next().getName().equals( "r" ) ) {
6602 if ( !it.next().getName().equals( "ab" ) ) {
6605 if ( !it.next().getName().equals( "cd" ) ) {
6608 if ( !it.next().getName().equals( "A" ) ) {
6611 if ( !it.next().getName().equals( "B" ) ) {
6614 if ( !it.next().getName().equals( "C" ) ) {
6617 if ( !it.next().getName().equals( "D" ) ) {
6620 if ( it.hasNext() ) {
6623 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",
6624 new NHXParser() )[ 0 ];
6625 PhylogenyNodeIterator it2;
6626 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
6629 for( it2.reset(); it2.hasNext(); ) {
6632 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
6633 if ( !it3.next().getName().equals( "r" ) ) {
6636 if ( !it3.next().getName().equals( "abc" ) ) {
6639 if ( !it3.next().getName().equals( "defg" ) ) {
6642 if ( !it3.next().getName().equals( "A" ) ) {
6645 if ( !it3.next().getName().equals( "B" ) ) {
6648 if ( !it3.next().getName().equals( "C" ) ) {
6651 if ( !it3.next().getName().equals( "D" ) ) {
6654 if ( !it3.next().getName().equals( "E" ) ) {
6657 if ( !it3.next().getName().equals( "F" ) ) {
6660 if ( !it3.next().getName().equals( "G" ) ) {
6663 if ( !it3.next().getName().equals( "1" ) ) {
6666 if ( !it3.next().getName().equals( "2" ) ) {
6669 if ( !it3.next().getName().equals( "3" ) ) {
6672 if ( !it3.next().getName().equals( "4" ) ) {
6675 if ( !it3.next().getName().equals( "5" ) ) {
6678 if ( !it3.next().getName().equals( "6" ) ) {
6681 if ( !it3.next().getName().equals( "f1" ) ) {
6684 if ( !it3.next().getName().equals( "f2" ) ) {
6687 if ( !it3.next().getName().equals( "f3" ) ) {
6690 if ( !it3.next().getName().equals( "a" ) ) {
6693 if ( !it3.next().getName().equals( "b" ) ) {
6696 if ( !it3.next().getName().equals( "f21" ) ) {
6699 if ( !it3.next().getName().equals( "X" ) ) {
6702 if ( !it3.next().getName().equals( "Y" ) ) {
6705 if ( !it3.next().getName().equals( "Z" ) ) {
6708 if ( it3.hasNext() ) {
6711 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
6712 PhylogenyNodeIterator it4;
6713 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
6716 for( it4.reset(); it4.hasNext(); ) {
6719 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
6720 if ( !it5.next().getName().equals( "r" ) ) {
6723 if ( !it5.next().getName().equals( "A" ) ) {
6726 if ( !it5.next().getName().equals( "B" ) ) {
6729 if ( !it5.next().getName().equals( "C" ) ) {
6732 if ( !it5.next().getName().equals( "D" ) ) {
6735 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
6736 PhylogenyNodeIterator it6;
6737 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
6740 for( it6.reset(); it6.hasNext(); ) {
6743 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
6744 if ( !it7.next().getName().equals( "A" ) ) {
6747 if ( it.hasNext() ) {
6751 catch ( final Exception e ) {
6752 e.printStackTrace( System.out );
6758 private static boolean testMafft( final String path ) {
6760 final List<String> opts = new ArrayList<String>();
6761 opts.add( "--maxiterate" );
6763 opts.add( "--localpair" );
6764 opts.add( "--quiet" );
6766 final MsaInferrer mafft = Mafft.createInstance( path );
6767 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
6768 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
6771 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
6775 catch ( final Exception e ) {
6776 e.printStackTrace( System.out );
6782 private static boolean testMidpointrooting() {
6784 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6785 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
6786 PhylogenyMethods.midpointRoot( t0 );
6787 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6790 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6793 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6797 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",
6798 new NHXParser() )[ 0 ];
6799 if ( !t1.isRooted() ) {
6802 PhylogenyMethods.midpointRoot( t1 );
6803 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6806 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6809 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6812 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6815 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6818 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6821 t1.reRoot( t1.getNode( "A" ) );
6822 PhylogenyMethods.midpointRoot( t1 );
6823 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6826 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6829 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6832 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6835 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6839 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6843 catch ( final Exception e ) {
6844 e.printStackTrace( System.out );
6850 private static boolean testMsaQualityMethod() {
6852 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6853 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6854 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6855 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6856 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6861 final Msa msa = BasicMsa.createInstance( l );
6862 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6865 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6868 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6871 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6874 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6877 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6880 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6884 catch ( final Exception e ) {
6885 e.printStackTrace( System.out );
6891 private static boolean testMsaEntropy() {
6893 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6894 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6895 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6896 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6897 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6902 final Msa msa = BasicMsa.createInstance( l );
6903 //TODO need to DO the tests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6905 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6906 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6907 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6908 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6909 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6910 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6911 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6912 // System.out.println();
6913 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6914 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6915 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6916 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6917 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6918 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6919 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6920 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6921 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6922 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6923 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6924 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6925 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6926 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6927 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6928 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6929 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6930 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6931 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6932 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6933 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6934 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6935 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6936 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6937 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6938 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6939 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6940 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6941 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6942 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6943 final Msa msa2 = BasicMsa.createInstance( l2 );
6944 // System.out.println();
6945 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6946 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6947 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6949 catch ( final Exception e ) {
6950 e.printStackTrace( System.out );
6956 private static boolean testDeleteableMsa() {
6958 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6959 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6960 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6961 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6962 final MolecularSequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6963 final MolecularSequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6964 final List<MolecularSequence> l0 = new ArrayList<MolecularSequence>();
6971 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6972 dmsa0.deleteRow( "b", false );
6973 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6976 dmsa0.deleteRow( "e", false );
6977 dmsa0.deleteRow( "a", false );
6978 dmsa0.deleteRow( "f", false );
6979 if ( dmsa0.getLength() != 4 ) {
6982 if ( dmsa0.getNumberOfSequences() != 2 ) {
6985 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6988 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6991 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6994 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6997 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
7000 dmsa0.deleteRow( "c", false );
7001 dmsa0.deleteRow( "d", false );
7002 if ( dmsa0.getNumberOfSequences() != 0 ) {
7006 final MolecularSequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
7007 final MolecularSequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
7008 final MolecularSequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
7009 final MolecularSequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
7010 final MolecularSequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
7011 final MolecularSequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
7012 final List<MolecularSequence> l1 = new ArrayList<MolecularSequence>();
7019 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
7020 dmsa1.deleteGapOnlyColumns();
7021 dmsa1.deleteRow( "a", false );
7022 dmsa1.deleteRow( "f", false );
7023 dmsa1.deleteRow( "d", false );
7024 dmsa1.deleteGapOnlyColumns();
7025 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
7028 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
7031 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
7034 dmsa1.deleteRow( "c", false );
7035 dmsa1.deleteGapOnlyColumns();
7036 final Writer w0 = new StringWriter();
7037 dmsa1.write( w0, MSA_FORMAT.FASTA );
7038 final Writer w1 = new StringWriter();
7039 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
7040 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
7043 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
7046 final MolecularSequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
7047 final MolecularSequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
7048 final MolecularSequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
7049 final MolecularSequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
7050 final MolecularSequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
7051 final MolecularSequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
7052 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
7059 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
7060 dmsa2.deleteGapColumns( 0.5 );
7061 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
7064 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
7067 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
7070 dmsa2.deleteGapColumns( 0.2 );
7071 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
7074 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
7077 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
7080 dmsa2.deleteGapColumns( 0 );
7081 dmsa2.deleteRow( "a", false );
7082 dmsa2.deleteRow( "b", false );
7083 dmsa2.deleteRow( "f", false );
7084 dmsa2.deleteRow( "e", false );
7085 dmsa2.setIdentifier( 0, "new_c" );
7086 dmsa2.setIdentifier( 1, "new_d" );
7087 dmsa2.setResidueAt( 0, 0, 'x' );
7088 final MolecularSequence s = dmsa2.deleteRow( "new_d", true );
7089 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
7092 final Writer w = new StringWriter();
7093 dmsa2.write( w, MSA_FORMAT.PHYLIP );
7094 final String phylip = w.toString();
7095 if ( !phylip.equals( "1 1" + ForesterUtil.LINE_SEPARATOR + "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
7096 System.out.println( phylip );
7099 final Writer w2 = new StringWriter();
7100 dmsa2.write( w2, MSA_FORMAT.FASTA );
7101 final String fasta = w2.toString();
7102 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
7103 System.out.println( fasta );
7107 catch ( final Exception e ) {
7108 e.printStackTrace( System.out );
7114 private static boolean testNextNodeWithCollapsing() {
7116 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7118 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
7119 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7120 final Phylogeny t0 = factory.create( sb0.toString(), new NHXParser() )[ 0 ];
7121 t0.getNode( "cd" ).setCollapse( true );
7122 t0.getNode( "cde" ).setCollapse( true );
7123 n = t0.getFirstExternalNode();
7124 while ( n != null ) {
7126 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7128 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7131 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7134 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
7137 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
7140 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
7143 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
7147 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7148 final Phylogeny t1 = factory.create( sb1.toString(), new NHXParser() )[ 0 ];
7149 t1.getNode( "ab" ).setCollapse( true );
7150 t1.getNode( "cd" ).setCollapse( true );
7151 t1.getNode( "cde" ).setCollapse( true );
7152 n = t1.getNode( "ab" );
7153 ext = new ArrayList<PhylogenyNode>();
7154 while ( n != null ) {
7156 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7158 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7161 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7164 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
7167 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
7170 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
7174 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7175 final Phylogeny t2 = factory.create( sb2.toString(), new NHXParser() )[ 0 ];
7176 t2.getNode( "ab" ).setCollapse( true );
7177 t2.getNode( "cd" ).setCollapse( true );
7178 t2.getNode( "cde" ).setCollapse( true );
7179 t2.getNode( "c" ).setCollapse( true );
7180 t2.getNode( "d" ).setCollapse( true );
7181 t2.getNode( "e" ).setCollapse( true );
7182 t2.getNode( "gh" ).setCollapse( true );
7183 n = t2.getNode( "ab" );
7184 ext = new ArrayList<PhylogenyNode>();
7185 while ( n != null ) {
7187 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7189 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7192 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7195 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
7198 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
7202 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7203 final Phylogeny t3 = factory.create( sb3.toString(), new NHXParser() )[ 0 ];
7204 t3.getNode( "ab" ).setCollapse( true );
7205 t3.getNode( "cd" ).setCollapse( true );
7206 t3.getNode( "cde" ).setCollapse( true );
7207 t3.getNode( "c" ).setCollapse( true );
7208 t3.getNode( "d" ).setCollapse( true );
7209 t3.getNode( "e" ).setCollapse( true );
7210 t3.getNode( "gh" ).setCollapse( true );
7211 t3.getNode( "fgh" ).setCollapse( true );
7212 n = t3.getNode( "ab" );
7213 ext = new ArrayList<PhylogenyNode>();
7214 while ( n != null ) {
7216 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7218 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7221 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7224 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
7228 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7229 final Phylogeny t4 = factory.create( sb4.toString(), new NHXParser() )[ 0 ];
7230 t4.getNode( "ab" ).setCollapse( true );
7231 t4.getNode( "cd" ).setCollapse( true );
7232 t4.getNode( "cde" ).setCollapse( true );
7233 t4.getNode( "c" ).setCollapse( true );
7234 t4.getNode( "d" ).setCollapse( true );
7235 t4.getNode( "e" ).setCollapse( true );
7236 t4.getNode( "gh" ).setCollapse( true );
7237 t4.getNode( "fgh" ).setCollapse( true );
7238 t4.getNode( "abcdefgh" ).setCollapse( true );
7239 n = t4.getNode( "abcdefgh" );
7240 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
7243 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7244 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
7246 n = t5.getFirstExternalNode();
7247 while ( n != null ) {
7249 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7251 if ( ext.size() != 8 ) {
7254 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7257 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7260 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7263 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7266 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7269 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7272 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
7275 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
7278 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7279 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
7281 t6.getNode( "ab" ).setCollapse( true );
7282 n = t6.getNode( "ab" );
7283 while ( n != null ) {
7285 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7287 if ( ext.size() != 7 ) {
7290 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7293 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7296 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7299 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7302 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7305 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7308 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7311 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7312 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
7314 t7.getNode( "cd" ).setCollapse( true );
7315 n = t7.getNode( "a" );
7316 while ( n != null ) {
7318 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7320 if ( ext.size() != 7 ) {
7323 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7326 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7329 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7332 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7335 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7338 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7341 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7344 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7345 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
7347 t8.getNode( "cd" ).setCollapse( true );
7348 t8.getNode( "c" ).setCollapse( true );
7349 t8.getNode( "d" ).setCollapse( true );
7350 n = t8.getNode( "a" );
7351 while ( n != null ) {
7353 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7355 if ( ext.size() != 7 ) {
7358 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7361 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7364 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7365 System.out.println( "2 fail" );
7368 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7371 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7374 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7377 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7380 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7381 final Phylogeny t9 = factory.create( sb9.toString(), new NHXParser() )[ 0 ];
7383 t9.getNode( "gh" ).setCollapse( true );
7384 n = t9.getNode( "a" );
7385 while ( n != null ) {
7387 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7389 if ( ext.size() != 7 ) {
7392 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7395 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7398 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7401 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7404 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7407 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7410 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7413 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7414 final Phylogeny t10 = factory.create( sb10.toString(), new NHXParser() )[ 0 ];
7416 t10.getNode( "gh" ).setCollapse( true );
7417 t10.getNode( "g" ).setCollapse( true );
7418 t10.getNode( "h" ).setCollapse( true );
7419 n = t10.getNode( "a" );
7420 while ( n != null ) {
7422 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7424 if ( ext.size() != 7 ) {
7427 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7430 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7433 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7436 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7439 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7442 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7445 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7448 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7449 final Phylogeny t11 = factory.create( sb11.toString(), new NHXParser() )[ 0 ];
7451 t11.getNode( "gh" ).setCollapse( true );
7452 t11.getNode( "fgh" ).setCollapse( true );
7453 n = t11.getNode( "a" );
7454 while ( n != null ) {
7456 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7458 if ( ext.size() != 6 ) {
7461 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7464 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7467 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7470 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7473 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7476 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7479 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7480 final Phylogeny t12 = factory.create( sb12.toString(), new NHXParser() )[ 0 ];
7482 t12.getNode( "gh" ).setCollapse( true );
7483 t12.getNode( "fgh" ).setCollapse( true );
7484 t12.getNode( "g" ).setCollapse( true );
7485 t12.getNode( "h" ).setCollapse( true );
7486 t12.getNode( "f" ).setCollapse( true );
7487 n = t12.getNode( "a" );
7488 while ( n != null ) {
7490 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7492 if ( ext.size() != 6 ) {
7495 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7498 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7501 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7504 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7507 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7510 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7513 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7514 final Phylogeny t13 = factory.create( sb13.toString(), new NHXParser() )[ 0 ];
7516 t13.getNode( "ab" ).setCollapse( true );
7517 t13.getNode( "b" ).setCollapse( true );
7518 t13.getNode( "fgh" ).setCollapse( true );
7519 t13.getNode( "gh" ).setCollapse( true );
7520 n = t13.getNode( "ab" );
7521 while ( n != null ) {
7523 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7525 if ( ext.size() != 5 ) {
7528 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7531 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7534 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7537 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7540 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7543 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
7544 final Phylogeny t14 = factory.create( sb14.toString(), new NHXParser() )[ 0 ];
7546 t14.getNode( "ab" ).setCollapse( true );
7547 t14.getNode( "a" ).setCollapse( true );
7548 t14.getNode( "fgh" ).setCollapse( true );
7549 t14.getNode( "gh" ).setCollapse( true );
7550 n = t14.getNode( "ab" );
7551 while ( n != null ) {
7553 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7555 if ( ext.size() != 5 ) {
7558 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7561 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7564 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7567 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7570 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7573 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" );
7574 final Phylogeny t15 = factory.create( sb15.toString(), new NHXParser() )[ 0 ];
7576 t15.getNode( "ab" ).setCollapse( true );
7577 t15.getNode( "a" ).setCollapse( true );
7578 t15.getNode( "fgh" ).setCollapse( true );
7579 t15.getNode( "gh" ).setCollapse( true );
7580 n = t15.getNode( "ab" );
7581 while ( n != null ) {
7583 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7585 if ( ext.size() != 6 ) {
7588 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7591 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7594 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7597 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7600 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
7603 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7608 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" );
7609 final Phylogeny t16 = factory.create( sb16.toString(), new NHXParser() )[ 0 ];
7611 t16.getNode( "ab" ).setCollapse( true );
7612 t16.getNode( "a" ).setCollapse( true );
7613 t16.getNode( "fgh" ).setCollapse( true );
7614 t16.getNode( "gh" ).setCollapse( true );
7615 t16.getNode( "cd" ).setCollapse( true );
7616 t16.getNode( "cde" ).setCollapse( true );
7617 t16.getNode( "d" ).setCollapse( true );
7618 t16.getNode( "x" ).setCollapse( true );
7619 n = t16.getNode( "ab" );
7620 while ( n != null ) {
7622 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7624 if ( ext.size() != 4 ) {
7627 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7630 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7633 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
7636 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
7640 catch ( final Exception e ) {
7641 e.printStackTrace( System.out );
7647 private static boolean testNexusCharactersParsing() {
7649 final NexusCharactersParser parser = new NexusCharactersParser();
7650 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
7652 String[] labels = parser.getCharStateLabels();
7653 if ( labels.length != 7 ) {
7656 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7659 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7662 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7665 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7668 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7671 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7674 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7677 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7679 labels = parser.getCharStateLabels();
7680 if ( labels.length != 7 ) {
7683 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7686 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7689 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7692 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7695 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7698 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7701 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7705 catch ( final Exception e ) {
7706 e.printStackTrace( System.out );
7712 private static boolean testNexusMatrixParsing() {
7714 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
7715 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
7717 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
7718 if ( m.getNumberOfCharacters() != 9 ) {
7721 if ( m.getNumberOfIdentifiers() != 5 ) {
7724 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
7727 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
7730 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
7733 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
7736 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
7739 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
7742 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
7745 // if ( labels.length != 7 ) {
7748 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7751 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7754 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7757 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7760 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7763 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7766 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7769 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7771 // labels = parser.getCharStateLabels();
7772 // if ( labels.length != 7 ) {
7775 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7778 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7781 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7784 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7787 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7790 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7793 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7797 catch ( final Exception e ) {
7798 e.printStackTrace( System.out );
7804 private static boolean testNexusTreeParsing() {
7806 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7807 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7808 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7809 if ( phylogenies.length != 1 ) {
7812 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7815 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7819 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7820 if ( phylogenies.length != 1 ) {
7823 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7826 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7830 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7831 if ( phylogenies.length != 1 ) {
7834 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7837 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7840 if ( phylogenies[ 0 ].isRooted() ) {
7844 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7845 if ( phylogenies.length != 18 ) {
7848 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7851 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7854 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7857 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7860 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7863 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7866 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7869 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7872 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7875 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7878 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7881 if ( phylogenies[ 8 ].isRooted() ) {
7884 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7887 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7890 if ( !phylogenies[ 9 ].isRooted() ) {
7893 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7896 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7899 if ( !phylogenies[ 10 ].isRooted() ) {
7902 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7905 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7908 if ( phylogenies[ 11 ].isRooted() ) {
7911 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7914 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7917 if ( !phylogenies[ 12 ].isRooted() ) {
7920 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7923 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7926 if ( !phylogenies[ 13 ].isRooted() ) {
7929 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7932 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7935 if ( !phylogenies[ 14 ].isRooted() ) {
7938 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7941 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7944 if ( phylogenies[ 15 ].isRooted() ) {
7947 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7950 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7953 if ( !phylogenies[ 16 ].isRooted() ) {
7956 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7959 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7962 if ( phylogenies[ 17 ].isRooted() ) {
7965 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7968 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7970 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7971 if ( phylogenies.length != 9 ) {
7974 if ( !isEqual( 0.48039661496919533,
7975 phylogenies[ 0 ].getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7978 if ( !isEqual( 0.3959796191512233,
7979 phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7982 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7985 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7988 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7991 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7994 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7998 catch ( final Exception e ) {
7999 e.printStackTrace( System.out );
8005 private static boolean testNexusTreeParsingIterating() {
8007 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
8008 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
8009 if ( !p.hasNext() ) {
8012 Phylogeny phy = p.next();
8013 if ( phy == null ) {
8016 if ( phy.getNumberOfExternalNodes() != 25 ) {
8019 if ( !phy.getName().equals( "" ) ) {
8022 if ( p.hasNext() ) {
8026 if ( phy != null ) {
8030 if ( !p.hasNext() ) {
8034 if ( phy == null ) {
8037 if ( phy.getNumberOfExternalNodes() != 25 ) {
8040 if ( !phy.getName().equals( "" ) ) {
8043 if ( p.hasNext() ) {
8047 if ( phy != null ) {
8050 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
8051 if ( !p.hasNext() ) {
8055 if ( phy == null ) {
8058 if ( phy.getNumberOfExternalNodes() != 10 ) {
8061 if ( !phy.getName().equals( "name" ) ) {
8064 if ( p.hasNext() ) {
8068 if ( phy != null ) {
8072 if ( !p.hasNext() ) {
8076 if ( phy == null ) {
8079 if ( phy.getNumberOfExternalNodes() != 10 ) {
8082 if ( !phy.getName().equals( "name" ) ) {
8085 if ( p.hasNext() ) {
8089 if ( phy != null ) {
8092 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
8093 if ( !p.hasNext() ) {
8097 if ( phy == null ) {
8100 if ( phy.getNumberOfExternalNodes() != 3 ) {
8103 if ( !phy.getName().equals( "" ) ) {
8106 if ( phy.isRooted() ) {
8109 if ( p.hasNext() ) {
8113 if ( phy != null ) {
8118 if ( !p.hasNext() ) {
8122 if ( phy == null ) {
8125 if ( phy.getNumberOfExternalNodes() != 3 ) {
8128 if ( !phy.getName().equals( "" ) ) {
8131 if ( p.hasNext() ) {
8135 if ( phy != null ) {
8139 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
8140 if ( !p.hasNext() ) {
8145 if ( phy == null ) {
8148 if ( phy.getNumberOfExternalNodes() != 10 ) {
8151 if ( !phy.getName().equals( "tree 0" ) ) {
8155 if ( !p.hasNext() ) {
8159 if ( phy == null ) {
8162 if ( phy.getNumberOfExternalNodes() != 10 ) {
8165 if ( !phy.getName().equals( "tree 1" ) ) {
8169 if ( !p.hasNext() ) {
8173 if ( phy == null ) {
8176 if ( phy.getNumberOfExternalNodes() != 3 ) {
8177 System.out.println( phy.toString() );
8180 if ( !phy.getName().equals( "" ) ) {
8183 if ( phy.isRooted() ) {
8187 if ( !p.hasNext() ) {
8191 if ( phy == null ) {
8194 if ( phy.getNumberOfExternalNodes() != 4 ) {
8197 if ( !phy.getName().equals( "" ) ) {
8200 if ( !phy.isRooted() ) {
8204 if ( !p.hasNext() ) {
8208 if ( phy == null ) {
8211 if ( phy.getNumberOfExternalNodes() != 5 ) {
8212 System.out.println( phy.getNumberOfExternalNodes() );
8215 if ( !phy.getName().equals( "" ) ) {
8218 if ( !phy.isRooted() ) {
8222 if ( !p.hasNext() ) {
8226 if ( phy == null ) {
8229 if ( phy.getNumberOfExternalNodes() != 3 ) {
8232 if ( !phy.getName().equals( "" ) ) {
8235 if ( phy.isRooted() ) {
8239 if ( !p.hasNext() ) {
8243 if ( phy == null ) {
8246 if ( phy.getNumberOfExternalNodes() != 2 ) {
8249 if ( !phy.getName().equals( "" ) ) {
8252 if ( !phy.isRooted() ) {
8256 if ( !p.hasNext() ) {
8260 if ( phy.getNumberOfExternalNodes() != 3 ) {
8263 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8266 if ( !phy.isRooted() ) {
8270 if ( !p.hasNext() ) {
8274 if ( phy.getNumberOfExternalNodes() != 3 ) {
8277 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
8280 if ( !phy.getName().equals( "tree 8" ) ) {
8284 if ( !p.hasNext() ) {
8288 if ( phy.getNumberOfExternalNodes() != 3 ) {
8291 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
8294 if ( !phy.getName().equals( "tree 9" ) ) {
8298 if ( !p.hasNext() ) {
8302 if ( phy.getNumberOfExternalNodes() != 3 ) {
8305 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8308 if ( !phy.getName().equals( "tree 10" ) ) {
8311 if ( !phy.isRooted() ) {
8315 if ( !p.hasNext() ) {
8319 if ( phy.getNumberOfExternalNodes() != 3 ) {
8322 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
8325 if ( !phy.getName().equals( "tree 11" ) ) {
8328 if ( phy.isRooted() ) {
8332 if ( !p.hasNext() ) {
8336 if ( phy.getNumberOfExternalNodes() != 3 ) {
8339 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
8342 if ( !phy.getName().equals( "tree 12" ) ) {
8345 if ( !phy.isRooted() ) {
8349 if ( !p.hasNext() ) {
8353 if ( phy.getNumberOfExternalNodes() != 3 ) {
8356 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8359 if ( !phy.getName().equals( "tree 13" ) ) {
8362 if ( !phy.isRooted() ) {
8366 if ( !p.hasNext() ) {
8370 if ( phy.getNumberOfExternalNodes() != 10 ) {
8371 System.out.println( phy.getNumberOfExternalNodes() );
8374 if ( !phy.toNewHampshire()
8375 .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;" ) ) {
8376 System.out.println( phy.toNewHampshire() );
8379 if ( !phy.getName().equals( "tree 14" ) ) {
8382 if ( !phy.isRooted() ) {
8386 if ( !p.hasNext() ) {
8390 if ( phy.getNumberOfExternalNodes() != 10 ) {
8391 System.out.println( phy.getNumberOfExternalNodes() );
8394 if ( !phy.toNewHampshire()
8395 .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;" ) ) {
8396 System.out.println( phy.toNewHampshire() );
8399 if ( !phy.getName().equals( "tree 15" ) ) {
8402 if ( phy.isRooted() ) {
8406 if ( !p.hasNext() ) {
8410 if ( phy.getNumberOfExternalNodes() != 10 ) {
8411 System.out.println( phy.getNumberOfExternalNodes() );
8414 if ( !phy.toNewHampshire()
8415 .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;" ) ) {
8416 System.out.println( phy.toNewHampshire() );
8419 if ( !phy.getName().equals( "tree 16" ) ) {
8422 if ( !phy.isRooted() ) {
8426 if ( !p.hasNext() ) {
8430 if ( phy.getNumberOfExternalNodes() != 10 ) {
8431 System.out.println( phy.getNumberOfExternalNodes() );
8434 if ( !phy.toNewHampshire()
8435 .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;" ) ) {
8436 System.out.println( phy.toNewHampshire() );
8439 if ( !phy.getName().equals( "tree 17" ) ) {
8442 if ( phy.isRooted() ) {
8446 if ( p.hasNext() ) {
8450 if ( phy != null ) {
8455 if ( !p.hasNext() ) {
8459 if ( phy == null ) {
8462 if ( phy.getNumberOfExternalNodes() != 10 ) {
8465 if ( !phy.getName().equals( "tree 0" ) ) {
8469 if ( !p.hasNext() ) {
8473 if ( phy == null ) {
8476 if ( phy.getNumberOfExternalNodes() != 10 ) {
8479 if ( !phy.getName().equals( "tree 1" ) ) {
8483 if ( !p.hasNext() ) {
8487 if ( phy == null ) {
8490 if ( phy.getNumberOfExternalNodes() != 3 ) {
8493 if ( !phy.getName().equals( "" ) ) {
8496 if ( phy.isRooted() ) {
8500 if ( !p.hasNext() ) {
8504 if ( phy == null ) {
8507 if ( phy.getNumberOfExternalNodes() != 4 ) {
8510 if ( !phy.getName().equals( "" ) ) {
8513 if ( !phy.isRooted() ) {
8517 if ( !p.hasNext() ) {
8521 if ( phy == null ) {
8524 if ( phy.getNumberOfExternalNodes() != 5 ) {
8525 System.out.println( phy.getNumberOfExternalNodes() );
8528 if ( !phy.getName().equals( "" ) ) {
8531 if ( !phy.isRooted() ) {
8535 if ( !p.hasNext() ) {
8539 if ( phy == null ) {
8542 if ( phy.getNumberOfExternalNodes() != 3 ) {
8545 if ( !phy.getName().equals( "" ) ) {
8548 if ( phy.isRooted() ) {
8552 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
8553 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
8555 if ( !p2.hasNext() ) {
8559 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8562 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8566 if ( !p2.hasNext() ) {
8571 if ( !p2.hasNext() ) {
8576 if ( !p2.hasNext() ) {
8581 if ( !p2.hasNext() ) {
8586 if ( !p2.hasNext() ) {
8591 if ( !p2.hasNext() ) {
8596 if ( !p2.hasNext() ) {
8601 if ( !p2.hasNext() ) {
8605 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
8608 if ( p2.hasNext() ) {
8612 if ( phy != null ) {
8617 if ( !p2.hasNext() ) {
8621 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8624 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8628 catch ( final Exception e ) {
8629 e.printStackTrace( System.out );
8635 private static boolean testNexusTreeParsingTranslating() {
8637 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8638 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
8639 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
8640 if ( phylogenies.length != 1 ) {
8643 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8646 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8649 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8652 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8655 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8656 .equals( "Aranaeus" ) ) {
8660 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
8661 if ( phylogenies.length != 3 ) {
8664 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8667 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8670 if ( phylogenies[ 0 ].isRooted() ) {
8673 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8676 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8679 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8680 .equals( "Aranaeus" ) ) {
8683 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8686 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8689 if ( phylogenies[ 1 ].isRooted() ) {
8692 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8695 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8698 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8699 .equals( "Aranaeus" ) ) {
8702 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8705 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8708 if ( !phylogenies[ 2 ].isRooted() ) {
8711 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8714 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8717 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8718 .equals( "Aranaeus" ) ) {
8722 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
8723 if ( phylogenies.length != 3 ) {
8726 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8729 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8732 if ( phylogenies[ 0 ].isRooted() ) {
8735 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8738 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8741 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8742 .equals( "Aranaeus" ) ) {
8745 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8748 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8751 if ( phylogenies[ 1 ].isRooted() ) {
8754 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8757 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8760 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8761 .equals( "Aranaeus" ) ) {
8764 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8767 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8770 if ( !phylogenies[ 2 ].isRooted() ) {
8773 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8776 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8779 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8780 .equals( "Aranaeus" ) ) {
8783 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8784 if ( phylogenies.length != 3 ) {
8787 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8792 catch ( final Exception e ) {
8793 e.printStackTrace( System.out );
8799 private static boolean testNHParsing() {
8801 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8802 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8803 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8806 final NHXParser nhxp = new NHXParser();
8807 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8808 nhxp.setReplaceUnderscores( true );
8809 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8810 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8813 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8816 final Phylogeny p1b = factory.create(
8817 " \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 ",
8818 new NHXParser() )[ 0 ];
8819 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8822 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8825 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ).toString(), new NHXParser() )[ 0 ];
8826 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8827 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8828 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ).toString(), new NHXParser() )[ 0 ];
8829 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8830 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8831 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8832 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8833 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8834 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8835 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8836 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; " + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8838 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8841 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8844 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8847 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8850 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8851 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8852 final String p16_S = "((A,B),C)";
8853 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8854 if ( p16.length != 1 ) {
8857 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8860 final String p17_S = "(C,(A,B))";
8861 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8862 if ( p17.length != 1 ) {
8865 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8868 final String p18_S = "((A,B),(C,D))";
8869 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8870 if ( p18.length != 1 ) {
8873 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8876 final String p19_S = "(((A,B),C),D)";
8877 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8878 if ( p19.length != 1 ) {
8881 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8884 final String p20_S = "(A,(B,(C,D)))";
8885 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8886 if ( p20.length != 1 ) {
8889 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8892 final String p21_S = "(A,(B,(C,(D,E))))";
8893 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8894 if ( p21.length != 1 ) {
8897 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8900 final String p22_S = "((((A,B),C),D),E)";
8901 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8902 if ( p22.length != 1 ) {
8905 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8908 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8909 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8910 if ( p23.length != 1 ) {
8911 System.out.println( "xl=" + p23.length );
8915 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8918 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8919 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8920 if ( p24.length != 1 ) {
8923 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8926 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8927 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8928 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8929 if ( p241.length != 2 ) {
8932 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8935 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8938 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8939 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8940 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8941 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8942 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8943 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8944 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8945 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8946 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8947 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8950 final String p26_S = "(A,B)ab";
8951 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8952 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8955 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8956 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8957 if ( p27s.length != 1 ) {
8958 System.out.println( "xxl=" + p27s.length );
8962 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8963 System.out.println( p27s[ 0 ].toNewHampshireX() );
8967 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8969 if ( p27.length != 1 ) {
8970 System.out.println( "yl=" + p27.length );
8974 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8975 System.out.println( p27[ 0 ].toNewHampshireX() );
8979 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8980 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8981 final String p28_S3 = "(A,B)ab";
8982 final String p28_S4 = "((((A,B),C),D),;E;)";
8983 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8985 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8988 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8991 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8994 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8997 if ( p28.length != 4 ) {
9000 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";
9001 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
9002 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
9005 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";
9006 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
9007 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
9010 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
9011 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
9012 if ( ( p32.length != 0 ) ) {
9015 final String p33_S = "A";
9016 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
9017 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
9020 final String p34_S = "B;";
9021 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
9022 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
9025 final String p35_S = "B:0.2";
9026 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
9027 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
9030 final String p36_S = "(A)";
9031 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
9032 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
9035 final String p37_S = "((A))";
9036 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
9037 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
9040 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
9041 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
9042 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
9045 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
9046 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
9047 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
9050 final String p40_S = "(A,B,C)";
9051 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
9052 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
9055 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
9056 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
9057 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
9060 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
9061 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
9062 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
9065 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)";
9066 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
9067 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
9070 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)))";
9071 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
9072 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
9075 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
9076 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
9077 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
9080 final String p46_S = "";
9081 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
9082 if ( p46.length != 0 ) {
9085 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ).toString(),
9086 new NHXParser() )[ 0 ];
9087 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
9090 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ).toString(),
9091 new NHXParser() )[ 0 ];
9092 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
9095 final Phylogeny p49 = factory
9096 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ).toString(),
9097 new NHXParser() )[ 0 ];
9098 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
9101 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ).toString(),
9102 new NHXParser() )[ 0 ];
9103 if ( p50.getNode( "A" ) == null ) {
9106 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9107 .equals( "((A,B)ab:2.0[88],C);" ) ) {
9110 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
9113 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
9114 .equals( "((A,B)88:2.0,C);" ) ) {
9117 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ).toString(),
9118 new NHXParser() )[ 0 ];
9119 if ( p51.getNode( "A(A" ) == null ) {
9122 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ).toString(),
9123 new NHXParser() )[ 0 ];
9124 if ( p52.getNode( "A(A" ) == null ) {
9127 final Phylogeny p53 = factory
9128 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ).toString(),
9129 new NHXParser() )[ 0 ];
9130 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
9133 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ).toString(),
9134 new NHXParser() )[ 0 ];
9135 if ( p54.getNode( "A" ) == null ) {
9138 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9139 .equals( "((A,B)[88],C);" ) ) {
9142 final Phylogeny p55 = factory
9143 .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);" )
9144 .toString(), new NHXParser() )[ 0 ];
9145 if ( !p55.toNewHampshire()
9146 .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);" ) ) {
9147 System.out.println( p55.toNewHampshire() );
9150 final Phylogeny p56 = factory
9151 .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);" )
9152 .toString(), new NHXParser() )[ 0 ];
9153 if ( !p56.toNewHampshire()
9154 .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);" ) ) {
9155 System.out.println( p56.toNewHampshire() );
9158 final Phylogeny p57 = factory
9159 .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);" )
9160 .toString(), new NHXParser() )[ 0 ];
9161 if ( !p57.toNewHampshire()
9162 .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);" ) ) {
9163 System.out.println( p56.toNewHampshire() );
9166 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
9167 final Phylogeny p58 = factory.create( s58, new NHXParser() )[ 0 ];
9168 if ( !p58.toNewHampshire().equals( s58 ) ) {
9169 System.out.println( p58.toNewHampshire() );
9172 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
9173 final Phylogeny p59 = factory.create( s59, new NHXParser() )[ 0 ];
9174 if ( !p59.toNewHampshire().equals( s59 ) ) {
9175 System.out.println( p59.toNewHampshire() );
9178 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
9179 final Phylogeny p60 = factory.create( s60, new NHXParser() )[ 0 ];
9180 if ( !p60.toNewHampshire().equals( s60 ) ) {
9181 System.out.println( p60.toNewHampshire() );
9184 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
9185 final Phylogeny p61 = factory.create( s61, new NHXParser() )[ 0 ];
9186 if ( !p61.toNewHampshire()
9187 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
9188 System.out.println( p61.toNewHampshire() );
9191 final String s62 = "(1[&type=\"X\",size=123,subtree=(1,2);]:0.003,2[&type=\"(X,Y:3)\"]:0.004)[&type=\"(X,Y)\"]:0.0;";
9192 final Phylogeny p62 = factory.create( s62, new NHXParser() )[ 0 ];
9193 if ( !p62.toNewHampshire().equals( "(1:0.003,2:0.004):0.0;" ) ) {
9194 System.out.println( p62.toNewHampshire() );
9197 final String s63 = "(1:0.003[&type=\"X\",size=123,subtree=(1,2);],2:0.004[&type=\"(X,Y:3)\"]):0.0[&type=\"(X,Y)\"];";
9198 final Phylogeny p63 = factory.create( s63, new NHXParser() )[ 0 ];
9199 if ( !p63.toNewHampshire().equals( "(1:0.003,2:0.004):0.0;" ) ) {
9200 System.out.println( p63.toNewHampshire() );
9203 final String s64 = "((1,2):[95.5],3);";
9204 final Phylogeny p64 = factory.create( s64, new NHXParser() )[ 0 ];
9205 if ( !p64.toNewHampshireX().equals( "((1,2)[&&NHX:B=95.5],3)" ) ) {
9206 System.out.println( p64.toNewHampshireX() );
9209 final String s65 = "((1:0.1,2:0.2):0.3[10.2],3);";
9210 final Phylogeny p65 = factory.create( s65, new NHXParser() )[ 0 ];
9211 if ( !p65.toNewHampshireX().equals( "((1:0.1,2:0.2):0.3[&&NHX:B=10.2],3)" ) ) {
9212 System.out.println( p65.toNewHampshireX() );
9215 final Phylogeny p66 = factory.create( "((A,B)ab:2[0.44],C)", new NHXParser() )[ 0 ];
9216 if ( !isEqual( 0.44, p66.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
9219 final Phylogeny p67 = factory.create( "((A,B):2[0.67],C)", new NHXParser() )[ 0 ];
9220 if ( !isEqual( 0.67, p67.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9223 final Phylogeny p68 = factory.create( "((A,B):[0.68],C)", new NHXParser() )[ 0 ];
9224 if ( !isEqual( 0.68, p68.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9227 final Phylogeny p69 = factory.create( "((A,B)[0.69],C)", new NHXParser() )[ 0 ];
9228 if ( !isEqual( 0.69, p69.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9231 final Phylogeny p70 = factory.create( "((A,B)[+0.7],C)", new NHXParser() )[ 0 ];
9232 if ( !isEqual( 0.7, p70.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9235 final Phylogeny p71 = factory.create( "((A,B)[-0.71],C)", new NHXParser() )[ 0 ];
9236 if ( !isEqual( -0.71, p71.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9239 final Phylogeny p72 = factory.create( "((A,B)[],C)", new NHXParser() )[ 0 ];
9240 if ( !p72.toNewHampshireX().equals( "((A,B),C)" ) ) {
9243 final Phylogeny p73 = factory.create( "((A,B)[12x],C)", new NHXParser() )[ 0 ];
9244 if ( !p73.toNewHampshireX().equals( "((A,B),C)" ) ) {
9247 final Phylogeny p74 = factory.create( "((A,B)[12+],C)", new NHXParser() )[ 0 ];
9248 if ( !p74.toNewHampshireX().equals( "((A,B),C)" ) ) {
9251 final Phylogeny p75 = factory.create( "((A,B)ab[222]:3,C)", new NHXParser() )[ 0 ];
9252 if ( !isEqual( 222, p75.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9255 final Phylogeny p76 = factory.create( "((A,B)[100]:12,C)", new NHXParser() )[ 0 ];
9256 if ( !isEqual( 100, p76.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9259 final Phylogeny p77 = factory.create( "((A,B)abcde:13[77],C)", new NHXParser() )[ 0 ];
9260 if ( !isEqual( 77, p77.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9263 final Phylogeny p78 = factory.create( "((A,B):14[0],C)", new NHXParser() )[ 0 ];
9264 if ( !isEqual( 0, p78.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9267 final String the_one = "((((((a,b)ab:3.0[2],c):12.0[100],(d,e)de)abcde:13.0[2],f):14.0[0]):0.0[0]):0.0[0];";
9268 final Phylogeny p79 = factory.create(
9269 "((((((a,b)ab[2]:3,c)[100]:12,(d,e)de)abcde:13[2],f):14[0]):0[0])[0]:0;",
9270 new NHXParser() )[ 0 ];
9271 final String str79 = p79.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
9272 if ( !str79.equals( the_one ) ) {
9273 System.out.println( str79 );
9276 final Phylogeny p80 = factory.create(
9277 "((((((a[a)],b[12])ab[2]:3,c)[+100]:12,(d,e)de[12d,)])ab[]c[]de:13[2],f):14[0]):0[0])[0]:0;",
9278 new NHXParser() )[ 0 ];
9279 final String str80 = p80.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
9280 if ( !str80.equals( the_one ) ) {
9281 System.out.println( str80 );
9285 catch ( final Exception e ) {
9286 e.printStackTrace( System.out );
9292 private static boolean testNHParsingSpecialChars() {
9294 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9295 final String i0 = "(A!+=~QWERTY!@#$%^&*-,€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ)";
9296 final Phylogeny p0 = factory.create( i0, new NHXParser() )[ 0 ];
9297 if ( !p0.toNewHampshireX().equals( i0 ) ) {
9298 System.out.println();
9299 System.out.println( p0.toNewHampshireX() );
9300 System.out.println( i0 );
9303 final String i1 = "(हिंदी,한글,ไทย,'Tiếng Việt',ひらがなカタカナ漢字,繁體字,русский)";
9304 final Phylogeny p1 = factory.create( i1, new NHXParser() )[ 0 ];
9305 if ( !p1.toNewHampshireX().equals( i1 ) ) {
9306 System.out.println();
9307 System.out.println( p1.toNewHampshireX() );
9308 System.out.println( i1 );
9312 catch ( final Exception e ) {
9313 e.printStackTrace( System.out );
9319 private static boolean testNHParsingIter() {
9321 final String p0_str = "(A,B);";
9322 final NHXParser p = new NHXParser();
9323 p.setSource( p0_str );
9324 if ( !p.hasNext() ) {
9327 final Phylogeny p0 = p.next();
9328 if ( !p0.toNewHampshire().equals( p0_str ) ) {
9329 System.out.println( p0.toNewHampshire() );
9332 if ( p.hasNext() ) {
9335 if ( p.next() != null ) {
9339 final String p00_str = "(A,B)root;";
9340 p.setSource( p00_str );
9341 final Phylogeny p00 = p.next();
9342 if ( !p00.toNewHampshire().equals( p00_str ) ) {
9343 System.out.println( p00.toNewHampshire() );
9347 final String p000_str = "A;";
9348 p.setSource( p000_str );
9349 final Phylogeny p000 = p.next();
9350 if ( !p000.toNewHampshire().equals( p000_str ) ) {
9351 System.out.println( p000.toNewHampshire() );
9355 final String p0000_str = "A";
9356 p.setSource( p0000_str );
9357 final Phylogeny p0000 = p.next();
9358 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
9359 System.out.println( p0000.toNewHampshire() );
9363 p.setSource( "(A)" );
9364 final Phylogeny p00000 = p.next();
9365 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
9366 System.out.println( p00000.toNewHampshire() );
9370 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
9371 p.setSource( p1_str );
9372 if ( !p.hasNext() ) {
9375 final Phylogeny p1_0 = p.next();
9376 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
9377 System.out.println( p1_0.toNewHampshire() );
9380 if ( !p.hasNext() ) {
9383 final Phylogeny p1_1 = p.next();
9384 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
9385 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
9388 if ( !p.hasNext() ) {
9391 final Phylogeny p1_2 = p.next();
9392 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
9393 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
9396 if ( !p.hasNext() ) {
9399 final Phylogeny p1_3 = p.next();
9400 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
9401 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
9404 if ( p.hasNext() ) {
9407 if ( p.next() != null ) {
9411 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
9412 p.setSource( p2_str );
9413 if ( !p.hasNext() ) {
9416 Phylogeny p2_0 = p.next();
9417 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9418 System.out.println( p2_0.toNewHampshire() );
9421 if ( !p.hasNext() ) {
9424 Phylogeny p2_1 = p.next();
9425 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9426 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9429 if ( !p.hasNext() ) {
9432 Phylogeny p2_2 = p.next();
9433 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9434 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9437 if ( !p.hasNext() ) {
9440 Phylogeny p2_3 = p.next();
9441 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9442 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9445 if ( !p.hasNext() ) {
9448 Phylogeny p2_4 = p.next();
9449 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9450 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9453 if ( p.hasNext() ) {
9456 if ( p.next() != null ) {
9461 if ( !p.hasNext() ) {
9465 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9466 System.out.println( p2_0.toNewHampshire() );
9469 if ( !p.hasNext() ) {
9473 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9474 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9477 if ( !p.hasNext() ) {
9481 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9482 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9485 if ( !p.hasNext() ) {
9489 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9490 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9493 if ( !p.hasNext() ) {
9497 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9498 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9501 if ( p.hasNext() ) {
9504 if ( p.next() != null ) {
9508 final String p3_str = "((A,B),C)abc";
9509 p.setSource( p3_str );
9510 if ( !p.hasNext() ) {
9513 final Phylogeny p3_0 = p.next();
9514 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
9517 if ( p.hasNext() ) {
9520 if ( p.next() != null ) {
9524 final String p4_str = "((A,B)ab,C)abc";
9525 p.setSource( p4_str );
9526 if ( !p.hasNext() ) {
9529 final Phylogeny p4_0 = p.next();
9530 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
9533 if ( p.hasNext() ) {
9536 if ( p.next() != null ) {
9540 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
9541 p.setSource( p5_str );
9542 if ( !p.hasNext() ) {
9545 final Phylogeny p5_0 = p.next();
9546 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
9549 if ( p.hasNext() ) {
9552 if ( p.next() != null ) {
9556 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
9557 p.setSource( p6_str );
9558 if ( !p.hasNext() ) {
9561 Phylogeny p6_0 = p.next();
9562 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9565 if ( p.hasNext() ) {
9568 if ( p.next() != null ) {
9572 if ( !p.hasNext() ) {
9576 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9579 if ( p.hasNext() ) {
9582 if ( p.next() != null ) {
9586 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
9587 p.setSource( p7_str );
9588 if ( !p.hasNext() ) {
9591 Phylogeny p7_0 = p.next();
9592 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9595 if ( p.hasNext() ) {
9598 if ( p.next() != null ) {
9602 if ( !p.hasNext() ) {
9606 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9609 if ( p.hasNext() ) {
9612 if ( p.next() != null ) {
9616 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
9617 p.setSource( p8_str );
9618 if ( !p.hasNext() ) {
9621 Phylogeny p8_0 = p.next();
9622 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9625 if ( !p.hasNext() ) {
9628 if ( !p.hasNext() ) {
9631 Phylogeny p8_1 = p.next();
9632 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9635 if ( p.hasNext() ) {
9638 if ( p.next() != null ) {
9642 if ( !p.hasNext() ) {
9646 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9649 if ( !p.hasNext() ) {
9653 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9656 if ( p.hasNext() ) {
9659 if ( p.next() != null ) {
9665 if ( p.hasNext() ) {
9669 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
9670 if ( !p.hasNext() ) {
9673 Phylogeny p_27 = p.next();
9674 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9675 System.out.println( p_27.toNewHampshireX() );
9679 if ( p.hasNext() ) {
9682 if ( p.next() != null ) {
9686 if ( !p.hasNext() ) {
9690 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9691 System.out.println( p_27.toNewHampshireX() );
9695 if ( p.hasNext() ) {
9698 if ( p.next() != null ) {
9702 final String p30_str = "(A,B);(C,D)";
9703 final NHXParser p30 = new NHXParser();
9704 p30.setSource( p30_str );
9705 if ( !p30.hasNext() ) {
9708 Phylogeny phy30 = p30.next();
9709 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9710 System.out.println( phy30.toNewHampshire() );
9713 if ( !p30.hasNext() ) {
9716 Phylogeny phy301 = p30.next();
9717 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9718 System.out.println( phy301.toNewHampshire() );
9721 if ( p30.hasNext() ) {
9724 if ( p30.hasNext() ) {
9727 if ( p30.next() != null ) {
9730 if ( p30.next() != null ) {
9734 if ( !p30.hasNext() ) {
9738 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9739 System.out.println( phy30.toNewHampshire() );
9742 if ( !p30.hasNext() ) {
9745 phy301 = p30.next();
9746 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9747 System.out.println( phy301.toNewHampshire() );
9750 if ( p30.hasNext() ) {
9753 if ( p30.hasNext() ) {
9756 if ( p30.next() != null ) {
9759 if ( p30.next() != null ) {
9763 catch ( final Exception e ) {
9764 e.printStackTrace( System.out );
9770 private static boolean testNHXconversion() {
9772 final PhylogenyNode n1 = new PhylogenyNode();
9773 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9774 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9775 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9776 final PhylogenyNode n5 = PhylogenyNode
9777 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
9778 final PhylogenyNode n6 = PhylogenyNode
9779 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
9780 if ( !n1.toNewHampshireX().equals( "" ) ) {
9783 if ( !n2.toNewHampshireX().equals( "" ) ) {
9786 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
9789 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
9792 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
9795 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
9796 System.out.println( n6.toNewHampshireX() );
9799 final PhylogenyNode n7 = new PhylogenyNode();
9800 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
9801 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9802 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
9803 System.out.println( n7
9804 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
9808 catch ( final Exception e ) {
9809 e.printStackTrace( System.out );
9815 private static boolean testNHXNodeParsing() {
9817 final PhylogenyNode n1 = new PhylogenyNode();
9818 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9819 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9820 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9821 final PhylogenyNode n5 = PhylogenyNode
9822 .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]" );
9823 if ( !n3.getName().equals( "n3" ) ) {
9826 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9829 if ( n3.isDuplication() ) {
9832 if ( n3.isHasAssignedEvent() ) {
9835 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
9838 if ( !n4.getName().equals( "n4" ) ) {
9841 if ( n4.getDistanceToParent() != 0.01 ) {
9844 if ( !n5.getName().equals( "n5" ) ) {
9847 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
9850 if ( n5.getDistanceToParent() != 0.1 ) {
9853 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
9856 if ( !n5.isDuplication() ) {
9859 if ( !n5.isHasAssignedEvent() ) {
9862 final PhylogenyNode n8 = PhylogenyNode
9863 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
9864 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9865 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9868 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
9871 final PhylogenyNode n9 = PhylogenyNode
9872 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
9873 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9874 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
9877 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9880 final PhylogenyNode n10 = PhylogenyNode
9881 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9882 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9885 final PhylogenyNode n20 = PhylogenyNode
9886 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9887 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9890 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9893 final PhylogenyNode n20x = PhylogenyNode
9894 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9895 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9898 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9901 final PhylogenyNode n20xx = PhylogenyNode
9902 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9903 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9906 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9909 final PhylogenyNode n20xxx = PhylogenyNode
9910 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9911 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9914 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9917 final PhylogenyNode n20xxxx = PhylogenyNode
9918 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9919 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9922 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9925 final PhylogenyNode n21 = PhylogenyNode
9926 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9927 if ( !n21.getName().equals( "N21_PIG" ) ) {
9930 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9933 final PhylogenyNode n21x = PhylogenyNode
9934 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9935 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9938 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9941 final PhylogenyNode n22 = PhylogenyNode
9942 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9943 if ( !n22.getName().equals( "n22/PIG" ) ) {
9946 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9949 final PhylogenyNode n23 = PhylogenyNode
9950 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9951 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9954 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9957 final PhylogenyNode a = PhylogenyNode
9958 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9959 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9962 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9965 final PhylogenyNode c1 = PhylogenyNode
9966 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9967 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9968 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9971 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9974 final PhylogenyNode c2 = PhylogenyNode
9975 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9976 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9977 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9980 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9983 final PhylogenyNode e3 = PhylogenyNode
9984 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9985 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9988 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9991 final PhylogenyNode n11 = PhylogenyNode
9992 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9993 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9994 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9997 if ( n11.getDistanceToParent() != 0.4 ) {
10000 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
10003 final PhylogenyNode n12 = PhylogenyNode
10004 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
10005 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10006 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
10009 if ( n12.getDistanceToParent() != 0.4 ) {
10012 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
10015 final PhylogenyNode o = PhylogenyNode
10016 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10017 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
10020 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
10023 if ( n1.getName().compareTo( "" ) != 0 ) {
10026 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
10029 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
10032 if ( n2.getName().compareTo( "" ) != 0 ) {
10035 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
10038 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
10041 final PhylogenyNode n00 = PhylogenyNode
10042 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
10043 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
10046 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
10049 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
10050 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
10053 final PhylogenyNode n13 = PhylogenyNode
10054 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10055 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
10058 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
10061 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10064 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
10067 final PhylogenyNode n14 = PhylogenyNode
10068 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10069 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
10072 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
10075 final PhylogenyNode n15 = PhylogenyNode
10076 .createInstanceFromNhxString( "something_wicked[123]",
10077 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10078 if ( !n15.getName().equals( "something_wicked" ) ) {
10081 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
10084 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
10087 final PhylogenyNode n16 = PhylogenyNode
10088 .createInstanceFromNhxString( "something_wicked2[9]",
10089 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10090 if ( !n16.getName().equals( "something_wicked2" ) ) {
10093 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
10096 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
10099 final PhylogenyNode n17 = PhylogenyNode
10100 .createInstanceFromNhxString( "something_wicked3[a]",
10101 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10102 if ( !n17.getName().equals( "something_wicked3" ) ) {
10105 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
10108 final PhylogenyNode n18 = PhylogenyNode
10109 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10110 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
10113 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
10116 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
10119 final PhylogenyNode n19 = PhylogenyNode
10120 .createInstanceFromNhxString( "BLAH_1-roejojoej",
10121 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10122 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
10125 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
10128 final PhylogenyNode n30 = PhylogenyNode
10129 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
10130 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10131 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
10134 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
10137 final PhylogenyNode n31 = PhylogenyNode
10138 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
10139 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10140 if ( n31.getNodeData().isHasTaxonomy() ) {
10143 final PhylogenyNode n32 = PhylogenyNode
10144 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10145 if ( n32.getNodeData().isHasTaxonomy() ) {
10148 final PhylogenyNode n40 = PhylogenyNode
10149 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10150 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10153 final PhylogenyNode n41 = PhylogenyNode
10154 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10155 if ( n41.getNodeData().isHasTaxonomy() ) {
10158 final PhylogenyNode n42 = PhylogenyNode
10159 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10160 if ( n42.getNodeData().isHasTaxonomy() ) {
10163 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
10164 NHXParser.TAXONOMY_EXTRACTION.NO );
10165 if ( n43.getNodeData().isHasTaxonomy() ) {
10168 final PhylogenyNode n44 = PhylogenyNode
10169 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10170 if ( n44.getNodeData().isHasTaxonomy() ) {
10174 catch ( final Exception e ) {
10175 e.printStackTrace( System.out );
10181 private static boolean testNHXNodeParsing2() {
10183 final PhylogenyNode n0_0 = PhylogenyNode.createInstanceFromNhxString( "n0:[ignore me 123]:1E-3",
10184 NHXParser.TAXONOMY_EXTRACTION.NO,
10187 if ( !n0_0.getName().equals( "n0" ) ) {
10190 if ( !isEqual( n0_0.getDistanceToParent(), 0.001 ) ) {
10193 final PhylogenyNode n0_1 = PhylogenyNode.createInstanceFromNhxString( "n0[ignore me 123]:1E-3",
10194 NHXParser.TAXONOMY_EXTRACTION.NO,
10197 if ( !n0_1.getName().equals( "n0" ) ) {
10200 if ( !isEqual( n0_1.getDistanceToParent(), 0.001 ) ) {
10203 final PhylogenyNode n0_2 = PhylogenyNode.createInstanceFromNhxString( "n0:1E-3[ignore me 123]",
10204 NHXParser.TAXONOMY_EXTRACTION.NO,
10207 if ( !n0_2.getName().equals( "n0" ) ) {
10210 if ( !isEqual( n0_2.getDistanceToParent(), 0.001 ) ) {
10213 final PhylogenyNode n0_3 = PhylogenyNode.createInstanceFromNhxString( "n0:1E-3:[ignore me 123]",
10214 NHXParser.TAXONOMY_EXTRACTION.NO,
10217 if ( !n0_3.getName().equals( "n0" ) ) {
10220 if ( !isEqual( n0_3.getDistanceToParent(), 0.001 ) ) {
10223 final PhylogenyNode n0_4 = PhylogenyNode.createInstanceFromNhxString( "n0:0.001:[ignore me 123]",
10224 NHXParser.TAXONOMY_EXTRACTION.NO,
10227 if ( !n0_4.getName().equals( "n0" ) ) {
10230 if ( !isEqual( n0_4.getDistanceToParent(), 0.001 ) ) {
10233 final PhylogenyNode n1_0 = PhylogenyNode
10234 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]",
10235 NHXParser.TAXONOMY_EXTRACTION.NO,
10238 if ( !n1_0.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10241 if ( n1_0.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10244 final PhylogenyNode n1_1 = PhylogenyNode
10245 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]:0.001",
10246 NHXParser.TAXONOMY_EXTRACTION.NO,
10249 if ( !n1_1.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10252 if ( n1_1.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10255 if ( !isEqual( n1_1.getDistanceToParent(), 0.001 ) ) {
10258 final PhylogenyNode n1_2 = PhylogenyNode
10259 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:0.001[&!color=#FFFFFF]",
10260 NHXParser.TAXONOMY_EXTRACTION.NO,
10263 if ( !n1_2.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10266 if ( n1_2.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10269 if ( !isEqual( n1_2.getDistanceToParent(), 0.001 ) ) {
10272 final PhylogenyNode n1_3 = PhylogenyNode
10273 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[&boostrap=69,&!color=#FFFFFF]",
10274 NHXParser.TAXONOMY_EXTRACTION.NO,
10277 if ( !n1_3.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10280 if ( n1_3.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10283 if ( !isEqual( n1_3.getDistanceToParent(), 0.001 ) ) {
10286 if ( !isEqual( n1_3.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10289 if ( !n1_3.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
10292 final PhylogenyNode n1_4 = PhylogenyNode
10293 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&bootstrap=69,&!colour=#FFFFFF]:1e-3",
10294 NHXParser.TAXONOMY_EXTRACTION.NO,
10297 if ( !n1_4.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10300 if ( n1_4.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10303 if ( !isEqual( n1_4.getDistanceToParent(), 0.001 ) ) {
10306 if ( !isEqual( n1_4.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10309 if ( !n1_4.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
10312 final PhylogenyNode n1_5 = PhylogenyNode
10313 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[69.0]",
10314 NHXParser.TAXONOMY_EXTRACTION.NO,
10317 if ( !n1_5.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10320 if ( !isEqual( n1_5.getDistanceToParent(), 0.001 ) ) {
10323 if ( !isEqual( n1_5.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10326 final PhylogenyNode n1_6 = PhylogenyNode
10327 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00]:1e-3",
10328 NHXParser.TAXONOMY_EXTRACTION.NO,
10331 if ( !n1_6.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10334 if ( !isEqual( n1_6.getDistanceToParent(), 0.001 ) ) {
10337 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getStandardDeviation(), 0.11 ) ) {
10340 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getValue(), 0.95 ) ) {
10343 if ( !n1_6.getBranchData().getConfidence( 0 ).getType().equals( "posterior probability" ) ) {
10347 catch ( final Exception e ) {
10348 e.printStackTrace( System.out );
10354 private static boolean testNHXParsing() {
10356 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10357 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])",
10358 new NHXParser() )[ 0 ];
10359 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
10362 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]";
10363 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
10364 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10367 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]";
10368 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
10369 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
10372 final Phylogeny[] p3 = factory.create(
10373 "[ 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]",
10375 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10378 final Phylogeny[] p4 = factory.create(
10379 "(((((((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(]",
10381 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10384 final Phylogeny[] p5 = factory.create(
10385 "[] ( [][ ][ ] ([((( &&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(((]",
10387 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10390 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)";
10391 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)";
10392 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
10393 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
10396 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)))";
10397 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)))";
10398 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
10399 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
10402 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]) ))[,,, ])))))))";
10403 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
10404 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
10405 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
10408 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
10409 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10412 final Phylogeny p10 = factory.create(
10413 " [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]",
10414 new NHXParser() )[ 0 ];
10415 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10418 final Phylogeny p11 = factory.create(
10419 " [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]",
10420 new NHXParser() )[ 0 ];
10421 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10424 final Phylogeny p12 = factory.create( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]",
10425 new NHXParser() )[ 0 ];
10426 if ( !p12.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10430 catch ( final Exception e ) {
10431 e.printStackTrace( System.out );
10437 private static boolean testNHXParsingMB() {
10439 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10440 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
10441 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10442 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10443 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10444 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10445 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10446 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10447 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10448 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
10449 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
10452 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
10455 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
10456 0.1100000000000000e+00 ) ) {
10459 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
10462 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
10465 final Phylogeny p2 = factory
10466 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
10467 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10468 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10469 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10470 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10471 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10472 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10473 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10474 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
10475 if ( p2.getNode( "1" ) == null ) {
10478 if ( p2.getNode( "2" ) == null ) {
10482 catch ( final Exception e ) {
10483 e.printStackTrace( System.out );
10490 private static boolean testNHXParsingQuotes() {
10492 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10493 final NHXParser p = new NHXParser();
10494 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
10495 if ( phylogenies_0.length != 5 ) {
10498 final Phylogeny phy = phylogenies_0[ 4 ];
10499 if ( phy.getNumberOfExternalNodes() != 7 ) {
10502 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
10505 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
10508 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
10509 .getScientificName().equals( "hsapiens" ) ) {
10512 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
10515 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
10518 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
10521 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
10524 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
10527 final NHXParser p1p = new NHXParser();
10528 p1p.setIgnoreQuotes( true );
10529 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
10530 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
10533 final NHXParser p2p = new NHXParser();
10534 p1p.setIgnoreQuotes( false );
10535 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
10536 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
10539 final NHXParser p3p = new NHXParser();
10540 p3p.setIgnoreQuotes( false );
10541 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
10542 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
10545 final NHXParser p4p = new NHXParser();
10546 p4p.setIgnoreQuotes( false );
10547 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
10548 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
10551 final Phylogeny p10 = factory.create(
10552 " [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]",
10553 new NHXParser() )[ 0 ];
10554 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]";
10555 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
10558 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
10559 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
10562 final Phylogeny p12 = factory.create(
10563 " [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]",
10564 new NHXParser() )[ 0 ];
10565 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]";
10566 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
10569 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
10570 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
10573 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;";
10574 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
10577 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
10578 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
10582 catch ( final Exception e ) {
10583 e.printStackTrace( System.out );
10589 private static boolean testNodeRemoval() {
10591 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10592 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
10593 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
10594 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
10597 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
10598 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
10599 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
10602 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
10603 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
10604 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
10608 catch ( final Exception e ) {
10609 e.printStackTrace( System.out );
10615 private static boolean testPhylogenyBranch() {
10617 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
10618 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
10619 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
10620 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
10621 if ( !a1b1.equals( a1b1 ) ) {
10624 if ( !a1b1.equals( b1a1 ) ) {
10627 if ( !b1a1.equals( a1b1 ) ) {
10630 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
10631 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
10632 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
10633 if ( a1_b1.equals( b1_a1 ) ) {
10636 if ( a1_b1.equals( a1_b1_ ) ) {
10639 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
10640 if ( !a1_b1.equals( b1_a1_ ) ) {
10643 if ( a1_b1_.equals( b1_a1_ ) ) {
10646 if ( !a1_b1_.equals( b1_a1 ) ) {
10650 catch ( final Exception e ) {
10651 e.printStackTrace( System.out );
10657 private static boolean testPhyloXMLparsingOfDistributionElement() {
10659 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10660 PhyloXmlParser xml_parser = null;
10662 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
10664 catch ( final Exception e ) {
10665 // Do nothing -- means were not running from jar.
10667 if ( xml_parser == null ) {
10668 xml_parser = PhyloXmlParser.createPhyloXmlParser();
10669 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
10670 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
10673 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
10676 final Phylogeny[] phylogenies_0 = factory
10677 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml" ), xml_parser );
10678 if ( xml_parser.getErrorCount() > 0 ) {
10679 System.out.println( xml_parser.getErrorMessages().toString() );
10682 if ( phylogenies_0.length != 1 ) {
10685 final Phylogeny t1 = phylogenies_0[ 0 ];
10686 PhylogenyNode n = null;
10687 Distribution d = null;
10688 n = t1.getNode( "root node" );
10689 if ( !n.getNodeData().isHasDistribution() ) {
10692 if ( n.getNodeData().getDistributions().size() != 1 ) {
10695 d = n.getNodeData().getDistribution();
10696 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10699 if ( d.getPoints().size() != 1 ) {
10702 if ( d.getPolygons() != null ) {
10705 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10708 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10711 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10714 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10717 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10720 n = t1.getNode( "node a" );
10721 if ( !n.getNodeData().isHasDistribution() ) {
10724 if ( n.getNodeData().getDistributions().size() != 2 ) {
10727 d = n.getNodeData().getDistribution( 1 );
10728 if ( !d.getDesc().equals( "San Diego" ) ) {
10731 if ( d.getPoints().size() != 1 ) {
10734 if ( d.getPolygons() != null ) {
10737 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10740 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10743 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10746 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10749 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10752 n = t1.getNode( "node bb" );
10753 if ( !n.getNodeData().isHasDistribution() ) {
10756 if ( n.getNodeData().getDistributions().size() != 1 ) {
10759 d = n.getNodeData().getDistribution( 0 );
10760 if ( d.getPoints().size() != 3 ) {
10763 if ( d.getPolygons().size() != 2 ) {
10766 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10769 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10772 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10775 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10778 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10781 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10784 Polygon p = d.getPolygons().get( 0 );
10785 if ( p.getPoints().size() != 3 ) {
10788 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10791 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10794 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10797 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10800 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10803 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10806 p = d.getPolygons().get( 1 );
10807 if ( p.getPoints().size() != 3 ) {
10810 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10813 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10816 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10820 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
10821 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
10822 if ( rt.length != 1 ) {
10825 final Phylogeny t1_rt = rt[ 0 ];
10826 n = t1_rt.getNode( "root node" );
10827 if ( !n.getNodeData().isHasDistribution() ) {
10830 if ( n.getNodeData().getDistributions().size() != 1 ) {
10833 d = n.getNodeData().getDistribution();
10834 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10837 if ( d.getPoints().size() != 1 ) {
10840 if ( d.getPolygons() != null ) {
10843 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10846 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10849 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10852 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10855 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10858 n = t1_rt.getNode( "node a" );
10859 if ( !n.getNodeData().isHasDistribution() ) {
10862 if ( n.getNodeData().getDistributions().size() != 2 ) {
10865 d = n.getNodeData().getDistribution( 1 );
10866 if ( !d.getDesc().equals( "San Diego" ) ) {
10869 if ( d.getPoints().size() != 1 ) {
10872 if ( d.getPolygons() != null ) {
10875 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10878 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10881 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10884 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10887 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10890 n = t1_rt.getNode( "node bb" );
10891 if ( !n.getNodeData().isHasDistribution() ) {
10894 if ( n.getNodeData().getDistributions().size() != 1 ) {
10897 d = n.getNodeData().getDistribution( 0 );
10898 if ( d.getPoints().size() != 3 ) {
10901 if ( d.getPolygons().size() != 2 ) {
10904 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10907 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10910 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10913 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10916 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10919 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10922 p = d.getPolygons().get( 0 );
10923 if ( p.getPoints().size() != 3 ) {
10926 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10929 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10932 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10935 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10938 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10941 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10944 p = d.getPolygons().get( 1 );
10945 if ( p.getPoints().size() != 3 ) {
10948 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10951 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10954 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10958 catch ( final Exception e ) {
10959 e.printStackTrace( System.out );
10965 private static boolean testPostOrderIterator() {
10967 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10968 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10969 PhylogenyNodeIterator it0;
10970 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
10973 for( it0.reset(); it0.hasNext(); ) {
10976 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r",
10977 new NHXParser() )[ 0 ];
10978 final PhylogenyNodeIterator it = t1.iteratorPostorder();
10979 if ( !it.next().getName().equals( "A" ) ) {
10982 if ( !it.next().getName().equals( "B" ) ) {
10985 if ( !it.next().getName().equals( "ab" ) ) {
10988 if ( !it.next().getName().equals( "C" ) ) {
10991 if ( !it.next().getName().equals( "D" ) ) {
10994 if ( !it.next().getName().equals( "cd" ) ) {
10997 if ( !it.next().getName().equals( "abcd" ) ) {
11000 if ( !it.next().getName().equals( "E" ) ) {
11003 if ( !it.next().getName().equals( "F" ) ) {
11006 if ( !it.next().getName().equals( "ef" ) ) {
11009 if ( !it.next().getName().equals( "G" ) ) {
11012 if ( !it.next().getName().equals( "H" ) ) {
11015 if ( !it.next().getName().equals( "gh" ) ) {
11018 if ( !it.next().getName().equals( "efgh" ) ) {
11021 if ( !it.next().getName().equals( "r" ) ) {
11024 if ( it.hasNext() ) {
11028 catch ( final Exception e ) {
11029 e.printStackTrace( System.out );
11035 private static boolean testPreOrderIterator() {
11037 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11038 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
11039 PhylogenyNodeIterator it0;
11040 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
11043 for( it0.reset(); it0.hasNext(); ) {
11046 PhylogenyNodeIterator it = t0.iteratorPreorder();
11047 if ( !it.next().getName().equals( "r" ) ) {
11050 if ( !it.next().getName().equals( "ab" ) ) {
11053 if ( !it.next().getName().equals( "A" ) ) {
11056 if ( !it.next().getName().equals( "B" ) ) {
11059 if ( !it.next().getName().equals( "cd" ) ) {
11062 if ( !it.next().getName().equals( "C" ) ) {
11065 if ( !it.next().getName().equals( "D" ) ) {
11068 if ( it.hasNext() ) {
11071 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r",
11072 new NHXParser() )[ 0 ];
11073 it = t1.iteratorPreorder();
11074 if ( !it.next().getName().equals( "r" ) ) {
11077 if ( !it.next().getName().equals( "abcd" ) ) {
11080 if ( !it.next().getName().equals( "ab" ) ) {
11083 if ( !it.next().getName().equals( "A" ) ) {
11086 if ( !it.next().getName().equals( "B" ) ) {
11089 if ( !it.next().getName().equals( "cd" ) ) {
11092 if ( !it.next().getName().equals( "C" ) ) {
11095 if ( !it.next().getName().equals( "D" ) ) {
11098 if ( !it.next().getName().equals( "efgh" ) ) {
11101 if ( !it.next().getName().equals( "ef" ) ) {
11104 if ( !it.next().getName().equals( "E" ) ) {
11107 if ( !it.next().getName().equals( "F" ) ) {
11110 if ( !it.next().getName().equals( "gh" ) ) {
11113 if ( !it.next().getName().equals( "G" ) ) {
11116 if ( !it.next().getName().equals( "H" ) ) {
11119 if ( it.hasNext() ) {
11123 catch ( final Exception e ) {
11124 e.printStackTrace( System.out );
11130 private static boolean testPropertiesMap() {
11132 final PropertiesList pm = new PropertiesList();
11133 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
11134 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
11135 final Property p2 = new Property( "something:else",
11137 "improbable:research",
11140 pm.addProperty( p0 );
11141 pm.addProperty( p1 );
11142 pm.addProperty( p2 );
11143 if ( !pm.getProperties( "dimensions:diameter" ).get( 0 ).getValue().equals( "1" ) ) {
11146 if ( !pm.getProperties( "dimensions:length" ).get( 0 ).getValue().equals( "2" ) ) {
11149 if ( pm.getProperties().size() != 3 ) {
11152 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
11155 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
11158 if ( pm.getProperties().size() != 3 ) {
11162 catch ( final Exception e ) {
11163 e.printStackTrace( System.out );
11169 private static boolean testProteinId() {
11171 final ProteinId id1 = new ProteinId( "a" );
11172 final ProteinId id2 = new ProteinId( "a" );
11173 final ProteinId id3 = new ProteinId( "A" );
11174 final ProteinId id4 = new ProteinId( "b" );
11175 if ( !id1.equals( id1 ) ) {
11178 if ( id1.getId().equals( "x" ) ) {
11181 if ( id1.getId().equals( null ) ) {
11184 if ( !id1.equals( id2 ) ) {
11187 if ( id1.equals( id3 ) ) {
11190 if ( id1.hashCode() != id1.hashCode() ) {
11193 if ( id1.hashCode() != id2.hashCode() ) {
11196 if ( id1.hashCode() == id3.hashCode() ) {
11199 if ( id1.compareTo( id1 ) != 0 ) {
11202 if ( id1.compareTo( id2 ) != 0 ) {
11205 if ( id1.compareTo( id3 ) != 0 ) {
11208 if ( id1.compareTo( id4 ) >= 0 ) {
11211 if ( id4.compareTo( id1 ) <= 0 ) {
11214 if ( !id4.getId().equals( "b" ) ) {
11217 final ProteinId id5 = new ProteinId( " C " );
11218 if ( !id5.getId().equals( "C" ) ) {
11221 if ( id5.equals( id1 ) ) {
11225 catch ( final Exception e ) {
11226 e.printStackTrace( System.out );
11232 private static boolean testReIdMethods() {
11234 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11235 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
11236 final long count = PhylogenyNode.getNodeCount();
11237 p.levelOrderReID();
11238 if ( p.getNode( "r" ).getId() != count ) {
11241 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
11244 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
11247 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
11250 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
11253 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
11256 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
11259 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
11262 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
11265 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
11268 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
11271 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
11274 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
11277 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
11280 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
11284 catch ( final Exception e ) {
11285 e.printStackTrace( System.out );
11291 private static boolean testRerooting() {
11293 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11294 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",
11295 new NHXParser() )[ 0 ];
11296 if ( !t1.isRooted() ) {
11299 t1.reRoot( t1.getNode( "D" ) );
11300 t1.reRoot( t1.getNode( "CD" ) );
11301 t1.reRoot( t1.getNode( "A" ) );
11302 t1.reRoot( t1.getNode( "B" ) );
11303 t1.reRoot( t1.getNode( "AB" ) );
11304 t1.reRoot( t1.getNode( "D" ) );
11305 t1.reRoot( t1.getNode( "C" ) );
11306 t1.reRoot( t1.getNode( "CD" ) );
11307 t1.reRoot( t1.getNode( "A" ) );
11308 t1.reRoot( t1.getNode( "B" ) );
11309 t1.reRoot( t1.getNode( "AB" ) );
11310 t1.reRoot( t1.getNode( "D" ) );
11311 t1.reRoot( t1.getNode( "D" ) );
11312 t1.reRoot( t1.getNode( "C" ) );
11313 t1.reRoot( t1.getNode( "A" ) );
11314 t1.reRoot( t1.getNode( "B" ) );
11315 t1.reRoot( t1.getNode( "AB" ) );
11316 t1.reRoot( t1.getNode( "C" ) );
11317 t1.reRoot( t1.getNode( "D" ) );
11318 t1.reRoot( t1.getNode( "CD" ) );
11319 t1.reRoot( t1.getNode( "D" ) );
11320 t1.reRoot( t1.getNode( "A" ) );
11321 t1.reRoot( t1.getNode( "B" ) );
11322 t1.reRoot( t1.getNode( "AB" ) );
11323 t1.reRoot( t1.getNode( "C" ) );
11324 t1.reRoot( t1.getNode( "D" ) );
11325 t1.reRoot( t1.getNode( "CD" ) );
11326 t1.reRoot( t1.getNode( "D" ) );
11327 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
11330 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
11333 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
11336 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
11339 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
11342 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
11345 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",
11346 new NHXParser() )[ 0 ];
11347 t2.reRoot( t2.getNode( "A" ) );
11348 t2.reRoot( t2.getNode( "D" ) );
11349 t2.reRoot( t2.getNode( "ABC" ) );
11350 t2.reRoot( t2.getNode( "A" ) );
11351 t2.reRoot( t2.getNode( "B" ) );
11352 t2.reRoot( t2.getNode( "D" ) );
11353 t2.reRoot( t2.getNode( "C" ) );
11354 t2.reRoot( t2.getNode( "ABC" ) );
11355 t2.reRoot( t2.getNode( "A" ) );
11356 t2.reRoot( t2.getNode( "B" ) );
11357 t2.reRoot( t2.getNode( "AB" ) );
11358 t2.reRoot( t2.getNode( "AB" ) );
11359 t2.reRoot( t2.getNode( "D" ) );
11360 t2.reRoot( t2.getNode( "C" ) );
11361 t2.reRoot( t2.getNode( "B" ) );
11362 t2.reRoot( t2.getNode( "AB" ) );
11363 t2.reRoot( t2.getNode( "D" ) );
11364 t2.reRoot( t2.getNode( "D" ) );
11365 t2.reRoot( t2.getNode( "ABC" ) );
11366 t2.reRoot( t2.getNode( "A" ) );
11367 t2.reRoot( t2.getNode( "B" ) );
11368 t2.reRoot( t2.getNode( "AB" ) );
11369 t2.reRoot( t2.getNode( "D" ) );
11370 t2.reRoot( t2.getNode( "C" ) );
11371 t2.reRoot( t2.getNode( "ABC" ) );
11372 t2.reRoot( t2.getNode( "A" ) );
11373 t2.reRoot( t2.getNode( "B" ) );
11374 t2.reRoot( t2.getNode( "AB" ) );
11375 t2.reRoot( t2.getNode( "D" ) );
11376 t2.reRoot( t2.getNode( "D" ) );
11377 t2.reRoot( t2.getNode( "C" ) );
11378 t2.reRoot( t2.getNode( "A" ) );
11379 t2.reRoot( t2.getNode( "B" ) );
11380 t2.reRoot( t2.getNode( "AB" ) );
11381 t2.reRoot( t2.getNode( "C" ) );
11382 t2.reRoot( t2.getNode( "D" ) );
11383 t2.reRoot( t2.getNode( "ABC" ) );
11384 t2.reRoot( t2.getNode( "D" ) );
11385 t2.reRoot( t2.getNode( "A" ) );
11386 t2.reRoot( t2.getNode( "B" ) );
11387 t2.reRoot( t2.getNode( "AB" ) );
11388 t2.reRoot( t2.getNode( "C" ) );
11389 t2.reRoot( t2.getNode( "D" ) );
11390 t2.reRoot( t2.getNode( "ABC" ) );
11391 t2.reRoot( t2.getNode( "D" ) );
11392 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11395 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11398 t2.reRoot( t2.getNode( "ABC" ) );
11399 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11402 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11405 t2.reRoot( t2.getNode( "AB" ) );
11406 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11409 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11412 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11415 t2.reRoot( t2.getNode( "AB" ) );
11416 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11419 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11422 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11425 t2.reRoot( t2.getNode( "D" ) );
11426 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11429 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11432 t2.reRoot( t2.getNode( "ABC" ) );
11433 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11436 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11439 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
11440 new NHXParser() )[ 0 ];
11441 t3.reRoot( t3.getNode( "B" ) );
11442 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11445 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11448 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11451 t3.reRoot( t3.getNode( "B" ) );
11452 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11455 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11458 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11461 t3.reRoot( t3.getRoot() );
11462 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11465 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11468 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11472 catch ( final Exception e ) {
11473 e.printStackTrace( System.out );
11479 private static boolean testSDIse() {
11481 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11482 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
11483 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
11484 gene1.setRooted( true );
11485 species1.setRooted( true );
11486 final SDI sdi = new SDI( gene1, species1 );
11487 if ( !gene1.getRoot().isDuplication() ) {
11490 final Phylogeny species2 = factory.create(
11491 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11492 new NHXParser() )[ 0 ];
11493 final Phylogeny gene2 = factory.create(
11494 "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11495 new NHXParser() )[ 0 ];
11496 species2.setRooted( true );
11497 gene2.setRooted( true );
11498 final SDI sdi2 = new SDI( gene2, species2 );
11499 if ( sdi2.getDuplicationsSum() != 0 ) {
11502 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
11505 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
11508 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
11511 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
11514 if ( !gene2.getNode( "r" ).isSpeciation() ) {
11517 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
11520 final Phylogeny species3 = factory.create(
11521 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11522 new NHXParser() )[ 0 ];
11523 final Phylogeny gene3 = factory.create(
11524 "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11525 new NHXParser() )[ 0 ];
11526 species3.setRooted( true );
11527 gene3.setRooted( true );
11528 final SDI sdi3 = new SDI( gene3, species3 );
11529 if ( sdi3.getDuplicationsSum() != 1 ) {
11532 if ( !gene3.getNode( "aa" ).isDuplication() ) {
11535 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
11538 final Phylogeny species4 = factory.create(
11539 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11540 new NHXParser() )[ 0 ];
11541 final Phylogeny gene4 = factory.create(
11542 "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11543 new NHXParser() )[ 0 ];
11544 species4.setRooted( true );
11545 gene4.setRooted( true );
11546 final SDI sdi4 = new SDI( gene4, species4 );
11547 if ( sdi4.getDuplicationsSum() != 1 ) {
11550 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
11553 if ( !gene4.getNode( "abc" ).isDuplication() ) {
11556 if ( gene4.getNode( "abcd" ).isDuplication() ) {
11559 if ( species4.getNumberOfExternalNodes() != 6 ) {
11562 if ( gene4.getNumberOfExternalNodes() != 6 ) {
11565 final Phylogeny species5 = factory.create(
11566 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11567 new NHXParser() )[ 0 ];
11568 final Phylogeny gene5 = factory.create(
11569 "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11570 new NHXParser() )[ 0 ];
11571 species5.setRooted( true );
11572 gene5.setRooted( true );
11573 final SDI sdi5 = new SDI( gene5, species5 );
11574 if ( sdi5.getDuplicationsSum() != 2 ) {
11577 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
11580 if ( !gene5.getNode( "adc" ).isDuplication() ) {
11583 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
11586 if ( species5.getNumberOfExternalNodes() != 6 ) {
11589 if ( gene5.getNumberOfExternalNodes() != 6 ) {
11592 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
11593 // Conjecture for Comparing Molecular Phylogenies"
11594 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
11595 final Phylogeny species6 = factory.create(
11596 "(((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,"
11597 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11598 new NHXParser() )[ 0 ];
11599 final Phylogeny gene6 = factory.create(
11600 "(((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,"
11601 + "((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,"
11602 + "(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;",
11603 new NHXParser() )[ 0 ];
11604 species6.setRooted( true );
11605 gene6.setRooted( true );
11606 final SDI sdi6 = new SDI( gene6, species6 );
11607 if ( sdi6.getDuplicationsSum() != 3 ) {
11610 if ( !gene6.getNode( "r" ).isDuplication() ) {
11613 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
11616 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
11619 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
11622 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
11625 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
11628 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
11631 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
11634 sdi6.computeMappingCostL();
11635 if ( sdi6.computeMappingCostL() != 17 ) {
11638 if ( species6.getNumberOfExternalNodes() != 9 ) {
11641 if ( gene6.getNumberOfExternalNodes() != 9 ) {
11644 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
11645 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
11646 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
11647 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
11648 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
11649 species7.setRooted( true );
11650 final Phylogeny gene7_1 = Test
11651 .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])" );
11652 gene7_1.setRooted( true );
11653 final SDI sdi7 = new SDI( gene7_1, species7 );
11654 if ( sdi7.getDuplicationsSum() != 0 ) {
11657 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
11660 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
11663 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
11666 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
11669 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
11672 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
11675 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
11678 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
11681 final Phylogeny gene7_2 = Test
11682 .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])" );
11683 gene7_2.setRooted( true );
11684 final SDI sdi7_2 = new SDI( gene7_2, species7 );
11685 if ( sdi7_2.getDuplicationsSum() != 1 ) {
11688 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
11691 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
11694 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
11697 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
11700 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
11703 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
11706 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
11709 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
11712 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
11716 catch ( final Exception e ) {
11722 private static boolean testSDIunrooted() {
11724 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11725 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef",
11726 new NHXParser() )[ 0 ];
11727 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
11728 final Iterator<PhylogenyBranch> iter = l.iterator();
11729 PhylogenyBranch br = iter.next();
11730 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
11733 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
11737 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11740 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11744 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
11747 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
11751 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11754 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11758 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11761 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11765 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11768 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11772 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11775 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11779 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11782 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11786 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11789 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11793 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11796 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11800 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11803 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11807 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
11810 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
11814 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11817 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11821 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
11824 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
11828 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
11831 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
11834 if ( iter.hasNext() ) {
11837 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
11838 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
11839 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
11841 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11844 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11848 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11851 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11855 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11858 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11861 if ( iter1.hasNext() ) {
11864 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
11865 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
11866 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
11868 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11871 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11875 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11878 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11882 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11885 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11888 if ( iter2.hasNext() ) {
11891 final Phylogeny species0 = factory.create(
11892 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11893 new NHXParser() )[ 0 ];
11894 final Phylogeny gene1 = factory.create(
11895 "(((((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])",
11896 new NHXParser() )[ 0 ];
11897 species0.setRooted( true );
11898 gene1.setRooted( true );
11899 final SDIR sdi_unrooted = new SDIR();
11900 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
11901 if ( sdi_unrooted.getCount() != 1 ) {
11904 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
11907 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
11910 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
11913 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11916 final Phylogeny gene2 = factory.create(
11917 "(((((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])",
11918 new NHXParser() )[ 0 ];
11919 gene2.setRooted( true );
11920 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
11921 if ( sdi_unrooted.getCount() != 1 ) {
11924 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11927 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11930 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
11933 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11936 final Phylogeny species6 = factory.create(
11937 "(((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,"
11938 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11939 new NHXParser() )[ 0 ];
11940 final Phylogeny gene6 = factory.create(
11941 "((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],"
11942 + "(((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],"
11943 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11944 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11945 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11946 new NHXParser() )[ 0 ];
11947 species6.setRooted( true );
11948 gene6.setRooted( true );
11949 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
11950 if ( sdi_unrooted.getCount() != 1 ) {
11953 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11956 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11959 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11962 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11965 if ( !p6[ 0 ].getRoot().isDuplication() ) {
11968 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11971 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11974 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
11977 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11980 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
11983 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
11986 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11990 final Phylogeny species7 = factory.create(
11991 "(((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,"
11992 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11993 new NHXParser() )[ 0 ];
11994 final Phylogeny gene7 = factory.create(
11995 "((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],"
11996 + "(((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],"
11997 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11998 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11999 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
12000 new NHXParser() )[ 0 ];
12001 species7.setRooted( true );
12002 gene7.setRooted( true );
12003 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
12004 if ( sdi_unrooted.getCount() != 1 ) {
12007 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
12010 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
12013 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
12016 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
12019 if ( !p7[ 0 ].getRoot().isDuplication() ) {
12022 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
12025 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
12028 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
12031 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
12034 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
12037 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
12040 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
12044 final Phylogeny species8 = factory.create(
12045 "(((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,"
12046 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
12047 new NHXParser() )[ 0 ];
12048 final Phylogeny gene8 = factory.create(
12049 "((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],"
12050 + "(((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],"
12051 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
12052 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
12053 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
12054 new NHXParser() )[ 0 ];
12055 species8.setRooted( true );
12056 gene8.setRooted( true );
12057 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
12058 if ( sdi_unrooted.getCount() != 1 ) {
12061 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
12064 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
12067 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
12070 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
12073 if ( !p8[ 0 ].getRoot().isDuplication() ) {
12076 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
12079 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
12082 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
12085 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
12088 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
12091 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
12094 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
12099 catch ( final Exception e ) {
12100 e.printStackTrace( System.out );
12106 private static boolean testSequenceDbWsTools1() {
12108 final PhylogenyNode n = new PhylogenyNode();
12109 n.setName( "NP_001025424" );
12110 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
12111 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
12112 || !acc.getValue().equals( "NP_001025424" ) ) {
12115 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
12116 acc = SequenceDbWsTools.obtainSeqAccession( n );
12117 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
12118 || !acc.getValue().equals( "NP_001025424" ) ) {
12121 n.setName( "NP_001025424.1" );
12122 acc = SequenceDbWsTools.obtainSeqAccession( n );
12123 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
12124 || !acc.getValue().equals( "NP_001025424" ) ) {
12127 n.setName( "NM_001030253" );
12128 acc = SequenceDbWsTools.obtainSeqAccession( n );
12129 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
12130 || !acc.getValue().equals( "NM_001030253" ) ) {
12133 n.setName( "BCL2_HUMAN" );
12134 acc = SequenceDbWsTools.obtainSeqAccession( n );
12135 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
12136 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
12137 System.out.println( acc.toString() );
12140 n.setName( "P10415" );
12141 acc = SequenceDbWsTools.obtainSeqAccession( n );
12142 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
12143 || !acc.getValue().equals( "P10415" ) ) {
12144 System.out.println( acc.toString() );
12147 n.setName( " P10415 " );
12148 acc = SequenceDbWsTools.obtainSeqAccession( n );
12149 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
12150 || !acc.getValue().equals( "P10415" ) ) {
12151 System.out.println( acc.toString() );
12154 n.setName( "_P10415|" );
12155 acc = SequenceDbWsTools.obtainSeqAccession( n );
12156 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
12157 || !acc.getValue().equals( "P10415" ) ) {
12158 System.out.println( acc.toString() );
12161 n.setName( "AY695820" );
12162 acc = SequenceDbWsTools.obtainSeqAccession( n );
12163 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12164 || !acc.getValue().equals( "AY695820" ) ) {
12165 System.out.println( acc.toString() );
12168 n.setName( "_AY695820_" );
12169 acc = SequenceDbWsTools.obtainSeqAccession( n );
12170 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12171 || !acc.getValue().equals( "AY695820" ) ) {
12172 System.out.println( acc.toString() );
12175 n.setName( "AAA59452" );
12176 acc = SequenceDbWsTools.obtainSeqAccession( n );
12177 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12178 || !acc.getValue().equals( "AAA59452" ) ) {
12179 System.out.println( acc.toString() );
12182 n.setName( "_AAA59452_" );
12183 acc = SequenceDbWsTools.obtainSeqAccession( n );
12184 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12185 || !acc.getValue().equals( "AAA59452" ) ) {
12186 System.out.println( acc.toString() );
12189 n.setName( "AAA59452.1" );
12190 acc = SequenceDbWsTools.obtainSeqAccession( n );
12191 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12192 || !acc.getValue().equals( "AAA59452.1" ) ) {
12193 System.out.println( acc.toString() );
12196 n.setName( "_AAA59452.1_" );
12197 acc = SequenceDbWsTools.obtainSeqAccession( n );
12198 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12199 || !acc.getValue().equals( "AAA59452.1" ) ) {
12200 System.out.println( acc.toString() );
12203 n.setName( "GI:94894583" );
12204 acc = SequenceDbWsTools.obtainSeqAccession( n );
12205 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
12206 || !acc.getValue().equals( "94894583" ) ) {
12207 System.out.println( acc.toString() );
12210 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
12211 acc = SequenceDbWsTools.obtainSeqAccession( n );
12212 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
12213 || !acc.getValue().equals( "71845847" ) ) {
12214 System.out.println( acc.toString() );
12217 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
12218 acc = SequenceDbWsTools.obtainSeqAccession( n );
12219 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12220 || !acc.getValue().equals( "AAZ45343.1" ) ) {
12221 System.out.println( acc.toString() );
12225 catch ( final Exception e ) {
12231 private static boolean testSequenceDbWsTools2() {
12233 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
12234 SequenceDbWsTools.obtainSeqInformation( n1 );
12235 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
12238 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
12241 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12244 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
12247 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
12248 SequenceDbWsTools.obtainSeqInformation( n2 );
12249 if ( !n2.getNodeData().getSequence().getName()
12250 .equals( "Danio rerio B-cell CLL/lymphoma 2a (bcl2a), mRNA" ) ) {
12253 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
12256 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12259 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
12262 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
12263 SequenceDbWsTools.obtainSeqInformation( n3 );
12264 if ( !n3.getNodeData().getSequence().getName()
12265 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
12268 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
12271 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12274 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
12278 catch ( final IOException e ) {
12279 System.out.println();
12280 System.out.println( "the following might be due to absence internet connection:" );
12281 e.printStackTrace( System.out );
12284 catch ( final Exception e ) {
12285 e.printStackTrace();
12291 private static boolean testSequenceIdParsing() {
12293 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
12294 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12295 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12296 if ( id != null ) {
12297 System.out.println( "value =" + id.getValue() );
12298 System.out.println( "provider=" + id.getSource() );
12302 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
12303 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12304 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12305 if ( id != null ) {
12306 System.out.println( "value =" + id.getValue() );
12307 System.out.println( "provider=" + id.getSource() );
12311 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
12312 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12313 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12314 if ( id != null ) {
12315 System.out.println( "value =" + id.getValue() );
12316 System.out.println( "provider=" + id.getSource() );
12320 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
12321 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12322 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
12323 if ( id != null ) {
12324 System.out.println( "value =" + id.getValue() );
12325 System.out.println( "provider=" + id.getSource() );
12329 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
12330 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12331 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
12332 if ( id != null ) {
12333 System.out.println( "value =" + id.getValue() );
12334 System.out.println( "provider=" + id.getSource() );
12338 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
12339 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12340 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
12341 if ( id != null ) {
12342 System.out.println( "value =" + id.getValue() );
12343 System.out.println( "provider=" + id.getSource() );
12347 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
12348 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12349 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
12350 if ( id != null ) {
12351 System.out.println( "value =" + id.getValue() );
12352 System.out.println( "provider=" + id.getSource() );
12356 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
12357 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12358 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12359 if ( id != null ) {
12360 System.out.println( "value =" + id.getValue() );
12361 System.out.println( "provider=" + id.getSource() );
12365 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
12366 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12367 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12368 if ( id != null ) {
12369 System.out.println( "value =" + id.getValue() );
12370 System.out.println( "provider=" + id.getSource() );
12374 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
12375 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12376 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
12377 if ( id != null ) {
12378 System.out.println( "value =" + id.getValue() );
12379 System.out.println( "provider=" + id.getSource() );
12383 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
12384 if ( id != null ) {
12385 System.out.println( "value =" + id.getValue() );
12386 System.out.println( "provider=" + id.getSource() );
12389 id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" );
12390 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12391 || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) {
12392 if ( id != null ) {
12393 System.out.println( "value =" + id.getValue() );
12394 System.out.println( "provider=" + id.getSource() );
12398 id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" );
12399 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12400 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12401 if ( id != null ) {
12402 System.out.println( "value =" + id.getValue() );
12403 System.out.println( "provider=" + id.getSource() );
12407 id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" );
12408 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12409 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12410 if ( id != null ) {
12411 System.out.println( "value =" + id.getValue() );
12412 System.out.println( "provider=" + id.getSource() );
12416 id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" );
12417 if ( id != null ) {
12418 System.out.println( "value =" + id.getValue() );
12419 System.out.println( "provider=" + id.getSource() );
12423 catch ( final Exception e ) {
12424 e.printStackTrace( System.out );
12430 private static boolean testSequenceWriter() {
12432 final String n = ForesterUtil.LINE_SEPARATOR;
12433 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
12436 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
12439 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
12442 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
12445 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
12446 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
12449 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
12450 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
12454 catch ( final Exception e ) {
12455 e.printStackTrace();
12461 private static boolean testSpecies() {
12463 final Species s1 = new BasicSpecies( "a" );
12464 final Species s2 = new BasicSpecies( "a" );
12465 final Species s3 = new BasicSpecies( "A" );
12466 final Species s4 = new BasicSpecies( "b" );
12467 if ( !s1.equals( s1 ) ) {
12470 if ( s1.getSpeciesId().equals( "x" ) ) {
12473 if ( s1.getSpeciesId().equals( null ) ) {
12476 if ( !s1.equals( s2 ) ) {
12479 if ( s1.equals( s3 ) ) {
12482 if ( s1.hashCode() != s1.hashCode() ) {
12485 if ( s1.hashCode() != s2.hashCode() ) {
12488 if ( s1.hashCode() == s3.hashCode() ) {
12491 if ( s1.compareTo( s1 ) != 0 ) {
12494 if ( s1.compareTo( s2 ) != 0 ) {
12497 if ( s1.compareTo( s3 ) != 0 ) {
12500 if ( s1.compareTo( s4 ) >= 0 ) {
12503 if ( s4.compareTo( s1 ) <= 0 ) {
12506 if ( !s4.getSpeciesId().equals( "b" ) ) {
12509 final Species s5 = new BasicSpecies( " C " );
12510 if ( !s5.getSpeciesId().equals( "C" ) ) {
12513 if ( s5.equals( s1 ) ) {
12517 catch ( final Exception e ) {
12518 e.printStackTrace( System.out );
12524 private static boolean testSplit() {
12526 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12527 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12528 //Archaeopteryx.createApplication( p0 );
12529 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12530 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12531 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12532 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12533 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12534 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12535 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12536 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12537 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12538 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12539 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
12540 // System.out.println( s0.toString() );
12542 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12543 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12544 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12545 if ( s0.match( query_nodes ) ) {
12548 query_nodes = new HashSet<PhylogenyNode>();
12549 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12550 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12551 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12552 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12553 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12554 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12555 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12556 if ( !s0.match( query_nodes ) ) {
12560 query_nodes = new HashSet<PhylogenyNode>();
12561 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12562 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12563 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12564 if ( !s0.match( query_nodes ) ) {
12568 query_nodes = new HashSet<PhylogenyNode>();
12569 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12570 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12571 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12572 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12573 if ( !s0.match( query_nodes ) ) {
12577 query_nodes = new HashSet<PhylogenyNode>();
12578 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12579 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12580 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12581 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12582 if ( !s0.match( query_nodes ) ) {
12586 query_nodes = new HashSet<PhylogenyNode>();
12587 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12588 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12589 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12590 if ( !s0.match( query_nodes ) ) {
12593 query_nodes = new HashSet<PhylogenyNode>();
12594 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12595 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12596 if ( !s0.match( query_nodes ) ) {
12599 query_nodes = new HashSet<PhylogenyNode>();
12600 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12601 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12602 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12603 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12604 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12605 if ( !s0.match( query_nodes ) ) {
12608 query_nodes = new HashSet<PhylogenyNode>();
12609 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12610 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12611 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12612 if ( !s0.match( query_nodes ) ) {
12615 query_nodes = new HashSet<PhylogenyNode>();
12616 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12617 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12618 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12619 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12620 if ( !s0.match( query_nodes ) ) {
12623 query_nodes = new HashSet<PhylogenyNode>();
12624 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12625 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12626 if ( s0.match( query_nodes ) ) {
12629 query_nodes = new HashSet<PhylogenyNode>();
12630 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12632 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12633 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12634 if ( s0.match( query_nodes ) ) {
12637 query_nodes = new HashSet<PhylogenyNode>();
12638 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12639 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12640 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12641 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12642 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12643 if ( s0.match( query_nodes ) ) {
12646 query_nodes = new HashSet<PhylogenyNode>();
12647 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12648 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12649 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12650 if ( s0.match( query_nodes ) ) {
12653 query_nodes = new HashSet<PhylogenyNode>();
12654 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12655 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12656 if ( s0.match( query_nodes ) ) {
12659 query_nodes = new HashSet<PhylogenyNode>();
12660 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12661 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12662 if ( s0.match( query_nodes ) ) {
12665 query_nodes = new HashSet<PhylogenyNode>();
12666 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12667 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12668 if ( s0.match( query_nodes ) ) {
12671 query_nodes = new HashSet<PhylogenyNode>();
12672 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12673 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12674 if ( s0.match( query_nodes ) ) {
12677 query_nodes = new HashSet<PhylogenyNode>();
12678 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12679 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12680 if ( s0.match( query_nodes ) ) {
12683 query_nodes = new HashSet<PhylogenyNode>();
12684 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12685 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12686 if ( s0.match( query_nodes ) ) {
12689 query_nodes = new HashSet<PhylogenyNode>();
12690 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12691 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12692 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12693 if ( s0.match( query_nodes ) ) {
12696 query_nodes = new HashSet<PhylogenyNode>();
12697 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12698 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12699 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12700 if ( s0.match( query_nodes ) ) {
12703 query_nodes = new HashSet<PhylogenyNode>();
12704 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12705 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12706 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12707 if ( s0.match( query_nodes ) ) {
12710 query_nodes = new HashSet<PhylogenyNode>();
12711 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12712 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12713 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12714 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12715 if ( s0.match( query_nodes ) ) {
12719 // query_nodes = new HashSet<PhylogenyNode>();
12720 // query_nodes.add( new PhylogenyNode( "X" ) );
12721 // query_nodes.add( new PhylogenyNode( "Y" ) );
12722 // query_nodes.add( new PhylogenyNode( "A" ) );
12723 // query_nodes.add( new PhylogenyNode( "B" ) );
12724 // query_nodes.add( new PhylogenyNode( "C" ) );
12725 // query_nodes.add( new PhylogenyNode( "D" ) );
12726 // query_nodes.add( new PhylogenyNode( "E" ) );
12727 // query_nodes.add( new PhylogenyNode( "F" ) );
12728 // query_nodes.add( new PhylogenyNode( "G" ) );
12729 // if ( !s0.match( query_nodes ) ) {
12732 // query_nodes = new HashSet<PhylogenyNode>();
12733 // query_nodes.add( new PhylogenyNode( "X" ) );
12734 // query_nodes.add( new PhylogenyNode( "Y" ) );
12735 // query_nodes.add( new PhylogenyNode( "A" ) );
12736 // query_nodes.add( new PhylogenyNode( "B" ) );
12737 // query_nodes.add( new PhylogenyNode( "C" ) );
12738 // if ( !s0.match( query_nodes ) ) {
12742 // query_nodes = new HashSet<PhylogenyNode>();
12743 // query_nodes.add( new PhylogenyNode( "X" ) );
12744 // query_nodes.add( new PhylogenyNode( "Y" ) );
12745 // query_nodes.add( new PhylogenyNode( "D" ) );
12746 // query_nodes.add( new PhylogenyNode( "E" ) );
12747 // query_nodes.add( new PhylogenyNode( "F" ) );
12748 // query_nodes.add( new PhylogenyNode( "G" ) );
12749 // if ( !s0.match( query_nodes ) ) {
12753 // query_nodes = new HashSet<PhylogenyNode>();
12754 // query_nodes.add( new PhylogenyNode( "X" ) );
12755 // query_nodes.add( new PhylogenyNode( "Y" ) );
12756 // query_nodes.add( new PhylogenyNode( "A" ) );
12757 // query_nodes.add( new PhylogenyNode( "B" ) );
12758 // query_nodes.add( new PhylogenyNode( "C" ) );
12759 // query_nodes.add( new PhylogenyNode( "D" ) );
12760 // if ( !s0.match( query_nodes ) ) {
12764 // query_nodes = new HashSet<PhylogenyNode>();
12765 // query_nodes.add( new PhylogenyNode( "X" ) );
12766 // query_nodes.add( new PhylogenyNode( "Y" ) );
12767 // query_nodes.add( new PhylogenyNode( "E" ) );
12768 // query_nodes.add( new PhylogenyNode( "F" ) );
12769 // query_nodes.add( new PhylogenyNode( "G" ) );
12770 // if ( !s0.match( query_nodes ) ) {
12774 // query_nodes = new HashSet<PhylogenyNode>();
12775 // query_nodes.add( new PhylogenyNode( "X" ) );
12776 // query_nodes.add( new PhylogenyNode( "Y" ) );
12777 // query_nodes.add( new PhylogenyNode( "F" ) );
12778 // query_nodes.add( new PhylogenyNode( "G" ) );
12779 // if ( !s0.match( query_nodes ) ) {
12783 query_nodes = new HashSet<PhylogenyNode>();
12784 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12785 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12786 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12787 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12788 if ( s0.match( query_nodes ) ) {
12792 query_nodes = new HashSet<PhylogenyNode>();
12793 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12794 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12795 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12796 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12797 if ( s0.match( query_nodes ) ) {
12800 ///////////////////////////
12802 query_nodes = new HashSet<PhylogenyNode>();
12803 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12804 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12805 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12807 if ( s0.match( query_nodes ) ) {
12811 query_nodes = new HashSet<PhylogenyNode>();
12812 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12813 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12814 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12815 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12816 if ( s0.match( query_nodes ) ) {
12820 query_nodes = new HashSet<PhylogenyNode>();
12821 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12822 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12823 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12824 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12825 if ( s0.match( query_nodes ) ) {
12829 query_nodes = new HashSet<PhylogenyNode>();
12830 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12831 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12832 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12833 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12834 if ( s0.match( query_nodes ) ) {
12838 query_nodes = new HashSet<PhylogenyNode>();
12839 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12840 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12841 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12842 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12843 if ( s0.match( query_nodes ) ) {
12847 query_nodes = new HashSet<PhylogenyNode>();
12848 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12849 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12850 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12851 if ( s0.match( query_nodes ) ) {
12855 query_nodes = new HashSet<PhylogenyNode>();
12856 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12857 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12858 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12859 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12860 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12861 if ( s0.match( query_nodes ) ) {
12865 query_nodes = new HashSet<PhylogenyNode>();
12866 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12867 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12868 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12869 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12870 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12871 if ( s0.match( query_nodes ) ) {
12875 query_nodes = new HashSet<PhylogenyNode>();
12876 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12877 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12878 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12880 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12881 if ( s0.match( query_nodes ) ) {
12885 query_nodes = new HashSet<PhylogenyNode>();
12886 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12891 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12892 if ( s0.match( query_nodes ) ) {
12896 catch ( final Exception e ) {
12897 e.printStackTrace();
12903 private static boolean testSplitStrict() {
12905 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12906 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12907 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12908 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12909 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12910 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12911 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12912 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12913 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12914 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12915 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
12916 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12917 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12918 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12919 if ( s0.match( query_nodes ) ) {
12922 query_nodes = new HashSet<PhylogenyNode>();
12923 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12924 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12925 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12926 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12927 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12928 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12929 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12930 if ( !s0.match( query_nodes ) ) {
12934 query_nodes = new HashSet<PhylogenyNode>();
12935 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12936 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12937 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12938 if ( !s0.match( query_nodes ) ) {
12942 query_nodes = new HashSet<PhylogenyNode>();
12943 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12944 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12945 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12946 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12947 if ( !s0.match( query_nodes ) ) {
12951 query_nodes = new HashSet<PhylogenyNode>();
12952 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12953 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12954 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12955 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12956 if ( !s0.match( query_nodes ) ) {
12960 query_nodes = new HashSet<PhylogenyNode>();
12961 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12962 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12963 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12964 if ( !s0.match( query_nodes ) ) {
12968 query_nodes = new HashSet<PhylogenyNode>();
12969 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12970 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12971 if ( !s0.match( query_nodes ) ) {
12975 query_nodes = new HashSet<PhylogenyNode>();
12976 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12977 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12978 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12979 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12980 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12981 if ( !s0.match( query_nodes ) ) {
12985 query_nodes = new HashSet<PhylogenyNode>();
12986 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12987 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12988 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12989 if ( !s0.match( query_nodes ) ) {
12993 query_nodes = new HashSet<PhylogenyNode>();
12994 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12995 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12996 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12997 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12998 if ( !s0.match( query_nodes ) ) {
13002 query_nodes = new HashSet<PhylogenyNode>();
13003 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13004 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13005 if ( s0.match( query_nodes ) ) {
13009 query_nodes = new HashSet<PhylogenyNode>();
13010 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13011 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13012 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
13013 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
13014 if ( s0.match( query_nodes ) ) {
13018 query_nodes = new HashSet<PhylogenyNode>();
13019 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13020 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13021 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13022 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13023 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
13024 if ( s0.match( query_nodes ) ) {
13028 query_nodes = new HashSet<PhylogenyNode>();
13029 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13030 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
13031 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13032 if ( s0.match( query_nodes ) ) {
13036 query_nodes = new HashSet<PhylogenyNode>();
13037 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13038 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13039 if ( s0.match( query_nodes ) ) {
13043 query_nodes = new HashSet<PhylogenyNode>();
13044 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13045 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
13046 if ( s0.match( query_nodes ) ) {
13050 query_nodes = new HashSet<PhylogenyNode>();
13051 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13052 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
13053 if ( s0.match( query_nodes ) ) {
13057 query_nodes = new HashSet<PhylogenyNode>();
13058 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13059 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13060 if ( s0.match( query_nodes ) ) {
13064 query_nodes = new HashSet<PhylogenyNode>();
13065 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13066 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13067 if ( s0.match( query_nodes ) ) {
13071 query_nodes = new HashSet<PhylogenyNode>();
13072 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13073 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13074 if ( s0.match( query_nodes ) ) {
13078 query_nodes = new HashSet<PhylogenyNode>();
13079 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13080 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13081 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13082 if ( s0.match( query_nodes ) ) {
13086 query_nodes = new HashSet<PhylogenyNode>();
13087 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13088 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
13089 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13090 if ( s0.match( query_nodes ) ) {
13094 query_nodes = new HashSet<PhylogenyNode>();
13095 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13096 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13097 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13098 if ( s0.match( query_nodes ) ) {
13102 query_nodes = new HashSet<PhylogenyNode>();
13103 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13104 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13105 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13106 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13107 if ( s0.match( query_nodes ) ) {
13111 catch ( final Exception e ) {
13112 e.printStackTrace();
13118 private static boolean testSubtreeDeletion() {
13120 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13121 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
13122 t1.deleteSubtree( t1.getNode( "A" ), false );
13123 if ( t1.getNumberOfExternalNodes() != 5 ) {
13126 t1.toNewHampshireX();
13127 t1.deleteSubtree( t1.getNode( "E" ), false );
13128 if ( t1.getNumberOfExternalNodes() != 4 ) {
13131 t1.toNewHampshireX();
13132 t1.deleteSubtree( t1.getNode( "F" ), false );
13133 if ( t1.getNumberOfExternalNodes() != 3 ) {
13136 t1.toNewHampshireX();
13137 t1.deleteSubtree( t1.getNode( "D" ), false );
13138 t1.toNewHampshireX();
13139 if ( t1.getNumberOfExternalNodes() != 3 ) {
13142 t1.deleteSubtree( t1.getNode( "def" ), false );
13143 t1.toNewHampshireX();
13144 if ( t1.getNumberOfExternalNodes() != 2 ) {
13147 t1.deleteSubtree( t1.getNode( "B" ), false );
13148 t1.toNewHampshireX();
13149 if ( t1.getNumberOfExternalNodes() != 1 ) {
13152 t1.deleteSubtree( t1.getNode( "C" ), false );
13153 t1.toNewHampshireX();
13154 if ( t1.getNumberOfExternalNodes() != 1 ) {
13157 t1.deleteSubtree( t1.getNode( "abc" ), false );
13158 t1.toNewHampshireX();
13159 if ( t1.getNumberOfExternalNodes() != 1 ) {
13162 t1.deleteSubtree( t1.getNode( "r" ), false );
13163 if ( t1.getNumberOfExternalNodes() != 0 ) {
13166 if ( !t1.isEmpty() ) {
13169 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
13170 t2.deleteSubtree( t2.getNode( "A" ), false );
13171 t2.toNewHampshireX();
13172 if ( t2.getNumberOfExternalNodes() != 5 ) {
13175 t2.deleteSubtree( t2.getNode( "abc" ), false );
13176 t2.toNewHampshireX();
13177 if ( t2.getNumberOfExternalNodes() != 3 ) {
13180 t2.deleteSubtree( t2.getNode( "def" ), false );
13181 t2.toNewHampshireX();
13182 if ( t2.getNumberOfExternalNodes() != 1 ) {
13186 catch ( final Exception e ) {
13187 e.printStackTrace( System.out );
13193 private static boolean testSupportCount() {
13195 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13196 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
13197 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
13198 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
13199 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))" + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
13201 SupportCount.count( t0_1, phylogenies_1, true, false );
13202 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
13203 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
13204 + "(((((A,B),C),D),E),((F,G),X))" + "(((((A,Y),B),C),D),((F,G),E))" + "(((((A,B),C),D),E),(F,G))"
13205 + "(((((A,B),C),D),E),(F,G))" + "(((((A,B),C),D),E),(F,G))" + "(((((A,B),C),D),E),(F,G),Z)"
13206 + "(((((A,B),C),D),E),(F,G))" + "((((((A,B),C),D),E),F),G)" + "(((((X,Y),F,G),E),((A,B),C)),D)",
13208 SupportCount.count( t0_2, phylogenies_2, true, false );
13209 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
13210 while ( it.hasNext() ) {
13211 final PhylogenyNode n = it.next();
13212 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
13216 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
13217 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
13218 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
13219 SupportCount.count( t0_3, phylogenies_3, true, false );
13220 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
13221 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
13224 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
13227 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
13230 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
13233 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
13236 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
13239 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
13242 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
13245 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
13248 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
13251 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13252 final Phylogeny[] phylogenies_4 = factory
13253 .create( "((((((A,X),C),B),D),E),F) " + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
13254 SupportCount.count( t0_4, phylogenies_4, true, false );
13255 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
13256 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
13259 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
13262 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
13265 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
13268 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
13271 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
13274 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
13277 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
13280 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
13283 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
13286 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13287 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13288 double d = SupportCount.compare( b1, a, true, true, true );
13289 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
13292 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13293 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13294 d = SupportCount.compare( b2, a, true, true, true );
13295 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
13298 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13299 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
13300 d = SupportCount.compare( b3, a, true, true, true );
13301 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
13304 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
13305 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
13306 d = SupportCount.compare( b4, a, true, true, false );
13307 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
13311 catch ( final Exception e ) {
13312 e.printStackTrace( System.out );
13318 private static boolean testSupportTransfer() {
13320 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13321 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)",
13322 new NHXParser() )[ 0 ];
13323 final Phylogeny p2 = factory.create(
13324 "(((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)",
13325 new NHXParser() )[ 0 ];
13326 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
13329 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
13332 support_transfer.moveBranchLengthsToBootstrap( p1 );
13333 support_transfer.transferSupportValues( p1, p2 );
13334 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
13337 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
13340 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
13343 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
13346 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
13349 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
13352 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
13355 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
13359 catch ( final Exception e ) {
13360 e.printStackTrace( System.out );
13366 private static boolean testTaxonomyExtraction() {
13368 final PhylogenyNode n0 = PhylogenyNode
13369 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13370 if ( n0.getNodeData().isHasTaxonomy() ) {
13373 final PhylogenyNode n1 = PhylogenyNode
13374 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13375 if ( n1.getNodeData().isHasTaxonomy() ) {
13376 System.out.println( n1.toString() );
13379 final PhylogenyNode n2x = PhylogenyNode
13380 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13381 if ( n2x.getNodeData().isHasTaxonomy() ) {
13384 final PhylogenyNode n3 = PhylogenyNode
13385 .createInstanceFromNhxString( "BLAGG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13386 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13387 System.out.println( n3.toString() );
13390 final PhylogenyNode n4 = PhylogenyNode
13391 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13392 if ( n4.getNodeData().isHasTaxonomy() ) {
13393 System.out.println( n4.toString() );
13396 final PhylogenyNode n5 = PhylogenyNode
13397 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13398 if ( n5.getNodeData().isHasTaxonomy() ) {
13399 System.out.println( n5.toString() );
13402 final PhylogenyNode n6 = PhylogenyNode
13403 .createInstanceFromNhxString( "BLAGG-12345-blag",
13404 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13405 if ( n6.getNodeData().isHasTaxonomy() ) {
13406 System.out.println( n6.toString() );
13409 final PhylogenyNode n7 = PhylogenyNode
13410 .createInstanceFromNhxString( "BL-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13411 if ( n7.getNodeData().isHasTaxonomy() ) {
13412 System.out.println( n7.toString() );
13415 final PhylogenyNode n8 = PhylogenyNode
13416 .createInstanceFromNhxString( "BLAGG_12345-blag",
13417 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13418 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13419 System.out.println( n8.toString() );
13422 final PhylogenyNode n9 = PhylogenyNode
13423 .createInstanceFromNhxString( "BLAGG_12345/blag",
13424 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13425 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13426 System.out.println( n9.toString() );
13429 final PhylogenyNode n10x = PhylogenyNode
13430 .createInstanceFromNhxString( "BLAG!_12X45-blag",
13431 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13432 if ( n10x.getNodeData().isHasTaxonomy() ) {
13433 System.out.println( n10x.toString() );
13436 final PhylogenyNode n10xx = PhylogenyNode
13437 .createInstanceFromNhxString( "BLAG!_1YX45-blag",
13438 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13439 if ( n10xx.getNodeData().isHasTaxonomy() ) {
13440 System.out.println( n10xx.toString() );
13443 final PhylogenyNode n10 = PhylogenyNode
13444 .createInstanceFromNhxString( "BLAGG_9YX45-blag",
13445 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13446 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
13447 System.out.println( n10.toString() );
13450 final PhylogenyNode n10v = PhylogenyNode
13451 .createInstanceFromNhxString( "BLAGG_BPM1-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13452 if ( !n10v.getNodeData().getTaxonomy().getTaxonomyCode().equals( "BPM1" ) ) {
13453 System.out.println( n10v.toString() );
13456 final PhylogenyNode n10v2 = PhylogenyNode
13457 .createInstanceFromNhxString( "BLAGG_ABV-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13458 if ( !n10v2.getNodeData().getTaxonomy().getTaxonomyCode().equals( "ABV" ) ) {
13459 System.out.println( n10v2.toString() );
13462 final PhylogenyNode n11 = PhylogenyNode
13463 .createInstanceFromNhxString( "BLAG@_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13464 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13465 System.out.println( n11.toString() );
13468 final PhylogenyNode n12 = PhylogenyNode
13469 .createInstanceFromNhxString( "BLA_G_Mus_musculus_musculus",
13470 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13471 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13472 System.out.println( n12.toString() );
13475 final PhylogenyNode n13 = PhylogenyNode
13476 .createInstanceFromNhxString( "BLAaG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13477 if ( n13.getNodeData().isHasTaxonomy() ) {
13478 System.out.println( n13.toString() );
13481 final PhylogenyNode n14 = PhylogenyNode
13482 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13483 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13484 System.out.println( n14.toString() );
13487 final PhylogenyNode n15 = PhylogenyNode
13488 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13489 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13490 System.out.println( n15.toString() );
13493 final PhylogenyNode n16 = PhylogenyNode
13494 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13495 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13496 System.out.println( n16.toString() );
13499 final PhylogenyNode n17 = PhylogenyNode
13500 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13501 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13502 System.out.println( n17.toString() );
13505 final PhylogenyNode n18 = PhylogenyNode
13506 .createInstanceFromNhxString( "Mus_musculus_musculus_392",
13507 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13508 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13509 System.out.println( n18.toString() );
13512 final PhylogenyNode n19 = PhylogenyNode
13513 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
13514 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13515 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13516 System.out.println( n19.toString() );
13519 final PhylogenyNode n20 = PhylogenyNode
13520 .createInstanceFromNhxString( "Mus musculus musculus 392",
13521 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13522 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13523 System.out.println( n20.toString() );
13526 final PhylogenyNode n21 = PhylogenyNode
13527 .createInstanceFromNhxString( "Mus musculus musculus K392",
13528 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13529 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13530 System.out.println( n21.toString() );
13533 final PhylogenyNode n23 = PhylogenyNode
13534 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
13535 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13536 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13537 System.out.println( n23.toString() );
13540 final PhylogenyNode n24 = PhylogenyNode
13541 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13542 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13543 System.out.println( n24.toString() );
13547 final PhylogenyNode n25 = PhylogenyNode
13548 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
13549 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13550 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
13551 System.out.println( n25.toString() );
13554 final PhylogenyNode n26 = PhylogenyNode
13555 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
13556 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13557 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13558 System.out.println( n26.toString() );
13561 final PhylogenyNode n27 = PhylogenyNode
13562 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13563 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13564 System.out.println( n27.toString() );
13568 catch ( final Exception e ) {
13569 e.printStackTrace( System.out );
13575 private static boolean testTreeCopy() {
13577 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
13578 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
13579 final Phylogeny t1 = t0.copy();
13580 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
13583 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13586 t0.deleteSubtree( t0.getNode( "c" ), true );
13587 t0.deleteSubtree( t0.getNode( "a" ), true );
13588 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
13589 t0.getNode( "b" ).setName( "Bee" );
13590 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
13593 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13596 t0.deleteSubtree( t0.getNode( "e" ), true );
13597 t0.deleteSubtree( t0.getNode( "Bee" ), true );
13598 t0.deleteSubtree( t0.getNode( "d" ), true );
13599 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13603 catch ( final Exception e ) {
13604 e.printStackTrace();
13610 private static boolean testTreeMethods() {
13612 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13613 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
13614 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
13615 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
13616 System.out.println( t0.toNewHampshireX() );
13619 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
13620 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
13621 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
13624 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
13627 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
13631 catch ( final Exception e ) {
13632 e.printStackTrace( System.out );
13638 private static boolean testPhylogenyMethods() {
13640 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13641 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)r", new NHXParser() )[ 0 ];
13643 if ( PhylogenyMethods.calculateLevel( t0.getNode( "A" ) ) != 0 ) {
13646 if ( PhylogenyMethods.calculateLevel( t0.getNode( "B" ) ) != 0 ) {
13649 if ( PhylogenyMethods.calculateLevel( t0.getNode( "ab" ) ) != 1 ) {
13652 if ( PhylogenyMethods.calculateLevel( t0.getNode( "C" ) ) != 0 ) {
13655 if ( PhylogenyMethods.calculateLevel( t0.getNode( "abc" ) ) != 2 ) {
13658 if ( PhylogenyMethods.calculateLevel( t0.getNode( "D" ) ) != 0 ) {
13661 if ( PhylogenyMethods.calculateLevel( t0.getNode( "abcd" ) ) != 3 ) {
13664 if ( PhylogenyMethods.calculateLevel( t0.getNode( "E" ) ) != 0 ) {
13667 if ( PhylogenyMethods.calculateLevel( t0.getNode( "r" ) ) != 4 ) {
13670 final Phylogeny t1 = factory.create( "((((A,B)ab,C)abc,D)abcd,E,((((((X)1)2)3)4)5)6)r", new NHXParser() )[ 0 ];
13671 if ( PhylogenyMethods.calculateLevel( t1.getNode( "r" ) ) != 7 ) {
13674 if ( PhylogenyMethods.calculateLevel( t1.getNode( "X" ) ) != 0 ) {
13677 if ( PhylogenyMethods.calculateLevel( t1.getNode( "6" ) ) != 6 ) {
13680 if ( PhylogenyMethods.calculateLevel( t1.getNode( "5" ) ) != 5 ) {
13683 if ( PhylogenyMethods.calculateLevel( t1.getNode( "4" ) ) != 4 ) {
13686 if ( PhylogenyMethods.calculateLevel( t1.getNode( "3" ) ) != 3 ) {
13689 if ( PhylogenyMethods.calculateLevel( t1.getNode( "2" ) ) != 2 ) {
13692 if ( PhylogenyMethods.calculateLevel( t1.getNode( "1" ) ) != 1 ) {
13695 if ( PhylogenyMethods.calculateLevel( t1.getNode( "abcd" ) ) != 3 ) {
13700 catch ( final Exception e ) {
13701 e.printStackTrace( System.out );
13707 private static boolean testUniprotEntryRetrieval() {
13709 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 5000 );
13710 if ( !entry.getAccession().equals( "P12345" ) ) {
13713 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
13716 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
13719 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
13722 if ( !entry.getGeneName().equals( "GOT2" ) ) {
13725 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
13728 if ( entry.getMolecularSequence() == null ) {
13731 if ( !entry.getMolecularSequence().getMolecularSequenceAsString()
13732 .startsWith( "MALLHSARVLSGVASAFHPGLAAAASARASSWWAHVEMGPPDPILGVTEAYKRDTNSKKMNLGVGAYRDDNGKPYVLPSVRKAEAQIAAKGLDKEYLPIGGLAEFCRASAELALGENSEV" )
13733 || !entry.getMolecularSequence().getMolecularSequenceAsString().endsWith( "LAHAIHQVTK" ) ) {
13734 System.out.println( "got: " + entry.getMolecularSequence().getMolecularSequenceAsString() );
13735 System.out.println( "expected something else." );
13739 catch ( final IOException e ) {
13740 System.out.println();
13741 System.out.println( "the following might be due to absence internet connection:" );
13742 e.printStackTrace( System.out );
13745 catch ( final NullPointerException f ) {
13746 f.printStackTrace( System.out );
13749 catch ( final Exception e ) {
13755 private static boolean testUniprotTaxonomySearch() {
13757 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
13759 if ( results.size() != 1 ) {
13762 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13765 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13768 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13771 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13774 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13778 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
13779 if ( results.size() != 1 ) {
13782 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13785 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13788 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13791 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13794 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13798 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
13799 if ( results.size() != 1 ) {
13802 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13805 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13808 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13811 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13814 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13818 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
13819 if ( results.size() != 1 ) {
13822 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13825 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13828 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13831 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13834 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13837 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
13840 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
13843 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13844 .equals( "Nematostella vectensis" ) ) {
13845 System.out.println( results.get( 0 ).getLineage() );
13850 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
13851 if ( results.size() != 1 ) {
13854 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13857 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13860 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13863 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13866 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13869 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13870 .equals( "Xenopus tropicalis" ) ) {
13871 System.out.println( results.get( 0 ).getLineage() );
13876 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
13877 if ( results.size() != 1 ) {
13880 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13883 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13886 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13889 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13892 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13895 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13896 .equals( "Xenopus tropicalis" ) ) {
13897 System.out.println( results.get( 0 ).getLineage() );
13902 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
13903 if ( results.size() != 1 ) {
13906 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13909 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13912 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13915 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13918 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13921 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13922 .equals( "Xenopus tropicalis" ) ) {
13923 System.out.println( results.get( 0 ).getLineage() );
13927 catch ( final IOException e ) {
13928 System.out.println();
13929 System.out.println( "the following might be due to absence internet connection:" );
13930 e.printStackTrace( System.out );
13933 catch ( final Exception e ) {