2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.test;
28 import java.io.ByteArrayInputStream;
30 import java.io.FileInputStream;
31 import java.io.IOException;
32 import java.util.ArrayList;
33 import java.util.Date;
34 import java.util.HashSet;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.Locale;
39 import java.util.SortedSet;
41 import org.forester.application.support_transfer;
42 import org.forester.archaeopteryx.TreePanelUtil;
43 import org.forester.development.DevelopmentTools;
44 import org.forester.evoinference.TestPhylogenyReconstruction;
45 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
46 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
47 import org.forester.go.TestGo;
48 import org.forester.io.parsers.FastaParser;
49 import org.forester.io.parsers.GeneralMsaParser;
50 import org.forester.io.parsers.HmmscanPerDomainTableParser;
51 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
52 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
53 import org.forester.io.parsers.nexus.NexusCharactersParser;
54 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
55 import org.forester.io.parsers.nhx.NHXParser;
56 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
57 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
58 import org.forester.io.parsers.tol.TolParser;
59 import org.forester.io.parsers.util.ParserUtils;
60 import org.forester.io.writers.PhylogenyWriter;
61 import org.forester.io.writers.SequenceWriter;
62 import org.forester.msa.BasicMsa;
63 import org.forester.msa.Mafft;
64 import org.forester.msa.Msa;
65 import org.forester.msa.MsaInferrer;
66 import org.forester.msa.MsaMethods;
67 import org.forester.pccx.TestPccx;
68 import org.forester.phylogeny.Phylogeny;
69 import org.forester.phylogeny.PhylogenyBranch;
70 import org.forester.phylogeny.PhylogenyMethods;
71 import org.forester.phylogeny.PhylogenyNode;
72 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
73 import org.forester.phylogeny.data.Accession;
74 import org.forester.phylogeny.data.Accession.Source;
75 import org.forester.phylogeny.data.BinaryCharacters;
76 import org.forester.phylogeny.data.BranchWidth;
77 import org.forester.phylogeny.data.Confidence;
78 import org.forester.phylogeny.data.Distribution;
79 import org.forester.phylogeny.data.DomainArchitecture;
80 import org.forester.phylogeny.data.Event;
81 import org.forester.phylogeny.data.Identifier;
82 import org.forester.phylogeny.data.PhylogenyData;
83 import org.forester.phylogeny.data.PhylogenyDataUtil;
84 import org.forester.phylogeny.data.Polygon;
85 import org.forester.phylogeny.data.PropertiesMap;
86 import org.forester.phylogeny.data.Property;
87 import org.forester.phylogeny.data.Property.AppliesTo;
88 import org.forester.phylogeny.data.ProteinDomain;
89 import org.forester.phylogeny.data.Taxonomy;
90 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
91 import org.forester.phylogeny.factories.PhylogenyFactory;
92 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
93 import org.forester.protein.BasicDomain;
94 import org.forester.protein.BasicProtein;
95 import org.forester.protein.Domain;
96 import org.forester.protein.Protein;
97 import org.forester.protein.ProteinId;
98 import org.forester.rio.TestRIO;
99 import org.forester.sdi.SDI;
100 import org.forester.sdi.SDIR;
101 import org.forester.sdi.TestGSDI;
102 import org.forester.sequence.BasicSequence;
103 import org.forester.sequence.Sequence;
104 import org.forester.species.BasicSpecies;
105 import org.forester.species.Species;
106 import org.forester.surfacing.TestSurfacing;
107 import org.forester.tools.ConfidenceAssessor;
108 import org.forester.tools.SupportCount;
109 import org.forester.tools.TreeSplitMatrix;
110 import org.forester.util.AsciiHistogram;
111 import org.forester.util.BasicDescriptiveStatistics;
112 import org.forester.util.BasicTable;
113 import org.forester.util.BasicTableParser;
114 import org.forester.util.DescriptiveStatistics;
115 import org.forester.util.ForesterConstants;
116 import org.forester.util.ForesterUtil;
117 import org.forester.util.GeneralTable;
118 import org.forester.util.SequenceAccessionTools;
119 import org.forester.ws.seqdb.SequenceDatabaseEntry;
120 import org.forester.ws.seqdb.SequenceDbWsTools;
121 import org.forester.ws.seqdb.UniProtTaxonomy;
122 import org.forester.ws.wabi.TxSearch;
123 import org.forester.ws.wabi.TxSearch.RANKS;
124 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
125 import org.forester.ws.wabi.TxSearch.TAX_RANK;
127 @SuppressWarnings( "unused")
128 public final class Test {
130 private final static boolean PERFORM_DB_TESTS = true;
131 private final static double ZERO_DIFF = 1.0E-9;
132 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
133 + ForesterUtil.getFileSeparator() + "test_data"
134 + ForesterUtil.getFileSeparator();
135 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
136 + ForesterUtil.getFileSeparator() + "resources"
137 + ForesterUtil.getFileSeparator();
138 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
139 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
140 + ForesterConstants.PHYLO_XML_VERSION + "/"
141 + ForesterConstants.PHYLO_XML_XSD;
142 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
143 + ForesterConstants.PHYLO_XML_VERSION + "/"
144 + ForesterConstants.PHYLO_XML_XSD;
146 public 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." );
222 System.out.print( "Sequence writer: " );
223 if ( testSequenceWriter() ) {
224 System.out.println( "OK." );
228 System.out.println( "failed." );
231 System.out.print( "Sequence id parsing: " );
232 if ( testSequenceIdParsing() ) {
233 System.out.println( "OK." );
237 System.out.println( "failed." );
240 System.out.print( "UniProtKB id extraction: " );
241 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
242 System.out.println( "OK." );
246 System.out.println( "failed." );
249 System.out.print( "Sequence DB tools 1: " );
250 if ( testSequenceDbWsTools1() ) {
251 System.out.println( "OK." );
255 System.out.println( "failed." );
258 if ( PERFORM_DB_TESTS ) {
259 System.out.print( "Sequence DB tools 2: " );
260 if ( testSequenceDbWsTools2() ) {
261 System.out.println( "OK." );
265 System.out.println( "failed." );
271 System.out.print( "Hmmscan output parser: " );
272 if ( testHmmscanOutputParser() ) {
273 System.out.println( "OK." );
277 System.out.println( "failed." );
280 System.out.print( "Taxonomy code extraction: " );
281 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
282 System.out.println( "OK." );
286 System.out.println( "failed." );
289 System.out.print( "SN extraction: " );
290 if ( Test.testExtractSNFromNodeName() ) {
291 System.out.println( "OK." );
295 System.out.println( "failed." );
298 System.out.print( "Taxonomy extraction (general): " );
299 if ( Test.testTaxonomyExtraction() ) {
300 System.out.println( "OK." );
304 System.out.println( "failed." );
307 System.out.print( "Uri for Aptx web sequence accession: " );
308 if ( Test.testCreateUriForSeqWeb() ) {
309 System.out.println( "OK." );
313 System.out.println( "failed." );
316 System.out.print( "Basic node construction and parsing of NHX (node level): " );
317 if ( Test.testNHXNodeParsing() ) {
318 System.out.println( "OK." );
322 System.out.println( "failed." );
325 System.out.print( "NHX parsing iterating: " );
326 if ( Test.testNHParsingIter() ) {
327 System.out.println( "OK." );
331 System.out.println( "failed." );
334 System.out.print( "NH parsing: " );
335 if ( Test.testNHParsing() ) {
336 System.out.println( "OK." );
340 System.out.println( "failed." );
343 System.out.print( "Conversion to NHX (node level): " );
344 if ( Test.testNHXconversion() ) {
345 System.out.println( "OK." );
349 System.out.println( "failed." );
352 System.out.print( "NHX parsing: " );
353 if ( Test.testNHXParsing() ) {
354 System.out.println( "OK." );
358 System.out.println( "failed." );
361 System.out.print( "NHX parsing with quotes: " );
362 if ( Test.testNHXParsingQuotes() ) {
363 System.out.println( "OK." );
367 System.out.println( "failed." );
370 System.out.print( "NHX parsing (MrBayes): " );
371 if ( Test.testNHXParsingMB() ) {
372 System.out.println( "OK." );
376 System.out.println( "failed." );
379 System.out.print( "Nexus characters parsing: " );
380 if ( Test.testNexusCharactersParsing() ) {
381 System.out.println( "OK." );
385 System.out.println( "failed." );
388 System.out.print( "Nexus tree parsing iterating: " );
389 if ( Test.testNexusTreeParsingIterating() ) {
390 System.out.println( "OK." );
394 System.out.println( "failed." );
397 System.out.print( "Nexus tree parsing: " );
398 if ( Test.testNexusTreeParsing() ) {
399 System.out.println( "OK." );
403 System.out.println( "failed." );
406 System.out.print( "Nexus tree parsing (translating): " );
407 if ( Test.testNexusTreeParsingTranslating() ) {
408 System.out.println( "OK." );
412 System.out.println( "failed." );
415 System.out.print( "Nexus matrix parsing: " );
416 if ( Test.testNexusMatrixParsing() ) {
417 System.out.println( "OK." );
421 System.out.println( "failed." );
424 System.out.print( "Basic phyloXML parsing: " );
425 if ( Test.testBasicPhyloXMLparsing() ) {
426 System.out.println( "OK." );
430 System.out.println( "failed." );
433 System.out.print( "Basic phyloXML parsing (validating against schema): " );
434 if ( testBasicPhyloXMLparsingValidating() ) {
435 System.out.println( "OK." );
439 System.out.println( "failed." );
442 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
443 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
444 System.out.println( "OK." );
448 System.out.println( "failed." );
451 System.out.print( "phyloXML Distribution Element: " );
452 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
453 System.out.println( "OK." );
457 System.out.println( "failed." );
460 System.out.print( "Tol XML parsing: " );
461 if ( Test.testBasicTolXMLparsing() ) {
462 System.out.println( "OK." );
466 System.out.println( "failed." );
469 System.out.print( "Copying of node data: " );
470 if ( Test.testCopyOfNodeData() ) {
471 System.out.println( "OK." );
475 System.out.println( "failed." );
478 System.out.print( "Basic tree methods: " );
479 if ( Test.testBasicTreeMethods() ) {
480 System.out.println( "OK." );
484 System.out.println( "failed." );
487 System.out.print( "Tree methods: " );
488 if ( Test.testTreeMethods() ) {
489 System.out.println( "OK." );
493 System.out.println( "failed." );
496 System.out.print( "Postorder Iterator: " );
497 if ( Test.testPostOrderIterator() ) {
498 System.out.println( "OK." );
502 System.out.println( "failed." );
505 System.out.print( "Preorder Iterator: " );
506 if ( Test.testPreOrderIterator() ) {
507 System.out.println( "OK." );
511 System.out.println( "failed." );
514 System.out.print( "Levelorder Iterator: " );
515 if ( Test.testLevelOrderIterator() ) {
516 System.out.println( "OK." );
520 System.out.println( "failed." );
523 System.out.print( "Re-id methods: " );
524 if ( Test.testReIdMethods() ) {
525 System.out.println( "OK." );
529 System.out.println( "failed." );
532 System.out.print( "Methods on last external nodes: " );
533 if ( Test.testLastExternalNodeMethods() ) {
534 System.out.println( "OK." );
538 System.out.println( "failed." );
541 System.out.print( "Methods on external nodes: " );
542 if ( Test.testExternalNodeRelatedMethods() ) {
543 System.out.println( "OK." );
547 System.out.println( "failed." );
550 System.out.print( "Deletion of external nodes: " );
551 if ( Test.testDeletionOfExternalNodes() ) {
552 System.out.println( "OK." );
556 System.out.println( "failed." );
559 System.out.print( "Subtree deletion: " );
560 if ( Test.testSubtreeDeletion() ) {
561 System.out.println( "OK." );
565 System.out.println( "failed." );
568 System.out.print( "Phylogeny branch: " );
569 if ( Test.testPhylogenyBranch() ) {
570 System.out.println( "OK." );
574 System.out.println( "failed." );
577 System.out.print( "Rerooting: " );
578 if ( Test.testRerooting() ) {
579 System.out.println( "OK." );
583 System.out.println( "failed." );
586 System.out.print( "Mipoint rooting: " );
587 if ( Test.testMidpointrooting() ) {
588 System.out.println( "OK." );
592 System.out.println( "failed." );
595 System.out.print( "Node removal: " );
596 if ( Test.testNodeRemoval() ) {
597 System.out.println( "OK." );
601 System.out.println( "failed." );
604 System.out.print( "Support count: " );
605 if ( Test.testSupportCount() ) {
606 System.out.println( "OK." );
610 System.out.println( "failed." );
613 System.out.print( "Support transfer: " );
614 if ( Test.testSupportTransfer() ) {
615 System.out.println( "OK." );
619 System.out.println( "failed." );
622 System.out.print( "Finding of LCA: " );
623 if ( Test.testGetLCA() ) {
624 System.out.println( "OK." );
628 System.out.println( "failed." );
631 System.out.print( "Finding of LCA 2: " );
632 if ( Test.testGetLCA2() ) {
633 System.out.println( "OK." );
637 System.out.println( "failed." );
640 System.out.print( "Calculation of distance between nodes: " );
641 if ( Test.testGetDistance() ) {
642 System.out.println( "OK." );
646 System.out.println( "failed." );
649 System.out.print( "Descriptive statistics: " );
650 if ( Test.testDescriptiveStatistics() ) {
651 System.out.println( "OK." );
655 System.out.println( "failed." );
658 System.out.print( "Data objects and methods: " );
659 if ( Test.testDataObjects() ) {
660 System.out.println( "OK." );
664 System.out.println( "failed." );
667 System.out.print( "Properties map: " );
668 if ( Test.testPropertiesMap() ) {
669 System.out.println( "OK." );
673 System.out.println( "failed." );
676 System.out.print( "SDIse: " );
677 if ( Test.testSDIse() ) {
678 System.out.println( "OK." );
682 System.out.println( "failed." );
685 System.out.print( "SDIunrooted: " );
686 if ( Test.testSDIunrooted() ) {
687 System.out.println( "OK." );
691 System.out.println( "failed." );
694 System.out.print( "GSDI: " );
695 if ( TestGSDI.test() ) {
696 System.out.println( "OK." );
700 System.out.println( "failed." );
703 System.out.print( "RIO: " );
704 if ( TestRIO.test() ) {
705 System.out.println( "OK." );
709 System.out.println( "failed." );
712 System.out.print( "Phylogeny reconstruction:" );
713 System.out.println();
714 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
715 System.out.println( "OK." );
719 System.out.println( "failed." );
722 System.out.print( "Analysis of domain architectures: " );
723 System.out.println();
724 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
725 System.out.println( "OK." );
729 System.out.println( "failed." );
732 System.out.print( "GO: " );
733 System.out.println();
734 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
735 System.out.println( "OK." );
739 System.out.println( "failed." );
742 System.out.print( "Modeling tools: " );
743 if ( TestPccx.test() ) {
744 System.out.println( "OK." );
748 System.out.println( "failed." );
751 System.out.print( "Split Matrix strict: " );
752 if ( Test.testSplitStrict() ) {
753 System.out.println( "OK." );
757 System.out.println( "failed." );
760 System.out.print( "Split Matrix: " );
761 if ( Test.testSplit() ) {
762 System.out.println( "OK." );
766 System.out.println( "failed." );
769 System.out.print( "Confidence Assessor: " );
770 if ( Test.testConfidenceAssessor() ) {
771 System.out.println( "OK." );
775 System.out.println( "failed." );
778 System.out.print( "Basic table: " );
779 if ( Test.testBasicTable() ) {
780 System.out.println( "OK." );
784 System.out.println( "failed." );
787 System.out.print( "General table: " );
788 if ( Test.testGeneralTable() ) {
789 System.out.println( "OK." );
793 System.out.println( "failed." );
796 System.out.print( "Amino acid sequence: " );
797 if ( Test.testAminoAcidSequence() ) {
798 System.out.println( "OK." );
802 System.out.println( "failed." );
805 System.out.print( "General MSA parser: " );
806 if ( Test.testGeneralMsaParser() ) {
807 System.out.println( "OK." );
811 System.out.println( "failed." );
814 System.out.print( "Fasta parser for msa: " );
815 if ( Test.testFastaParser() ) {
816 System.out.println( "OK." );
820 System.out.println( "failed." );
823 System.out.print( "Creation of balanced phylogeny: " );
824 if ( Test.testCreateBalancedPhylogeny() ) {
825 System.out.println( "OK." );
829 System.out.println( "failed." );
832 System.out.print( "EMBL Entry Retrieval: " );
833 if ( Test.testEmblEntryRetrieval() ) {
834 System.out.println( "OK." );
838 System.out.println( "failed." );
841 if ( PERFORM_DB_TESTS ) {
842 System.out.print( "Uniprot Entry Retrieval: " );
843 if ( Test.testUniprotEntryRetrieval() ) {
844 System.out.println( "OK." );
848 System.out.println( "failed." );
852 if ( PERFORM_DB_TESTS ) {
853 System.out.print( "Uniprot Taxonomy Search: " );
854 if ( Test.testUniprotTaxonomySearch() ) {
855 System.out.println( "OK." );
859 System.out.println( "failed." );
865 final String os = ForesterUtil.OS_NAME.toLowerCase();
866 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
867 path = "/usr/local/bin/mafft";
869 else if ( os.indexOf( "win" ) >= 0 ) {
870 path = "C:\\Program Files\\mafft-win\\mafft.bat";
873 path = "/home/czmasek/bin/mafft";
875 if ( !MsaInferrer.isInstalled( path ) ) {
878 if ( !MsaInferrer.isInstalled( path ) ) {
879 path = "/usr/local/bin/mafft";
881 if ( MsaInferrer.isInstalled( path ) ) {
882 System.out.print( "MAFFT (external program): " );
883 if ( Test.testMafft( path ) ) {
884 System.out.println( "OK." );
888 System.out.println( "failed [will not count towards failed tests]" );
892 System.out.print( "Next nodes with collapsed: " );
893 if ( Test.testNextNodeWithCollapsing() ) {
894 System.out.println( "OK." );
898 System.out.println( "failed." );
901 System.out.print( "Simple MSA quality: " );
902 if ( Test.testMsaQualityMethod() ) {
903 System.out.println( "OK." );
907 System.out.println( "failed." );
910 System.out.println();
911 final Runtime rt = java.lang.Runtime.getRuntime();
912 final long free_memory = rt.freeMemory() / 1000000;
913 final long total_memory = rt.totalMemory() / 1000000;
914 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
915 + free_memory + "MB, total memory: " + total_memory + "MB)" );
916 System.out.println();
917 System.out.println( "Successful tests: " + succeeded );
918 System.out.println( "Failed tests: " + failed );
919 System.out.println();
921 System.out.println( "OK." );
924 System.out.println( "Not OK." );
928 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
929 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
933 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
934 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
937 private static boolean testAminoAcidSequence() {
939 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
940 if ( aa1.getLength() != 13 ) {
943 if ( aa1.getResidueAt( 0 ) != 'A' ) {
946 if ( aa1.getResidueAt( 2 ) != 'K' ) {
949 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
952 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
953 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
956 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
957 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
960 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
961 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
965 catch ( final Exception e ) {
972 private static boolean testBasicDomain() {
974 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
975 if ( !pd.getDomainId().equals( "id" ) ) {
978 if ( pd.getNumber() != 1 ) {
981 if ( pd.getTotalCount() != 4 ) {
984 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
987 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
988 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
989 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
990 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
991 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
992 if ( !a1.equals( a1 ) ) {
995 if ( !a1.equals( a1_copy ) ) {
998 if ( !a1.equals( a1_equal ) ) {
1001 if ( !a1.equals( a2 ) ) {
1004 if ( a1.equals( a3 ) ) {
1007 if ( a1.compareTo( a1 ) != 0 ) {
1010 if ( a1.compareTo( a1_copy ) != 0 ) {
1013 if ( a1.compareTo( a1_equal ) != 0 ) {
1016 if ( a1.compareTo( a2 ) != 0 ) {
1019 if ( a1.compareTo( a3 ) == 0 ) {
1023 catch ( final Exception e ) {
1024 e.printStackTrace( System.out );
1030 private static boolean testBasicNodeMethods() {
1032 if ( PhylogenyNode.getNodeCount() != 0 ) {
1035 final PhylogenyNode n1 = new PhylogenyNode();
1036 final PhylogenyNode n2 = PhylogenyNode
1037 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1038 final PhylogenyNode n3 = PhylogenyNode
1039 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1040 final PhylogenyNode n4 = PhylogenyNode
1041 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1042 if ( n1.isHasAssignedEvent() ) {
1045 if ( PhylogenyNode.getNodeCount() != 4 ) {
1048 if ( n3.getIndicator() != 0 ) {
1051 if ( n3.getNumberOfExternalNodes() != 1 ) {
1054 if ( !n3.isExternal() ) {
1057 if ( !n3.isRoot() ) {
1060 if ( !n4.getName().equals( "n4" ) ) {
1064 catch ( final Exception e ) {
1065 e.printStackTrace( System.out );
1071 private static boolean testBasicPhyloXMLparsing() {
1073 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1074 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1075 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1077 if ( xml_parser.getErrorCount() > 0 ) {
1078 System.out.println( xml_parser.getErrorMessages().toString() );
1081 if ( phylogenies_0.length != 4 ) {
1084 final Phylogeny t1 = phylogenies_0[ 0 ];
1085 final Phylogeny t2 = phylogenies_0[ 1 ];
1086 final Phylogeny t3 = phylogenies_0[ 2 ];
1087 final Phylogeny t4 = phylogenies_0[ 3 ];
1088 if ( t1.getNumberOfExternalNodes() != 1 ) {
1091 if ( !t1.isRooted() ) {
1094 if ( t1.isRerootable() ) {
1097 if ( !t1.getType().equals( "gene_tree" ) ) {
1100 if ( t2.getNumberOfExternalNodes() != 2 ) {
1103 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1106 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1109 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1112 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1115 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1118 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1121 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1122 .startsWith( "actgtgggggt" ) ) {
1125 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1126 .startsWith( "ctgtgatgcat" ) ) {
1129 if ( t3.getNumberOfExternalNodes() != 4 ) {
1132 if ( !t1.getName().equals( "t1" ) ) {
1135 if ( !t2.getName().equals( "t2" ) ) {
1138 if ( !t3.getName().equals( "t3" ) ) {
1141 if ( !t4.getName().equals( "t4" ) ) {
1144 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1147 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1150 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1153 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1154 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1157 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1160 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1163 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1166 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1167 .equals( "apoptosis" ) ) {
1170 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1171 .equals( "GO:0006915" ) ) {
1174 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1175 .equals( "UniProtKB" ) ) {
1178 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1179 .equals( "experimental" ) ) {
1182 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1183 .equals( "function" ) ) {
1186 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1187 .getValue() != 1 ) {
1190 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1191 .getType().equals( "ml" ) ) {
1194 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1195 .equals( "apoptosis" ) ) {
1198 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1199 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1202 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1203 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1206 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1207 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1210 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1211 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1214 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1215 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1218 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1219 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1222 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1223 .equals( "GO:0005829" ) ) {
1226 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1227 .equals( "intracellular organelle" ) ) {
1230 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1233 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1234 .equals( "UniProt link" ) ) ) {
1237 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1240 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1241 if ( x.size() != 4 ) {
1245 for( final Accession acc : x ) {
1247 if ( !acc.getSource().equals( "KEGG" ) ) {
1250 if ( !acc.getValue().equals( "hsa:596" ) ) {
1257 catch ( final Exception e ) {
1258 e.printStackTrace( System.out );
1264 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1266 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1267 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1268 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1269 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1272 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1274 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1276 if ( xml_parser.getErrorCount() > 0 ) {
1277 System.out.println( xml_parser.getErrorMessages().toString() );
1280 if ( phylogenies_0.length != 4 ) {
1283 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1284 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1285 if ( phylogenies_t1.length != 1 ) {
1288 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1289 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1292 if ( !t1_rt.isRooted() ) {
1295 if ( t1_rt.isRerootable() ) {
1298 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1301 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1302 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1303 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1304 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1307 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1310 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1313 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1316 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1317 .startsWith( "actgtgggggt" ) ) {
1320 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1321 .startsWith( "ctgtgatgcat" ) ) {
1324 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1325 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1326 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1327 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1328 if ( phylogenies_1.length != 1 ) {
1331 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1332 if ( !t3_rt.getName().equals( "t3" ) ) {
1335 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1338 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1341 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1344 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1347 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1348 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1351 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1354 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1357 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1358 .equals( "UniProtKB" ) ) {
1361 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1362 .equals( "apoptosis" ) ) {
1365 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1366 .equals( "GO:0006915" ) ) {
1369 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1370 .equals( "UniProtKB" ) ) {
1373 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1374 .equals( "experimental" ) ) {
1377 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1378 .equals( "function" ) ) {
1381 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1382 .getValue() != 1 ) {
1385 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1386 .getType().equals( "ml" ) ) {
1389 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1390 .equals( "apoptosis" ) ) {
1393 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1394 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1397 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1398 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1401 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1402 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1405 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1406 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1409 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1410 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1413 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1414 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1417 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1418 .equals( "GO:0005829" ) ) {
1421 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1422 .equals( "intracellular organelle" ) ) {
1425 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1428 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1429 .equals( "UniProt link" ) ) ) {
1432 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1435 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1438 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1439 .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." ) ) ) {
1442 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1445 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1448 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1451 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1454 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1455 .equals( "ncbi" ) ) {
1458 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1461 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1462 .getName().equals( "B" ) ) {
1465 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1466 .getFrom() != 21 ) {
1469 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1472 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1473 .getLength() != 24 ) {
1476 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1477 .getConfidence() != 2144 ) {
1480 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1481 .equals( "pfam" ) ) {
1484 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1487 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1490 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1493 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1496 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1497 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1500 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1503 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1506 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1509 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1512 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1515 if ( taxbb.getSynonyms().size() != 2 ) {
1518 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1521 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1524 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1527 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1530 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1533 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1534 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1537 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1540 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1543 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1546 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1549 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1552 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1555 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1559 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1562 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1563 .equalsIgnoreCase( "435" ) ) {
1566 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1569 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1570 .equalsIgnoreCase( "443.7" ) ) {
1573 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1576 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1579 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1580 .equalsIgnoreCase( "433" ) ) {
1583 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
1584 .getCrossReferences();
1585 if ( x.size() != 4 ) {
1589 for( final Accession acc : x ) {
1591 if ( !acc.getSource().equals( "KEGG" ) ) {
1594 if ( !acc.getValue().equals( "hsa:596" ) ) {
1601 catch ( final Exception e ) {
1602 e.printStackTrace( System.out );
1608 private static boolean testBasicPhyloXMLparsingValidating() {
1610 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1611 PhyloXmlParser xml_parser = null;
1613 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1615 catch ( final Exception e ) {
1616 // Do nothing -- means were not running from jar.
1618 if ( xml_parser == null ) {
1619 xml_parser = new PhyloXmlParser();
1620 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1621 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1624 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1627 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1629 if ( xml_parser.getErrorCount() > 0 ) {
1630 System.out.println( xml_parser.getErrorMessages().toString() );
1633 if ( phylogenies_0.length != 4 ) {
1636 final Phylogeny t1 = phylogenies_0[ 0 ];
1637 final Phylogeny t2 = phylogenies_0[ 1 ];
1638 final Phylogeny t3 = phylogenies_0[ 2 ];
1639 final Phylogeny t4 = phylogenies_0[ 3 ];
1640 if ( !t1.getName().equals( "t1" ) ) {
1643 if ( !t2.getName().equals( "t2" ) ) {
1646 if ( !t3.getName().equals( "t3" ) ) {
1649 if ( !t4.getName().equals( "t4" ) ) {
1652 if ( t1.getNumberOfExternalNodes() != 1 ) {
1655 if ( t2.getNumberOfExternalNodes() != 2 ) {
1658 if ( t3.getNumberOfExternalNodes() != 4 ) {
1661 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
1662 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
1663 if ( xml_parser.getErrorCount() > 0 ) {
1664 System.out.println( "errors:" );
1665 System.out.println( xml_parser.getErrorMessages().toString() );
1668 if ( phylogenies_1.length != 4 ) {
1671 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
1673 if ( xml_parser.getErrorCount() > 0 ) {
1674 System.out.println( "errors:" );
1675 System.out.println( xml_parser.getErrorMessages().toString() );
1678 if ( phylogenies_2.length != 1 ) {
1681 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
1684 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
1686 if ( xml_parser.getErrorCount() > 0 ) {
1687 System.out.println( xml_parser.getErrorMessages().toString() );
1690 if ( phylogenies_3.length != 2 ) {
1693 final Phylogeny a = phylogenies_3[ 0 ];
1694 if ( !a.getName().equals( "tree 4" ) ) {
1697 if ( a.getNumberOfExternalNodes() != 3 ) {
1700 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
1703 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
1706 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
1708 if ( xml_parser.getErrorCount() > 0 ) {
1709 System.out.println( xml_parser.getErrorMessages().toString() );
1712 if ( phylogenies_4.length != 1 ) {
1715 final Phylogeny s = phylogenies_4[ 0 ];
1716 if ( s.getNumberOfExternalNodes() != 6 ) {
1719 s.getNode( "first" );
1721 s.getNode( "\"<a'b&c'd\">\"" );
1722 s.getNode( "'''\"" );
1723 s.getNode( "\"\"\"" );
1724 s.getNode( "dick & doof" );
1726 catch ( final Exception e ) {
1727 e.printStackTrace( System.out );
1733 private static boolean testBasicProtein() {
1735 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
1736 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1737 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1738 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
1739 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
1740 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
1741 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1742 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1743 p0.addProteinDomain( y );
1744 p0.addProteinDomain( e );
1745 p0.addProteinDomain( b );
1746 p0.addProteinDomain( c );
1747 p0.addProteinDomain( d );
1748 p0.addProteinDomain( a );
1749 p0.addProteinDomain( x );
1750 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
1753 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
1757 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
1758 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1759 aa0.addProteinDomain( a1 );
1760 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
1763 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
1767 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
1768 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1769 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1770 aa1.addProteinDomain( a11 );
1771 aa1.addProteinDomain( a12 );
1772 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
1775 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
1778 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1779 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
1782 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
1785 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
1788 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1789 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
1792 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
1795 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
1798 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
1801 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1802 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
1805 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
1808 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
1811 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
1814 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1815 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
1818 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
1821 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
1824 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
1828 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
1829 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1830 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1831 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
1832 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
1833 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
1834 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
1835 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
1836 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
1837 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
1838 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
1839 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1840 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1841 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
1842 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
1843 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
1844 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
1845 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
1846 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
1847 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
1848 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
1849 p00.addProteinDomain( y0 );
1850 p00.addProteinDomain( e0 );
1851 p00.addProteinDomain( b0 );
1852 p00.addProteinDomain( c0 );
1853 p00.addProteinDomain( d0 );
1854 p00.addProteinDomain( a0 );
1855 p00.addProteinDomain( x0 );
1856 p00.addProteinDomain( y1 );
1857 p00.addProteinDomain( y2 );
1858 p00.addProteinDomain( y3 );
1859 p00.addProteinDomain( e1 );
1860 p00.addProteinDomain( e2 );
1861 p00.addProteinDomain( e3 );
1862 p00.addProteinDomain( e4 );
1863 p00.addProteinDomain( e5 );
1864 p00.addProteinDomain( z0 );
1865 p00.addProteinDomain( z1 );
1866 p00.addProteinDomain( z2 );
1867 p00.addProteinDomain( zz0 );
1868 p00.addProteinDomain( zz1 );
1869 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
1872 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
1875 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
1878 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
1881 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" ) ) {
1884 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
1885 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1886 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
1887 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
1888 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
1889 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
1890 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
1891 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
1892 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
1893 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
1894 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
1895 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
1896 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
1897 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
1898 p.addProteinDomain( B15 );
1899 p.addProteinDomain( C50 );
1900 p.addProteinDomain( A60 );
1901 p.addProteinDomain( A30 );
1902 p.addProteinDomain( C70 );
1903 p.addProteinDomain( B35 );
1904 p.addProteinDomain( B40 );
1905 p.addProteinDomain( A0 );
1906 p.addProteinDomain( A10 );
1907 p.addProteinDomain( A20 );
1908 p.addProteinDomain( B25 );
1909 p.addProteinDomain( D80 );
1910 List<String> domains_ids = new ArrayList<String>();
1911 domains_ids.add( "A" );
1912 domains_ids.add( "B" );
1913 domains_ids.add( "C" );
1914 if ( !p.contains( domains_ids, false ) ) {
1917 if ( !p.contains( domains_ids, true ) ) {
1920 domains_ids.add( "X" );
1921 if ( p.contains( domains_ids, false ) ) {
1924 if ( p.contains( domains_ids, true ) ) {
1927 domains_ids = new ArrayList<String>();
1928 domains_ids.add( "A" );
1929 domains_ids.add( "C" );
1930 domains_ids.add( "D" );
1931 if ( !p.contains( domains_ids, false ) ) {
1934 if ( !p.contains( domains_ids, true ) ) {
1937 domains_ids = new ArrayList<String>();
1938 domains_ids.add( "A" );
1939 domains_ids.add( "D" );
1940 domains_ids.add( "C" );
1941 if ( !p.contains( domains_ids, false ) ) {
1944 if ( p.contains( domains_ids, true ) ) {
1947 domains_ids = new ArrayList<String>();
1948 domains_ids.add( "A" );
1949 domains_ids.add( "A" );
1950 domains_ids.add( "B" );
1951 if ( !p.contains( domains_ids, false ) ) {
1954 if ( !p.contains( domains_ids, true ) ) {
1957 domains_ids = new ArrayList<String>();
1958 domains_ids.add( "A" );
1959 domains_ids.add( "A" );
1960 domains_ids.add( "A" );
1961 domains_ids.add( "B" );
1962 domains_ids.add( "B" );
1963 if ( !p.contains( domains_ids, false ) ) {
1966 if ( !p.contains( domains_ids, true ) ) {
1969 domains_ids = new ArrayList<String>();
1970 domains_ids.add( "A" );
1971 domains_ids.add( "A" );
1972 domains_ids.add( "B" );
1973 domains_ids.add( "A" );
1974 domains_ids.add( "B" );
1975 domains_ids.add( "B" );
1976 domains_ids.add( "A" );
1977 domains_ids.add( "B" );
1978 domains_ids.add( "C" );
1979 domains_ids.add( "A" );
1980 domains_ids.add( "C" );
1981 domains_ids.add( "D" );
1982 if ( !p.contains( domains_ids, false ) ) {
1985 if ( p.contains( domains_ids, true ) ) {
1989 catch ( final Exception e ) {
1990 e.printStackTrace( System.out );
1996 private static boolean testBasicTable() {
1998 final BasicTable<String> t0 = new BasicTable<String>();
1999 if ( t0.getNumberOfColumns() != 0 ) {
2002 if ( t0.getNumberOfRows() != 0 ) {
2005 t0.setValue( 3, 2, "23" );
2006 t0.setValue( 10, 1, "error" );
2007 t0.setValue( 10, 1, "110" );
2008 t0.setValue( 9, 1, "19" );
2009 t0.setValue( 1, 10, "101" );
2010 t0.setValue( 10, 10, "1010" );
2011 t0.setValue( 100, 10, "10100" );
2012 t0.setValue( 0, 0, "00" );
2013 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2016 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2019 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2022 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2025 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2028 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2031 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2034 if ( t0.getNumberOfColumns() != 101 ) {
2037 if ( t0.getNumberOfRows() != 11 ) {
2040 if ( t0.getValueAsString( 49, 4 ) != null ) {
2043 final String l = ForesterUtil.getLineSeparator();
2044 final StringBuffer source = new StringBuffer();
2045 source.append( "" + l );
2046 source.append( "# 1 1 1 1 1 1 1 1" + l );
2047 source.append( " 00 01 02 03" + l );
2048 source.append( " 10 11 12 13 " + l );
2049 source.append( "20 21 22 23 " + l );
2050 source.append( " 30 31 32 33" + l );
2051 source.append( "40 41 42 43" + l );
2052 source.append( " # 1 1 1 1 1 " + l );
2053 source.append( "50 51 52 53 54" + l );
2054 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2055 if ( t1.getNumberOfColumns() != 5 ) {
2058 if ( t1.getNumberOfRows() != 6 ) {
2061 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2064 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2067 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2070 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2073 final StringBuffer source1 = new StringBuffer();
2074 source1.append( "" + l );
2075 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2076 source1.append( " 00; 01 ;02;03" + l );
2077 source1.append( " 10; 11; 12; 13 " + l );
2078 source1.append( "20; 21; 22; 23 " + l );
2079 source1.append( " 30; 31; 32; 33" + l );
2080 source1.append( "40;41;42;43" + l );
2081 source1.append( " # 1 1 1 1 1 " + l );
2082 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2083 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2084 if ( t2.getNumberOfColumns() != 5 ) {
2087 if ( t2.getNumberOfRows() != 6 ) {
2090 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2093 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2096 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2099 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2102 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2105 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2108 final StringBuffer source2 = new StringBuffer();
2109 source2.append( "" + l );
2110 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2111 source2.append( " 00; 01 ;02;03" + l );
2112 source2.append( " 10; 11; 12; 13 " + l );
2113 source2.append( "20; 21; 22; 23 " + l );
2114 source2.append( " " + l );
2115 source2.append( " 30; 31; 32; 33" + l );
2116 source2.append( "40;41;42;43" + l );
2117 source2.append( " comment: 1 1 1 1 1 " + l );
2118 source2.append( ";;;50 ; 52; 53;;54 " + l );
2119 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2125 if ( tl.size() != 2 ) {
2128 final BasicTable<String> t3 = tl.get( 0 );
2129 final BasicTable<String> t4 = tl.get( 1 );
2130 if ( t3.getNumberOfColumns() != 4 ) {
2133 if ( t3.getNumberOfRows() != 3 ) {
2136 if ( t4.getNumberOfColumns() != 4 ) {
2139 if ( t4.getNumberOfRows() != 3 ) {
2142 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2145 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2149 catch ( final Exception e ) {
2150 e.printStackTrace( System.out );
2156 private static boolean testBasicTolXMLparsing() {
2158 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2159 final TolParser parser = new TolParser();
2160 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2161 if ( parser.getErrorCount() > 0 ) {
2162 System.out.println( parser.getErrorMessages().toString() );
2165 if ( phylogenies_0.length != 1 ) {
2168 final Phylogeny t1 = phylogenies_0[ 0 ];
2169 if ( t1.getNumberOfExternalNodes() != 5 ) {
2172 if ( !t1.isRooted() ) {
2175 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2178 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2181 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2184 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2187 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2188 if ( parser.getErrorCount() > 0 ) {
2189 System.out.println( parser.getErrorMessages().toString() );
2192 if ( phylogenies_1.length != 1 ) {
2195 final Phylogeny t2 = phylogenies_1[ 0 ];
2196 if ( t2.getNumberOfExternalNodes() != 664 ) {
2199 if ( !t2.isRooted() ) {
2202 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2205 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2208 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2211 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2214 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2217 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2218 .equals( "Aquifex" ) ) {
2221 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2222 if ( parser.getErrorCount() > 0 ) {
2223 System.out.println( parser.getErrorMessages().toString() );
2226 if ( phylogenies_2.length != 1 ) {
2229 final Phylogeny t3 = phylogenies_2[ 0 ];
2230 if ( t3.getNumberOfExternalNodes() != 184 ) {
2233 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2236 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2239 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2242 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2243 if ( parser.getErrorCount() > 0 ) {
2244 System.out.println( parser.getErrorMessages().toString() );
2247 if ( phylogenies_3.length != 1 ) {
2250 final Phylogeny t4 = phylogenies_3[ 0 ];
2251 if ( t4.getNumberOfExternalNodes() != 1 ) {
2254 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2257 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2260 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2263 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2264 if ( parser.getErrorCount() > 0 ) {
2265 System.out.println( parser.getErrorMessages().toString() );
2268 if ( phylogenies_4.length != 1 ) {
2271 final Phylogeny t5 = phylogenies_4[ 0 ];
2272 if ( t5.getNumberOfExternalNodes() != 13 ) {
2275 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2278 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2281 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2285 catch ( final Exception e ) {
2286 e.printStackTrace( System.out );
2292 private static boolean testBasicTreeMethods() {
2294 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2295 final Phylogeny t1 = factory.create();
2296 if ( !t1.isEmpty() ) {
2299 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2300 if ( t2.getNumberOfExternalNodes() != 4 ) {
2303 if ( t2.getHeight() != 8.5 ) {
2306 if ( !t2.isCompletelyBinary() ) {
2309 if ( t2.isEmpty() ) {
2312 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2313 if ( t3.getNumberOfExternalNodes() != 5 ) {
2316 if ( t3.getHeight() != 11 ) {
2319 if ( t3.isCompletelyBinary() ) {
2322 final PhylogenyNode n = t3.getNode( "ABC" );
2323 final Phylogeny t4 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3,(F,G,H,I))", new NHXParser() )[ 0 ];
2324 if ( t4.getNumberOfExternalNodes() != 9 ) {
2327 if ( t4.getHeight() != 11 ) {
2330 if ( t4.isCompletelyBinary() ) {
2333 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)" );
2334 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2335 if ( t5.getNumberOfExternalNodes() != 8 ) {
2338 if ( t5.getHeight() != 15 ) {
2341 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)" );
2342 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2343 if ( t6.getHeight() != 15 ) {
2346 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)" );
2347 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2348 if ( t7.getHeight() != 15 ) {
2351 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)" );
2352 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2353 if ( t8.getNumberOfExternalNodes() != 10 ) {
2356 if ( t8.getHeight() != 15 ) {
2359 final char[] a9 = new char[] { 'a' };
2360 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2361 if ( t9.getHeight() != 0 ) {
2364 final char[] a10 = new char[] { 'a', ':', '6' };
2365 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2366 if ( t10.getHeight() != 6 ) {
2370 catch ( final Exception e ) {
2371 e.printStackTrace( System.out );
2377 private static boolean testConfidenceAssessor() {
2379 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2380 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2381 final Phylogeny[] ev0 = factory
2382 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2384 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2385 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2388 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2391 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2392 final Phylogeny[] ev1 = factory
2393 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
2395 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2396 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2399 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2402 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2403 final Phylogeny[] ev_b = factory
2404 .create( "((A,C),X);((A,X),C);(A,C);((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
2406 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2407 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2410 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2414 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2415 final Phylogeny[] ev1x = factory
2416 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
2418 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2419 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2422 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2425 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2426 final Phylogeny[] ev_bx = factory
2427 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
2429 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2430 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2433 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2437 final Phylogeny[] t2 = factory
2438 .create( "((((a,b),c),d),e);(((a,b),c),(d,e));(((((a,b),c),d),e),f);((((a,b),c),(d,e)),f);(((a,b),c),d,e);((a,b,c),d,e);",
2440 final Phylogeny[] ev2 = factory
2441 .create( "((((a,b),c),d),e);((((a,b),c),d),e);((((a,b),e),d),c);((((a,b),e),d),c);(((a,b),(c,d)),e);((a,b),x);((a,b),(x,y));(a,b);(a,e);(a,b,c);",
2443 for( final Phylogeny target : t2 ) {
2444 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2447 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2448 new NHXParser() )[ 0 ];
2449 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2450 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2451 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2454 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2457 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2461 catch ( final Exception e ) {
2462 e.printStackTrace();
2468 private static boolean testCopyOfNodeData() {
2470 final PhylogenyNode n1 = PhylogenyNode
2471 .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]" );
2472 final PhylogenyNode n2 = n1.copyNodeData();
2473 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2477 catch ( final Exception e ) {
2478 e.printStackTrace();
2484 private static boolean testCreateBalancedPhylogeny() {
2486 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
2487 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
2490 if ( p0.getNumberOfExternalNodes() != 15625 ) {
2493 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
2494 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
2497 if ( p1.getNumberOfExternalNodes() != 100 ) {
2501 catch ( final Exception e ) {
2502 e.printStackTrace();
2508 private static boolean testCreateUriForSeqWeb() {
2510 final PhylogenyNode n = new PhylogenyNode();
2511 n.setName( "tr|B3RJ64" );
2512 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
2515 n.setName( "B0LM41_HUMAN" );
2516 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
2519 n.setName( "NP_001025424" );
2520 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
2523 n.setName( "_NM_001030253-" );
2524 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
2527 n.setName( "XM_002122186" );
2528 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
2531 n.setName( "dgh_AAA34956_gdg" );
2532 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2535 n.setName( "AAA34956" );
2536 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2539 n.setName( "GI:394892" );
2540 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2541 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2544 n.setName( "gi_394892" );
2545 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2546 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2549 n.setName( "gi6335_gi_394892_56635_Gi_43" );
2550 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2551 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2554 n.setName( "P12345" );
2555 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2556 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2559 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
2560 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2561 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2565 catch ( final Exception e ) {
2566 e.printStackTrace( System.out );
2572 private static boolean testDataObjects() {
2574 final Confidence s0 = new Confidence();
2575 final Confidence s1 = new Confidence();
2576 if ( !s0.isEqual( s1 ) ) {
2579 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2580 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2581 if ( s2.isEqual( s1 ) ) {
2584 if ( !s2.isEqual( s3 ) ) {
2587 final Confidence s4 = ( Confidence ) s3.copy();
2588 if ( !s4.isEqual( s3 ) ) {
2595 final Taxonomy t1 = new Taxonomy();
2596 final Taxonomy t2 = new Taxonomy();
2597 final Taxonomy t3 = new Taxonomy();
2598 final Taxonomy t4 = new Taxonomy();
2599 final Taxonomy t5 = new Taxonomy();
2600 t1.setIdentifier( new Identifier( "ecoli" ) );
2601 t1.setTaxonomyCode( "ECOLI" );
2602 t1.setScientificName( "E. coli" );
2603 t1.setCommonName( "coli" );
2604 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2605 if ( !t1.isEqual( t0 ) ) {
2608 t2.setIdentifier( new Identifier( "ecoli" ) );
2609 t2.setTaxonomyCode( "OTHER" );
2610 t2.setScientificName( "what" );
2611 t2.setCommonName( "something" );
2612 if ( !t1.isEqual( t2 ) ) {
2615 t2.setIdentifier( new Identifier( "nemve" ) );
2616 if ( t1.isEqual( t2 ) ) {
2619 t1.setIdentifier( null );
2620 t3.setTaxonomyCode( "ECOLI" );
2621 t3.setScientificName( "what" );
2622 t3.setCommonName( "something" );
2623 if ( !t1.isEqual( t3 ) ) {
2626 t1.setIdentifier( null );
2627 t1.setTaxonomyCode( "" );
2628 t4.setScientificName( "E. ColI" );
2629 t4.setCommonName( "something" );
2630 if ( !t1.isEqual( t4 ) ) {
2633 t4.setScientificName( "B. subtilis" );
2634 t4.setCommonName( "something" );
2635 if ( t1.isEqual( t4 ) ) {
2638 t1.setIdentifier( null );
2639 t1.setTaxonomyCode( "" );
2640 t1.setScientificName( "" );
2641 t5.setCommonName( "COLI" );
2642 if ( !t1.isEqual( t5 ) ) {
2645 t5.setCommonName( "vibrio" );
2646 if ( t1.isEqual( t5 ) ) {
2651 final Identifier id0 = new Identifier( "123", "pfam" );
2652 final Identifier id1 = ( Identifier ) id0.copy();
2653 if ( !id1.isEqual( id1 ) ) {
2656 if ( !id1.isEqual( id0 ) ) {
2659 if ( !id0.isEqual( id1 ) ) {
2666 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
2667 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
2668 if ( !pd1.isEqual( pd1 ) ) {
2671 if ( !pd1.isEqual( pd0 ) ) {
2676 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
2677 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
2678 if ( !pd3.isEqual( pd3 ) ) {
2681 if ( !pd2.isEqual( pd3 ) ) {
2684 if ( !pd0.isEqual( pd3 ) ) {
2689 // DomainArchitecture
2690 // ------------------
2691 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
2692 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
2693 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
2694 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
2695 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
2696 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
2701 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
2702 if ( ds0.getNumberOfDomains() != 4 ) {
2705 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
2706 if ( !ds0.isEqual( ds0 ) ) {
2709 if ( !ds0.isEqual( ds1 ) ) {
2712 if ( ds1.getNumberOfDomains() != 4 ) {
2715 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
2720 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
2721 if ( ds0.isEqual( ds2 ) ) {
2727 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
2728 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
2729 System.out.println( ds3.toNHX() );
2732 if ( ds3.getNumberOfDomains() != 3 ) {
2737 final Event e1 = new Event( Event.EventType.fusion );
2738 if ( e1.isDuplication() ) {
2741 if ( !e1.isFusion() ) {
2744 if ( !e1.asText().toString().equals( "fusion" ) ) {
2747 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
2750 final Event e11 = new Event( Event.EventType.fusion );
2751 if ( !e11.isEqual( e1 ) ) {
2754 if ( !e11.toNHX().toString().equals( "" ) ) {
2757 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
2758 if ( e2.isDuplication() ) {
2761 if ( !e2.isSpeciationOrDuplication() ) {
2764 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
2767 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
2770 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
2773 if ( e11.isEqual( e2 ) ) {
2776 final Event e2c = ( Event ) e2.copy();
2777 if ( !e2c.isEqual( e2 ) ) {
2780 Event e3 = new Event( 1, 2, 3 );
2781 if ( e3.isDuplication() ) {
2784 if ( e3.isSpeciation() ) {
2787 if ( e3.isGeneLoss() ) {
2790 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2793 final Event e3c = ( Event ) e3.copy();
2794 final Event e3cc = ( Event ) e3c.copy();
2795 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
2799 if ( !e3c.isEqual( e3cc ) ) {
2802 Event e4 = new Event( 1, 2, 3 );
2803 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2806 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
2809 final Event e4c = ( Event ) e4.copy();
2811 final Event e4cc = ( Event ) e4c.copy();
2812 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2815 if ( !e4c.isEqual( e4cc ) ) {
2818 final Event e5 = new Event();
2819 if ( !e5.isUnassigned() ) {
2822 if ( !e5.asText().toString().equals( "unassigned" ) ) {
2825 if ( !e5.asSimpleText().toString().equals( "" ) ) {
2828 final Event e6 = new Event( 1, 0, 0 );
2829 if ( !e6.asText().toString().equals( "duplication" ) ) {
2832 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
2835 final Event e7 = new Event( 0, 1, 0 );
2836 if ( !e7.asText().toString().equals( "speciation" ) ) {
2839 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
2842 final Event e8 = new Event( 0, 0, 1 );
2843 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
2846 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
2850 catch ( final Exception e ) {
2851 e.printStackTrace( System.out );
2857 private static boolean testDeletionOfExternalNodes() {
2859 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2860 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
2861 final PhylogenyWriter w = new PhylogenyWriter();
2862 if ( t0.isEmpty() ) {
2865 if ( t0.getNumberOfExternalNodes() != 1 ) {
2868 t0.deleteSubtree( t0.getNode( "A" ), false );
2869 if ( t0.getNumberOfExternalNodes() != 0 ) {
2872 if ( !t0.isEmpty() ) {
2875 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
2876 if ( t1.getNumberOfExternalNodes() != 2 ) {
2879 t1.deleteSubtree( t1.getNode( "A" ), false );
2880 if ( t1.getNumberOfExternalNodes() != 1 ) {
2883 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
2886 t1.deleteSubtree( t1.getNode( "B" ), false );
2887 if ( t1.getNumberOfExternalNodes() != 1 ) {
2890 t1.deleteSubtree( t1.getNode( "r" ), false );
2891 if ( !t1.isEmpty() ) {
2894 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
2895 if ( t2.getNumberOfExternalNodes() != 3 ) {
2898 t2.deleteSubtree( t2.getNode( "B" ), false );
2899 if ( t2.getNumberOfExternalNodes() != 2 ) {
2902 t2.toNewHampshireX();
2903 PhylogenyNode n = t2.getNode( "A" );
2904 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2907 t2.deleteSubtree( t2.getNode( "A" ), false );
2908 if ( t2.getNumberOfExternalNodes() != 2 ) {
2911 t2.deleteSubtree( t2.getNode( "C" ), true );
2912 if ( t2.getNumberOfExternalNodes() != 1 ) {
2915 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2916 if ( t3.getNumberOfExternalNodes() != 4 ) {
2919 t3.deleteSubtree( t3.getNode( "B" ), true );
2920 if ( t3.getNumberOfExternalNodes() != 3 ) {
2923 n = t3.getNode( "A" );
2924 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2927 n = n.getNextExternalNode();
2928 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2931 t3.deleteSubtree( t3.getNode( "A" ), true );
2932 if ( t3.getNumberOfExternalNodes() != 2 ) {
2935 n = t3.getNode( "C" );
2936 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2939 t3.deleteSubtree( t3.getNode( "C" ), true );
2940 if ( t3.getNumberOfExternalNodes() != 1 ) {
2943 t3.deleteSubtree( t3.getNode( "D" ), true );
2944 if ( t3.getNumberOfExternalNodes() != 0 ) {
2947 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2948 if ( t4.getNumberOfExternalNodes() != 6 ) {
2951 t4.deleteSubtree( t4.getNode( "B2" ), true );
2952 if ( t4.getNumberOfExternalNodes() != 5 ) {
2955 String s = w.toNewHampshire( t4, false, true ).toString();
2956 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2959 t4.deleteSubtree( t4.getNode( "B11" ), true );
2960 if ( t4.getNumberOfExternalNodes() != 4 ) {
2963 t4.deleteSubtree( t4.getNode( "C" ), true );
2964 if ( t4.getNumberOfExternalNodes() != 3 ) {
2967 n = t4.getNode( "A" );
2968 n = n.getNextExternalNode();
2969 if ( !n.getName().equals( "B12" ) ) {
2972 n = n.getNextExternalNode();
2973 if ( !n.getName().equals( "D" ) ) {
2976 s = w.toNewHampshire( t4, false, true ).toString();
2977 if ( !s.equals( "((A,B12),D);" ) ) {
2980 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2981 t5.deleteSubtree( t5.getNode( "A" ), true );
2982 if ( t5.getNumberOfExternalNodes() != 5 ) {
2985 s = w.toNewHampshire( t5, false, true ).toString();
2986 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
2989 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2990 t6.deleteSubtree( t6.getNode( "B11" ), true );
2991 if ( t6.getNumberOfExternalNodes() != 5 ) {
2994 s = w.toNewHampshire( t6, false, false ).toString();
2995 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
2998 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2999 t7.deleteSubtree( t7.getNode( "B12" ), true );
3000 if ( t7.getNumberOfExternalNodes() != 5 ) {
3003 s = w.toNewHampshire( t7, false, true ).toString();
3004 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3007 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3008 t8.deleteSubtree( t8.getNode( "B2" ), true );
3009 if ( t8.getNumberOfExternalNodes() != 5 ) {
3012 s = w.toNewHampshire( t8, false, false ).toString();
3013 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3016 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3017 t9.deleteSubtree( t9.getNode( "C" ), true );
3018 if ( t9.getNumberOfExternalNodes() != 5 ) {
3021 s = w.toNewHampshire( t9, false, true ).toString();
3022 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3025 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3026 t10.deleteSubtree( t10.getNode( "D" ), true );
3027 if ( t10.getNumberOfExternalNodes() != 5 ) {
3030 s = w.toNewHampshire( t10, false, true ).toString();
3031 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3034 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3035 t11.deleteSubtree( t11.getNode( "A" ), true );
3036 if ( t11.getNumberOfExternalNodes() != 2 ) {
3039 s = w.toNewHampshire( t11, false, true ).toString();
3040 if ( !s.equals( "(B,C);" ) ) {
3043 t11.deleteSubtree( t11.getNode( "C" ), true );
3044 if ( t11.getNumberOfExternalNodes() != 1 ) {
3047 s = w.toNewHampshire( t11, false, false ).toString();
3048 if ( !s.equals( "B;" ) ) {
3051 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3052 t12.deleteSubtree( t12.getNode( "B2" ), true );
3053 if ( t12.getNumberOfExternalNodes() != 8 ) {
3056 s = w.toNewHampshire( t12, false, true ).toString();
3057 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3060 t12.deleteSubtree( t12.getNode( "B3" ), true );
3061 if ( t12.getNumberOfExternalNodes() != 7 ) {
3064 s = w.toNewHampshire( t12, false, true ).toString();
3065 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3068 t12.deleteSubtree( t12.getNode( "C3" ), true );
3069 if ( t12.getNumberOfExternalNodes() != 6 ) {
3072 s = w.toNewHampshire( t12, false, true ).toString();
3073 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3076 t12.deleteSubtree( t12.getNode( "A1" ), true );
3077 if ( t12.getNumberOfExternalNodes() != 5 ) {
3080 s = w.toNewHampshire( t12, false, true ).toString();
3081 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3084 t12.deleteSubtree( t12.getNode( "B1" ), true );
3085 if ( t12.getNumberOfExternalNodes() != 4 ) {
3088 s = w.toNewHampshire( t12, false, true ).toString();
3089 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3092 t12.deleteSubtree( t12.getNode( "A3" ), true );
3093 if ( t12.getNumberOfExternalNodes() != 3 ) {
3096 s = w.toNewHampshire( t12, false, true ).toString();
3097 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3100 t12.deleteSubtree( t12.getNode( "A2" ), true );
3101 if ( t12.getNumberOfExternalNodes() != 2 ) {
3104 s = w.toNewHampshire( t12, false, true ).toString();
3105 if ( !s.equals( "(C1,C2);" ) ) {
3108 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3109 t13.deleteSubtree( t13.getNode( "D" ), true );
3110 if ( t13.getNumberOfExternalNodes() != 4 ) {
3113 s = w.toNewHampshire( t13, false, true ).toString();
3114 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3117 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3118 t14.deleteSubtree( t14.getNode( "E" ), true );
3119 if ( t14.getNumberOfExternalNodes() != 5 ) {
3122 s = w.toNewHampshire( t14, false, true ).toString();
3123 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3126 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3127 t15.deleteSubtree( t15.getNode( "B2" ), true );
3128 if ( t15.getNumberOfExternalNodes() != 11 ) {
3131 t15.deleteSubtree( t15.getNode( "B1" ), true );
3132 if ( t15.getNumberOfExternalNodes() != 10 ) {
3135 t15.deleteSubtree( t15.getNode( "B3" ), true );
3136 if ( t15.getNumberOfExternalNodes() != 9 ) {
3139 t15.deleteSubtree( t15.getNode( "B4" ), true );
3140 if ( t15.getNumberOfExternalNodes() != 8 ) {
3143 t15.deleteSubtree( t15.getNode( "A1" ), true );
3144 if ( t15.getNumberOfExternalNodes() != 7 ) {
3147 t15.deleteSubtree( t15.getNode( "C4" ), true );
3148 if ( t15.getNumberOfExternalNodes() != 6 ) {
3152 catch ( final Exception e ) {
3153 e.printStackTrace( System.out );
3159 private static boolean testDescriptiveStatistics() {
3161 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3162 dss1.addValue( 82 );
3163 dss1.addValue( 78 );
3164 dss1.addValue( 70 );
3165 dss1.addValue( 58 );
3166 dss1.addValue( 42 );
3167 if ( dss1.getN() != 5 ) {
3170 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3173 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3176 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3179 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3182 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3185 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3188 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3191 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3194 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3197 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3200 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3203 dss1.addValue( 123 );
3204 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3207 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3210 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3213 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3214 dss2.addValue( -1.85 );
3215 dss2.addValue( 57.5 );
3216 dss2.addValue( 92.78 );
3217 dss2.addValue( 57.78 );
3218 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3221 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3224 final double[] a = dss2.getDataAsDoubleArray();
3225 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3228 dss2.addValue( -100 );
3229 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3232 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3235 final double[] ds = new double[ 14 ];
3250 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3251 if ( bins.length != 4 ) {
3254 if ( bins[ 0 ] != 2 ) {
3257 if ( bins[ 1 ] != 3 ) {
3260 if ( bins[ 2 ] != 4 ) {
3263 if ( bins[ 3 ] != 5 ) {
3266 final double[] ds1 = new double[ 9 ];
3276 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3277 if ( bins1.length != 4 ) {
3280 if ( bins1[ 0 ] != 2 ) {
3283 if ( bins1[ 1 ] != 3 ) {
3286 if ( bins1[ 2 ] != 0 ) {
3289 if ( bins1[ 3 ] != 4 ) {
3292 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3293 if ( bins1_1.length != 3 ) {
3296 if ( bins1_1[ 0 ] != 3 ) {
3299 if ( bins1_1[ 1 ] != 2 ) {
3302 if ( bins1_1[ 2 ] != 4 ) {
3305 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3306 if ( bins1_2.length != 3 ) {
3309 if ( bins1_2[ 0 ] != 2 ) {
3312 if ( bins1_2[ 1 ] != 2 ) {
3315 if ( bins1_2[ 2 ] != 2 ) {
3318 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3332 dss3.addValue( 10 );
3333 dss3.addValue( 10 );
3334 dss3.addValue( 10 );
3335 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3336 histo.toStringBuffer( 10, '=', 40, 5 );
3337 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3339 catch ( final Exception e ) {
3340 e.printStackTrace( System.out );
3346 private static boolean testDir( final String file ) {
3348 final File f = new File( file );
3349 if ( !f.exists() ) {
3352 if ( !f.isDirectory() ) {
3355 if ( !f.canRead() ) {
3359 catch ( final Exception e ) {
3365 private static boolean testEmblEntryRetrieval() {
3366 //The format for GenBank Accession numbers are:
3367 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
3368 //Protein: 3 letters + 5 numerals
3369 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
3370 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
3373 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
3376 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
3379 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
3382 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
3385 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
3388 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
3391 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
3394 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
3397 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
3400 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
3403 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
3406 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
3409 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
3415 private static boolean testExternalNodeRelatedMethods() {
3417 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3418 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3419 PhylogenyNode n = t1.getNode( "A" );
3420 n = n.getNextExternalNode();
3421 if ( !n.getName().equals( "B" ) ) {
3424 n = n.getNextExternalNode();
3425 if ( !n.getName().equals( "C" ) ) {
3428 n = n.getNextExternalNode();
3429 if ( !n.getName().equals( "D" ) ) {
3432 n = t1.getNode( "B" );
3433 while ( !n.isLastExternalNode() ) {
3434 n = n.getNextExternalNode();
3436 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3437 n = t2.getNode( "A" );
3438 n = n.getNextExternalNode();
3439 if ( !n.getName().equals( "B" ) ) {
3442 n = n.getNextExternalNode();
3443 if ( !n.getName().equals( "C" ) ) {
3446 n = n.getNextExternalNode();
3447 if ( !n.getName().equals( "D" ) ) {
3450 n = t2.getNode( "B" );
3451 while ( !n.isLastExternalNode() ) {
3452 n = n.getNextExternalNode();
3454 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3455 n = t3.getNode( "A" );
3456 n = n.getNextExternalNode();
3457 if ( !n.getName().equals( "B" ) ) {
3460 n = n.getNextExternalNode();
3461 if ( !n.getName().equals( "C" ) ) {
3464 n = n.getNextExternalNode();
3465 if ( !n.getName().equals( "D" ) ) {
3468 n = n.getNextExternalNode();
3469 if ( !n.getName().equals( "E" ) ) {
3472 n = n.getNextExternalNode();
3473 if ( !n.getName().equals( "F" ) ) {
3476 n = n.getNextExternalNode();
3477 if ( !n.getName().equals( "G" ) ) {
3480 n = n.getNextExternalNode();
3481 if ( !n.getName().equals( "H" ) ) {
3484 n = t3.getNode( "B" );
3485 while ( !n.isLastExternalNode() ) {
3486 n = n.getNextExternalNode();
3488 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3489 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3490 final PhylogenyNode node = iter.next();
3492 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3493 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3494 final PhylogenyNode node = iter.next();
3496 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
3497 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
3498 if ( !iter.next().getName().equals( "A" ) ) {
3501 if ( !iter.next().getName().equals( "B" ) ) {
3504 if ( !iter.next().getName().equals( "C" ) ) {
3507 if ( !iter.next().getName().equals( "D" ) ) {
3510 if ( !iter.next().getName().equals( "E" ) ) {
3513 if ( !iter.next().getName().equals( "F" ) ) {
3516 if ( iter.hasNext() ) {
3520 catch ( final Exception e ) {
3521 e.printStackTrace( System.out );
3527 private static boolean testExtractSNFromNodeName() {
3529 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
3532 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
3533 .equals( "Mus musculus musculus" ) ) {
3536 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
3537 .equals( "Mus musculus musculus" ) ) {
3540 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
3543 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
3544 .equals( "Mus musculus" ) ) {
3548 catch ( final Exception e ) {
3549 e.printStackTrace( System.out );
3555 private static boolean testExtractTaxonomyCodeFromNodeName() {
3557 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3560 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3561 .equals( "SOYBN" ) ) {
3564 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3565 .equals( "ARATH" ) ) {
3568 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3569 .equals( "ARATH" ) ) {
3572 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3575 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3578 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3581 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3582 .equals( "SOYBN" ) ) {
3585 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3586 .equals( "SOYBN" ) ) {
3589 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3590 .equals( "SOYBN" ) ) {
3593 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3594 .equals( "SOYBN" ) ) {
3597 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3598 .equals( "SOYBN" ) ) {
3601 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3602 .equals( "SOYBN" ) ) {
3605 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
3606 .equals( "SOYBN" ) ) {
3609 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
3610 .equals( "SOYBN" ) ) {
3613 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
3616 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
3617 .equals( "SOYBN" ) ) {
3620 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
3621 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
3624 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
3625 .equals( "9YX45" ) ) {
3628 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
3629 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3630 .equals( "MOUSE" ) ) {
3633 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
3634 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3635 .equals( "MOUSE" ) ) {
3638 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
3639 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3640 .equals( "MOUSE" ) ) {
3643 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
3644 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3647 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
3648 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3651 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3652 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3655 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3656 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3659 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
3660 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3663 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
3664 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3667 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
3668 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3671 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3672 .equals( "RAT" ) ) {
3675 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3676 .equals( "PIG" ) ) {
3680 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3681 .equals( "MOUSE" ) ) {
3684 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3685 .equals( "MOUSE" ) ) {
3688 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3692 catch ( final Exception e ) {
3693 e.printStackTrace( System.out );
3699 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
3701 PhylogenyNode n = new PhylogenyNode();
3702 n.setName( "tr|B3RJ64" );
3703 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3706 n.setName( "tr.B3RJ64" );
3707 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3710 n.setName( "tr=B3RJ64" );
3711 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3714 n.setName( "tr-B3RJ64" );
3715 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3718 n.setName( "tr/B3RJ64" );
3719 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3722 n.setName( "tr\\B3RJ64" );
3723 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3726 n.setName( "tr_B3RJ64" );
3727 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3730 n.setName( " tr|B3RJ64 " );
3731 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3734 n.setName( "-tr|B3RJ64-" );
3735 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3738 n.setName( "-tr=B3RJ64-" );
3739 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3742 n.setName( "_tr=B3RJ64_" );
3743 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3746 n.setName( " tr_tr|B3RJ64_sp|123 " );
3747 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3750 n.setName( "B3RJ64" );
3751 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3754 n.setName( "sp|B3RJ64" );
3755 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3758 n.setName( "sp|B3RJ64C" );
3759 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3762 n.setName( "sp B3RJ64" );
3763 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3766 n.setName( "sp|B3RJ6X" );
3767 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3770 n.setName( "sp|B3RJ6" );
3771 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3774 n.setName( "K1PYK7_CRAGI" );
3775 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3778 n.setName( "K1PYK7_PEA" );
3779 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
3782 n.setName( "K1PYK7_RAT" );
3783 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
3786 n.setName( "K1PYK7_PIG" );
3787 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
3790 n.setName( "~K1PYK7_PIG~" );
3791 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
3794 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
3795 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3798 n.setName( "K1PYKX_CRAGI" );
3799 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3802 n.setName( "XXXXX_CRAGI" );
3803 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
3806 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
3807 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
3810 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
3811 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3814 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
3815 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
3818 n = new PhylogenyNode();
3819 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
3820 seq.setSymbol( "K1PYK7_CRAGI" );
3821 n.getNodeData().addSequence( seq );
3822 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3825 seq.setSymbol( "tr|B3RJ64" );
3826 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3829 n = new PhylogenyNode();
3830 seq = new org.forester.phylogeny.data.Sequence();
3831 seq.setName( "K1PYK7_CRAGI" );
3832 n.getNodeData().addSequence( seq );
3833 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3836 seq.setName( "tr|B3RJ64" );
3837 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3840 n = new PhylogenyNode();
3841 seq = new org.forester.phylogeny.data.Sequence();
3842 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
3843 n.getNodeData().addSequence( seq );
3844 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
3847 n = new PhylogenyNode();
3848 seq = new org.forester.phylogeny.data.Sequence();
3849 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
3850 n.getNodeData().addSequence( seq );
3851 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3855 n = new PhylogenyNode();
3856 n.setName( "ACP19736" );
3857 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
3860 n = new PhylogenyNode();
3861 n.setName( "|ACP19736|" );
3862 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
3866 catch ( final Exception e ) {
3867 e.printStackTrace( System.out );
3873 private static boolean testFastaParser() {
3875 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
3878 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
3881 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
3882 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
3885 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
3888 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
3891 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
3894 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
3897 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
3901 catch ( final Exception e ) {
3902 e.printStackTrace();
3908 private static boolean testGeneralMsaParser() {
3910 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
3911 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
3912 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
3913 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
3914 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
3915 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
3916 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
3917 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
3918 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3921 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3924 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3927 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3930 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3933 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3936 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3939 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3942 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3945 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3948 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3951 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3954 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
3955 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3958 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3961 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3964 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
3965 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
3968 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
3971 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
3974 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
3975 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3978 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3981 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3985 catch ( final Exception e ) {
3986 e.printStackTrace();
3992 private static boolean testGeneralTable() {
3994 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
3995 t0.setValue( 3, 2, "23" );
3996 t0.setValue( 10, 1, "error" );
3997 t0.setValue( 10, 1, "110" );
3998 t0.setValue( 9, 1, "19" );
3999 t0.setValue( 1, 10, "101" );
4000 t0.setValue( 10, 10, "1010" );
4001 t0.setValue( 100, 10, "10100" );
4002 t0.setValue( 0, 0, "00" );
4003 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4006 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4009 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4012 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4015 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4018 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4021 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4024 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4027 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4030 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4031 t1.setValue( "3", "2", "23" );
4032 t1.setValue( "10", "1", "error" );
4033 t1.setValue( "10", "1", "110" );
4034 t1.setValue( "9", "1", "19" );
4035 t1.setValue( "1", "10", "101" );
4036 t1.setValue( "10", "10", "1010" );
4037 t1.setValue( "100", "10", "10100" );
4038 t1.setValue( "0", "0", "00" );
4039 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4040 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4043 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4046 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4049 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4052 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4055 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4058 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4061 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4064 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4067 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4071 catch ( final Exception e ) {
4072 e.printStackTrace( System.out );
4078 private static boolean testGetDistance() {
4080 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4081 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",
4082 new NHXParser() )[ 0 ];
4083 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4086 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4089 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4092 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4095 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4098 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4101 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4104 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4107 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4110 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4113 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4116 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4119 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4122 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4125 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4128 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4131 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4134 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4137 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4140 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4143 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4146 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4149 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4152 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4155 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4158 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4161 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4164 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4167 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4170 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4173 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4176 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",
4177 new NHXParser() )[ 0 ];
4178 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4181 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4184 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4187 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4190 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4193 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4196 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4199 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4202 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4205 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4208 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4212 catch ( final Exception e ) {
4213 e.printStackTrace( System.out );
4219 private static boolean testGetLCA() {
4221 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4222 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4223 new NHXParser() )[ 0 ];
4224 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4225 if ( !A.getName().equals( "A" ) ) {
4228 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4229 if ( !gh.getName().equals( "gh" ) ) {
4232 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4233 if ( !ab.getName().equals( "ab" ) ) {
4236 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4237 if ( !ab2.getName().equals( "ab" ) ) {
4240 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4241 if ( !gh2.getName().equals( "gh" ) ) {
4244 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4245 if ( !gh3.getName().equals( "gh" ) ) {
4248 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4249 if ( !abc.getName().equals( "abc" ) ) {
4252 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4253 if ( !abc2.getName().equals( "abc" ) ) {
4256 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4257 if ( !abcd.getName().equals( "abcd" ) ) {
4260 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4261 if ( !abcd2.getName().equals( "abcd" ) ) {
4264 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4265 if ( !abcdef.getName().equals( "abcdef" ) ) {
4268 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4269 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4272 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4273 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4276 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4277 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4280 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4281 if ( !abcde.getName().equals( "abcde" ) ) {
4284 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4285 if ( !abcde2.getName().equals( "abcde" ) ) {
4288 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4289 if ( !r.getName().equals( "abcdefgh" ) ) {
4292 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4293 if ( !r2.getName().equals( "abcdefgh" ) ) {
4296 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4297 if ( !r3.getName().equals( "abcdefgh" ) ) {
4300 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4301 if ( !abcde3.getName().equals( "abcde" ) ) {
4304 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4305 if ( !abcde4.getName().equals( "abcde" ) ) {
4308 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4309 if ( !ab3.getName().equals( "ab" ) ) {
4312 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4313 if ( !ab4.getName().equals( "ab" ) ) {
4316 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4317 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4318 if ( !cd.getName().equals( "cd" ) ) {
4321 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4322 if ( !cd2.getName().equals( "cd" ) ) {
4325 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4326 if ( !cde.getName().equals( "cde" ) ) {
4329 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4330 if ( !cde2.getName().equals( "cde" ) ) {
4333 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4334 if ( !cdef.getName().equals( "cdef" ) ) {
4337 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4338 if ( !cdef2.getName().equals( "cdef" ) ) {
4341 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4342 if ( !cdef3.getName().equals( "cdef" ) ) {
4345 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4346 if ( !rt.getName().equals( "r" ) ) {
4349 final Phylogeny p3 = factory
4350 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4351 new NHXParser() )[ 0 ];
4352 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4353 if ( !bc_3.getName().equals( "bc" ) ) {
4356 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4357 if ( !ac_3.getName().equals( "abc" ) ) {
4360 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4361 if ( !ad_3.getName().equals( "abcde" ) ) {
4364 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4365 if ( !af_3.getName().equals( "abcdef" ) ) {
4368 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4369 if ( !ag_3.getName().equals( "" ) ) {
4372 if ( !ag_3.isRoot() ) {
4375 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4376 if ( !al_3.getName().equals( "" ) ) {
4379 if ( !al_3.isRoot() ) {
4382 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4383 if ( !kl_3.getName().equals( "" ) ) {
4386 if ( !kl_3.isRoot() ) {
4389 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4390 if ( !fl_3.getName().equals( "" ) ) {
4393 if ( !fl_3.isRoot() ) {
4396 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
4397 if ( !gk_3.getName().equals( "ghijk" ) ) {
4400 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4401 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
4402 if ( !r_4.getName().equals( "r" ) ) {
4405 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4406 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
4407 if ( !r_5.getName().equals( "root" ) ) {
4410 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4411 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
4412 if ( !r_6.getName().equals( "rot" ) ) {
4415 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4416 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
4417 if ( !r_7.getName().equals( "rott" ) ) {
4421 catch ( final Exception e ) {
4422 e.printStackTrace( System.out );
4428 private static boolean testGetLCA2() {
4430 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4431 final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
4432 PhylogenyMethods.preOrderReId( p_a );
4433 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
4434 p_a.getNode( "a" ) );
4435 if ( !p_a_1.getName().equals( "a" ) ) {
4438 final Phylogeny p_b = factory.create( "((a)b)", new NHXParser() )[ 0 ];
4439 PhylogenyMethods.preOrderReId( p_b );
4440 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
4441 p_b.getNode( "a" ) );
4442 if ( !p_b_1.getName().equals( "b" ) ) {
4445 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
4446 p_b.getNode( "b" ) );
4447 if ( !p_b_2.getName().equals( "b" ) ) {
4450 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
4451 PhylogenyMethods.preOrderReId( p_c );
4452 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
4453 p_c.getNode( "a" ) );
4454 if ( !p_c_1.getName().equals( "b" ) ) {
4457 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4458 p_c.getNode( "c" ) );
4459 if ( !p_c_2.getName().equals( "c" ) ) {
4460 System.out.println( p_c_2.getName() );
4464 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4465 p_c.getNode( "b" ) );
4466 if ( !p_c_3.getName().equals( "b" ) ) {
4469 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
4470 p_c.getNode( "a" ) );
4471 if ( !p_c_4.getName().equals( "c" ) ) {
4474 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4475 new NHXParser() )[ 0 ];
4476 PhylogenyMethods.preOrderReId( p1 );
4477 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4478 p1.getNode( "A" ) );
4479 if ( !A.getName().equals( "A" ) ) {
4482 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
4483 p1.getNode( "gh" ) );
4484 if ( !gh.getName().equals( "gh" ) ) {
4487 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4488 p1.getNode( "B" ) );
4489 if ( !ab.getName().equals( "ab" ) ) {
4492 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4493 p1.getNode( "A" ) );
4494 if ( !ab2.getName().equals( "ab" ) ) {
4497 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4498 p1.getNode( "G" ) );
4499 if ( !gh2.getName().equals( "gh" ) ) {
4502 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
4503 p1.getNode( "H" ) );
4504 if ( !gh3.getName().equals( "gh" ) ) {
4507 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
4508 p1.getNode( "A" ) );
4509 if ( !abc.getName().equals( "abc" ) ) {
4512 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4513 p1.getNode( "C" ) );
4514 if ( !abc2.getName().equals( "abc" ) ) {
4517 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4518 p1.getNode( "D" ) );
4519 if ( !abcd.getName().equals( "abcd" ) ) {
4522 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
4523 p1.getNode( "A" ) );
4524 if ( !abcd2.getName().equals( "abcd" ) ) {
4527 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4528 p1.getNode( "F" ) );
4529 if ( !abcdef.getName().equals( "abcdef" ) ) {
4532 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4533 p1.getNode( "A" ) );
4534 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4537 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4538 p1.getNode( "F" ) );
4539 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4542 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4543 p1.getNode( "ab" ) );
4544 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4547 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4548 p1.getNode( "E" ) );
4549 if ( !abcde.getName().equals( "abcde" ) ) {
4552 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4553 p1.getNode( "A" ) );
4554 if ( !abcde2.getName().equals( "abcde" ) ) {
4557 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
4558 p1.getNode( "abcdefgh" ) );
4559 if ( !r.getName().equals( "abcdefgh" ) ) {
4562 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4563 p1.getNode( "H" ) );
4564 if ( !r2.getName().equals( "abcdefgh" ) ) {
4567 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4568 p1.getNode( "A" ) );
4569 if ( !r3.getName().equals( "abcdefgh" ) ) {
4572 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4573 p1.getNode( "abcde" ) );
4574 if ( !abcde3.getName().equals( "abcde" ) ) {
4577 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
4578 p1.getNode( "E" ) );
4579 if ( !abcde4.getName().equals( "abcde" ) ) {
4582 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4583 p1.getNode( "B" ) );
4584 if ( !ab3.getName().equals( "ab" ) ) {
4587 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4588 p1.getNode( "ab" ) );
4589 if ( !ab4.getName().equals( "ab" ) ) {
4592 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4593 PhylogenyMethods.preOrderReId( p2 );
4594 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4595 p2.getNode( "d" ) );
4596 if ( !cd.getName().equals( "cd" ) ) {
4599 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4600 p2.getNode( "c" ) );
4601 if ( !cd2.getName().equals( "cd" ) ) {
4604 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4605 p2.getNode( "e" ) );
4606 if ( !cde.getName().equals( "cde" ) ) {
4609 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
4610 p2.getNode( "c" ) );
4611 if ( !cde2.getName().equals( "cde" ) ) {
4614 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4615 p2.getNode( "f" ) );
4616 if ( !cdef.getName().equals( "cdef" ) ) {
4619 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4620 p2.getNode( "f" ) );
4621 if ( !cdef2.getName().equals( "cdef" ) ) {
4624 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
4625 p2.getNode( "d" ) );
4626 if ( !cdef3.getName().equals( "cdef" ) ) {
4629 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4630 p2.getNode( "a" ) );
4631 if ( !rt.getName().equals( "r" ) ) {
4634 final Phylogeny p3 = factory
4635 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4636 new NHXParser() )[ 0 ];
4637 PhylogenyMethods.preOrderReId( p3 );
4638 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
4639 p3.getNode( "c" ) );
4640 if ( !bc_3.getName().equals( "bc" ) ) {
4643 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4644 p3.getNode( "c" ) );
4645 if ( !ac_3.getName().equals( "abc" ) ) {
4648 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4649 p3.getNode( "d" ) );
4650 if ( !ad_3.getName().equals( "abcde" ) ) {
4653 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4654 p3.getNode( "f" ) );
4655 if ( !af_3.getName().equals( "abcdef" ) ) {
4658 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4659 p3.getNode( "g" ) );
4660 if ( !ag_3.getName().equals( "" ) ) {
4663 if ( !ag_3.isRoot() ) {
4666 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4667 p3.getNode( "l" ) );
4668 if ( !al_3.getName().equals( "" ) ) {
4671 if ( !al_3.isRoot() ) {
4674 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
4675 p3.getNode( "l" ) );
4676 if ( !kl_3.getName().equals( "" ) ) {
4679 if ( !kl_3.isRoot() ) {
4682 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
4683 p3.getNode( "l" ) );
4684 if ( !fl_3.getName().equals( "" ) ) {
4687 if ( !fl_3.isRoot() ) {
4690 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
4691 p3.getNode( "k" ) );
4692 if ( !gk_3.getName().equals( "ghijk" ) ) {
4695 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4696 PhylogenyMethods.preOrderReId( p4 );
4697 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
4698 p4.getNode( "c" ) );
4699 if ( !r_4.getName().equals( "r" ) ) {
4702 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4703 PhylogenyMethods.preOrderReId( p5 );
4704 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
4705 p5.getNode( "c" ) );
4706 if ( !r_5.getName().equals( "root" ) ) {
4709 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4710 PhylogenyMethods.preOrderReId( p6 );
4711 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
4712 p6.getNode( "a" ) );
4713 if ( !r_6.getName().equals( "rot" ) ) {
4716 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4717 PhylogenyMethods.preOrderReId( p7 );
4718 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
4719 p7.getNode( "e" ) );
4720 if ( !r_7.getName().equals( "rott" ) ) {
4723 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4724 p7.getNode( "a" ) );
4725 if ( !r_71.getName().equals( "rott" ) ) {
4728 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4729 p7.getNode( "rott" ) );
4730 if ( !r_72.getName().equals( "rott" ) ) {
4733 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4734 p7.getNode( "a" ) );
4735 if ( !r_73.getName().equals( "rott" ) ) {
4738 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4739 p7.getNode( "rott" ) );
4740 if ( !r_74.getName().equals( "rott" ) ) {
4743 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4744 p7.getNode( "e" ) );
4745 if ( !r_75.getName().equals( "e" ) ) {
4749 catch ( final Exception e ) {
4750 e.printStackTrace( System.out );
4756 private static boolean testHmmscanOutputParser() {
4757 final String test_dir = Test.PATH_TO_TEST_DATA;
4759 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
4760 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4762 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
4763 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4764 final List<Protein> proteins = parser2.parse();
4765 if ( parser2.getProteinsEncountered() != 4 ) {
4768 if ( proteins.size() != 4 ) {
4771 if ( parser2.getDomainsEncountered() != 69 ) {
4774 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
4777 if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
4780 final Protein p1 = proteins.get( 0 );
4781 if ( p1.getNumberOfProteinDomains() != 15 ) {
4784 if ( p1.getLength() != 850 ) {
4787 final Protein p2 = proteins.get( 1 );
4788 if ( p2.getNumberOfProteinDomains() != 51 ) {
4791 if ( p2.getLength() != 1291 ) {
4794 final Protein p3 = proteins.get( 2 );
4795 if ( p3.getNumberOfProteinDomains() != 2 ) {
4798 final Protein p4 = proteins.get( 3 );
4799 if ( p4.getNumberOfProteinDomains() != 1 ) {
4802 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
4805 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
4808 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
4811 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
4814 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
4817 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
4820 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
4823 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
4826 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
4830 catch ( final Exception e ) {
4831 e.printStackTrace( System.out );
4837 private static boolean testLastExternalNodeMethods() {
4839 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4840 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
4841 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
4842 final PhylogenyNode n1 = t0.getNode( "A" );
4843 if ( n1.isLastExternalNode() ) {
4846 final PhylogenyNode n2 = t0.getNode( "B" );
4847 if ( n2.isLastExternalNode() ) {
4850 final PhylogenyNode n3 = t0.getNode( "C" );
4851 if ( n3.isLastExternalNode() ) {
4854 final PhylogenyNode n4 = t0.getNode( "D" );
4855 if ( !n4.isLastExternalNode() ) {
4859 catch ( final Exception e ) {
4860 e.printStackTrace( System.out );
4866 private static boolean testLevelOrderIterator() {
4868 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4869 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
4870 PhylogenyNodeIterator it0;
4871 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
4874 for( it0.reset(); it0.hasNext(); ) {
4877 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
4878 if ( !it.next().getName().equals( "r" ) ) {
4881 if ( !it.next().getName().equals( "ab" ) ) {
4884 if ( !it.next().getName().equals( "cd" ) ) {
4887 if ( !it.next().getName().equals( "A" ) ) {
4890 if ( !it.next().getName().equals( "B" ) ) {
4893 if ( !it.next().getName().equals( "C" ) ) {
4896 if ( !it.next().getName().equals( "D" ) ) {
4899 if ( it.hasNext() ) {
4902 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",
4903 new NHXParser() )[ 0 ];
4904 PhylogenyNodeIterator it2;
4905 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
4908 for( it2.reset(); it2.hasNext(); ) {
4911 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
4912 if ( !it3.next().getName().equals( "r" ) ) {
4915 if ( !it3.next().getName().equals( "abc" ) ) {
4918 if ( !it3.next().getName().equals( "defg" ) ) {
4921 if ( !it3.next().getName().equals( "A" ) ) {
4924 if ( !it3.next().getName().equals( "B" ) ) {
4927 if ( !it3.next().getName().equals( "C" ) ) {
4930 if ( !it3.next().getName().equals( "D" ) ) {
4933 if ( !it3.next().getName().equals( "E" ) ) {
4936 if ( !it3.next().getName().equals( "F" ) ) {
4939 if ( !it3.next().getName().equals( "G" ) ) {
4942 if ( !it3.next().getName().equals( "1" ) ) {
4945 if ( !it3.next().getName().equals( "2" ) ) {
4948 if ( !it3.next().getName().equals( "3" ) ) {
4951 if ( !it3.next().getName().equals( "4" ) ) {
4954 if ( !it3.next().getName().equals( "5" ) ) {
4957 if ( !it3.next().getName().equals( "6" ) ) {
4960 if ( !it3.next().getName().equals( "f1" ) ) {
4963 if ( !it3.next().getName().equals( "f2" ) ) {
4966 if ( !it3.next().getName().equals( "f3" ) ) {
4969 if ( !it3.next().getName().equals( "a" ) ) {
4972 if ( !it3.next().getName().equals( "b" ) ) {
4975 if ( !it3.next().getName().equals( "f21" ) ) {
4978 if ( !it3.next().getName().equals( "X" ) ) {
4981 if ( !it3.next().getName().equals( "Y" ) ) {
4984 if ( !it3.next().getName().equals( "Z" ) ) {
4987 if ( it3.hasNext() ) {
4990 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
4991 PhylogenyNodeIterator it4;
4992 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
4995 for( it4.reset(); it4.hasNext(); ) {
4998 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
4999 if ( !it5.next().getName().equals( "r" ) ) {
5002 if ( !it5.next().getName().equals( "A" ) ) {
5005 if ( !it5.next().getName().equals( "B" ) ) {
5008 if ( !it5.next().getName().equals( "C" ) ) {
5011 if ( !it5.next().getName().equals( "D" ) ) {
5014 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5015 PhylogenyNodeIterator it6;
5016 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5019 for( it6.reset(); it6.hasNext(); ) {
5022 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5023 if ( !it7.next().getName().equals( "A" ) ) {
5026 if ( it.hasNext() ) {
5030 catch ( final Exception e ) {
5031 e.printStackTrace( System.out );
5037 private static boolean testMafft( final String path ) {
5039 final List<String> opts = new ArrayList<String>();
5040 opts.add( "--maxiterate" );
5042 opts.add( "--localpair" );
5043 opts.add( "--quiet" );
5045 final MsaInferrer mafft = Mafft.createInstance( path );
5046 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5047 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5050 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5054 catch ( final Exception e ) {
5055 e.printStackTrace( System.out );
5061 private static boolean testMidpointrooting() {
5063 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5064 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5065 PhylogenyMethods.midpointRoot( t0 );
5066 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5069 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5072 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5076 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",
5077 new NHXParser() )[ 0 ];
5078 if ( !t1.isRooted() ) {
5081 PhylogenyMethods.midpointRoot( t1 );
5082 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5085 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5088 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5091 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5094 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5097 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5100 t1.reRoot( t1.getNode( "A" ) );
5101 PhylogenyMethods.midpointRoot( t1 );
5102 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5105 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5108 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5111 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5114 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5118 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5122 catch ( final Exception e ) {
5123 e.printStackTrace( System.out );
5129 private static boolean testMsaQualityMethod() {
5131 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
5132 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
5133 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
5134 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
5135 final List<Sequence> l = new ArrayList<Sequence>();
5140 final Msa msa = BasicMsa.createInstance( l );
5141 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5144 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5147 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5150 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5154 catch ( final Exception e ) {
5155 e.printStackTrace( System.out );
5161 private static boolean testNextNodeWithCollapsing() {
5163 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5165 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5166 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5167 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5168 t0.getNode( "cd" ).setCollapse( true );
5169 t0.getNode( "cde" ).setCollapse( true );
5170 n = t0.getFirstExternalNode();
5171 while ( n != null ) {
5173 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5175 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5178 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5181 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5184 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5187 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5190 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5194 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5195 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5196 t1.getNode( "ab" ).setCollapse( true );
5197 t1.getNode( "cd" ).setCollapse( true );
5198 t1.getNode( "cde" ).setCollapse( true );
5199 n = t1.getNode( "ab" );
5200 ext = new ArrayList<PhylogenyNode>();
5201 while ( n != null ) {
5203 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5205 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5208 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5211 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5214 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5217 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5223 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5224 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5225 t2.getNode( "ab" ).setCollapse( true );
5226 t2.getNode( "cd" ).setCollapse( true );
5227 t2.getNode( "cde" ).setCollapse( true );
5228 t2.getNode( "c" ).setCollapse( true );
5229 t2.getNode( "d" ).setCollapse( true );
5230 t2.getNode( "e" ).setCollapse( true );
5231 t2.getNode( "gh" ).setCollapse( true );
5232 n = t2.getNode( "ab" );
5233 ext = new ArrayList<PhylogenyNode>();
5234 while ( n != null ) {
5236 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5238 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5241 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5244 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5247 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5253 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5254 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5255 t3.getNode( "ab" ).setCollapse( true );
5256 t3.getNode( "cd" ).setCollapse( true );
5257 t3.getNode( "cde" ).setCollapse( true );
5258 t3.getNode( "c" ).setCollapse( true );
5259 t3.getNode( "d" ).setCollapse( true );
5260 t3.getNode( "e" ).setCollapse( true );
5261 t3.getNode( "gh" ).setCollapse( true );
5262 t3.getNode( "fgh" ).setCollapse( true );
5263 n = t3.getNode( "ab" );
5264 ext = new ArrayList<PhylogenyNode>();
5265 while ( n != null ) {
5267 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5269 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5272 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5275 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5281 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5282 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5283 t4.getNode( "ab" ).setCollapse( true );
5284 t4.getNode( "cd" ).setCollapse( true );
5285 t4.getNode( "cde" ).setCollapse( true );
5286 t4.getNode( "c" ).setCollapse( true );
5287 t4.getNode( "d" ).setCollapse( true );
5288 t4.getNode( "e" ).setCollapse( true );
5289 t4.getNode( "gh" ).setCollapse( true );
5290 t4.getNode( "fgh" ).setCollapse( true );
5291 t4.getNode( "abcdefgh" ).setCollapse( true );
5292 n = t4.getNode( "abcdefgh" );
5293 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5298 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5299 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5301 n = t5.getFirstExternalNode();
5302 while ( n != null ) {
5304 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5306 if ( ext.size() != 8 ) {
5309 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5312 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5315 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5318 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5321 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5324 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5327 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5330 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5335 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5336 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5338 t6.getNode( "ab" ).setCollapse( true );
5339 n = t6.getNode( "ab" );
5340 while ( n != null ) {
5342 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5344 if ( ext.size() != 7 ) {
5347 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5350 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5353 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5356 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5359 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5362 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5365 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5370 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5371 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5373 t7.getNode( "cd" ).setCollapse( true );
5374 n = t7.getNode( "a" );
5375 while ( n != null ) {
5377 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5379 if ( ext.size() != 7 ) {
5382 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5385 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5388 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5391 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5394 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5397 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5400 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5405 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5406 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
5408 t8.getNode( "cd" ).setCollapse( true );
5409 t8.getNode( "c" ).setCollapse( true );
5410 t8.getNode( "d" ).setCollapse( true );
5411 n = t8.getNode( "a" );
5412 while ( n != null ) {
5414 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5416 if ( ext.size() != 7 ) {
5419 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5422 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5425 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5426 System.out.println( "2 fail" );
5429 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5432 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5435 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5438 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5443 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5444 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
5446 t9.getNode( "gh" ).setCollapse( true );
5447 n = t9.getNode( "a" );
5448 while ( n != null ) {
5450 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5452 if ( ext.size() != 7 ) {
5455 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5458 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5461 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5464 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5467 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5470 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5473 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5478 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5479 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
5481 t10.getNode( "gh" ).setCollapse( true );
5482 t10.getNode( "g" ).setCollapse( true );
5483 t10.getNode( "h" ).setCollapse( true );
5484 n = t10.getNode( "a" );
5485 while ( n != null ) {
5487 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5489 if ( ext.size() != 7 ) {
5492 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5495 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5498 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5501 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5504 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5507 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5510 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5515 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5516 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
5518 t11.getNode( "gh" ).setCollapse( true );
5519 t11.getNode( "fgh" ).setCollapse( true );
5520 n = t11.getNode( "a" );
5521 while ( n != null ) {
5523 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5525 if ( ext.size() != 6 ) {
5528 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5531 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5534 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5537 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5540 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5543 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5548 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5549 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
5551 t12.getNode( "gh" ).setCollapse( true );
5552 t12.getNode( "fgh" ).setCollapse( true );
5553 t12.getNode( "g" ).setCollapse( true );
5554 t12.getNode( "h" ).setCollapse( true );
5555 t12.getNode( "f" ).setCollapse( true );
5556 n = t12.getNode( "a" );
5557 while ( n != null ) {
5559 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5561 if ( ext.size() != 6 ) {
5564 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5567 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5570 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5573 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5576 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5579 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5584 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5585 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
5587 t13.getNode( "ab" ).setCollapse( true );
5588 t13.getNode( "b" ).setCollapse( true );
5589 t13.getNode( "fgh" ).setCollapse( true );
5590 t13.getNode( "gh" ).setCollapse( true );
5591 n = t13.getNode( "ab" );
5592 while ( n != null ) {
5594 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5596 if ( ext.size() != 5 ) {
5599 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5602 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5605 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5608 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5611 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5616 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
5617 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
5619 t14.getNode( "ab" ).setCollapse( true );
5620 t14.getNode( "a" ).setCollapse( true );
5621 t14.getNode( "fgh" ).setCollapse( true );
5622 t14.getNode( "gh" ).setCollapse( true );
5623 n = t14.getNode( "ab" );
5624 while ( n != null ) {
5626 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5628 if ( ext.size() != 5 ) {
5631 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5634 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5637 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5640 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5643 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5648 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" );
5649 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
5651 t15.getNode( "ab" ).setCollapse( true );
5652 t15.getNode( "a" ).setCollapse( true );
5653 t15.getNode( "fgh" ).setCollapse( true );
5654 t15.getNode( "gh" ).setCollapse( true );
5655 n = t15.getNode( "ab" );
5656 while ( n != null ) {
5658 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5660 if ( ext.size() != 6 ) {
5663 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5666 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5669 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5672 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5675 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
5678 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5683 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" );
5684 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
5686 t16.getNode( "ab" ).setCollapse( true );
5687 t16.getNode( "a" ).setCollapse( true );
5688 t16.getNode( "fgh" ).setCollapse( true );
5689 t16.getNode( "gh" ).setCollapse( true );
5690 t16.getNode( "cd" ).setCollapse( true );
5691 t16.getNode( "cde" ).setCollapse( true );
5692 t16.getNode( "d" ).setCollapse( true );
5693 t16.getNode( "x" ).setCollapse( true );
5694 n = t16.getNode( "ab" );
5695 while ( n != null ) {
5697 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5699 if ( ext.size() != 4 ) {
5702 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5705 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5708 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
5711 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
5715 catch ( final Exception e ) {
5716 e.printStackTrace( System.out );
5722 private static boolean testNexusCharactersParsing() {
5724 final NexusCharactersParser parser = new NexusCharactersParser();
5725 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
5727 String[] labels = parser.getCharStateLabels();
5728 if ( labels.length != 7 ) {
5731 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5734 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5737 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5740 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5743 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5746 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5749 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5752 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5754 labels = parser.getCharStateLabels();
5755 if ( labels.length != 7 ) {
5758 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5761 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5764 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5767 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5770 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5773 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5776 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5780 catch ( final Exception e ) {
5781 e.printStackTrace( System.out );
5787 private static boolean testNexusMatrixParsing() {
5789 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
5790 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
5792 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
5793 if ( m.getNumberOfCharacters() != 9 ) {
5796 if ( m.getNumberOfIdentifiers() != 5 ) {
5799 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
5802 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
5805 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
5808 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
5811 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
5814 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
5817 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
5820 // if ( labels.length != 7 ) {
5823 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5826 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5829 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5832 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5835 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5838 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5841 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5844 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5846 // labels = parser.getCharStateLabels();
5847 // if ( labels.length != 7 ) {
5850 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5853 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5856 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5859 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5862 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5865 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5868 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5872 catch ( final Exception e ) {
5873 e.printStackTrace( System.out );
5879 private static boolean testNexusTreeParsing() {
5881 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5882 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
5883 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
5884 if ( phylogenies.length != 1 ) {
5887 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
5890 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5894 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
5895 if ( phylogenies.length != 1 ) {
5898 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5901 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
5905 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
5906 if ( phylogenies.length != 1 ) {
5909 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5912 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5915 if ( phylogenies[ 0 ].isRooted() ) {
5919 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
5920 if ( phylogenies.length != 18 ) {
5923 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5926 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
5929 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
5932 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
5935 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
5938 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
5941 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
5944 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
5947 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
5950 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
5953 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
5956 if ( phylogenies[ 8 ].isRooted() ) {
5959 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
5962 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
5965 if ( !phylogenies[ 9 ].isRooted() ) {
5968 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
5971 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
5974 if ( !phylogenies[ 10 ].isRooted() ) {
5977 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
5980 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
5983 if ( phylogenies[ 11 ].isRooted() ) {
5986 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
5989 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
5992 if ( !phylogenies[ 12 ].isRooted() ) {
5995 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
5998 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6001 if ( !phylogenies[ 13 ].isRooted() ) {
6004 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6007 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6010 if ( !phylogenies[ 14 ].isRooted() ) {
6013 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6016 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6019 if ( phylogenies[ 15 ].isRooted() ) {
6022 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6025 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6028 if ( !phylogenies[ 16 ].isRooted() ) {
6031 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6034 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6037 if ( phylogenies[ 17 ].isRooted() ) {
6040 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6044 catch ( final Exception e ) {
6045 e.printStackTrace( System.out );
6051 private static boolean testNexusTreeParsingIterating() {
6053 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6054 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6055 if ( !p.hasNext() ) {
6058 Phylogeny phy = p.next();
6059 if ( phy == null ) {
6062 if ( phy.getNumberOfExternalNodes() != 25 ) {
6065 if ( !phy.getName().equals( "" ) ) {
6068 if ( p.hasNext() ) {
6072 if ( phy != null ) {
6077 if ( !p.hasNext() ) {
6081 if ( phy == null ) {
6084 if ( phy.getNumberOfExternalNodes() != 25 ) {
6087 if ( !phy.getName().equals( "" ) ) {
6090 if ( p.hasNext() ) {
6094 if ( phy != null ) {
6098 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6099 if ( !p.hasNext() ) {
6103 if ( phy == null ) {
6106 if ( phy.getNumberOfExternalNodes() != 10 ) {
6109 if ( !phy.getName().equals( "name" ) ) {
6112 if ( p.hasNext() ) {
6116 if ( phy != null ) {
6121 if ( !p.hasNext() ) {
6125 if ( phy == null ) {
6128 if ( phy.getNumberOfExternalNodes() != 10 ) {
6131 if ( !phy.getName().equals( "name" ) ) {
6134 if ( p.hasNext() ) {
6138 if ( phy != null ) {
6142 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6143 if ( !p.hasNext() ) {
6147 if ( phy == null ) {
6150 if ( phy.getNumberOfExternalNodes() != 3 ) {
6153 if ( !phy.getName().equals( "" ) ) {
6156 if ( phy.isRooted() ) {
6159 if ( p.hasNext() ) {
6163 if ( phy != null ) {
6168 if ( !p.hasNext() ) {
6172 if ( phy == null ) {
6175 if ( phy.getNumberOfExternalNodes() != 3 ) {
6178 if ( !phy.getName().equals( "" ) ) {
6181 if ( p.hasNext() ) {
6185 if ( phy != null ) {
6189 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6190 // if ( phylogenies.length != 18 ) {
6194 if ( !p.hasNext() ) {
6198 if ( phy == null ) {
6201 if ( phy.getNumberOfExternalNodes() != 10 ) {
6204 if ( !phy.getName().equals( "tree 0" ) ) {
6208 if ( !p.hasNext() ) {
6212 if ( phy == null ) {
6215 if ( phy.getNumberOfExternalNodes() != 10 ) {
6218 if ( !phy.getName().equals( "tree 1" ) ) {
6222 if ( !p.hasNext() ) {
6226 if ( phy == null ) {
6229 if ( phy.getNumberOfExternalNodes() != 3 ) {
6232 if ( !phy.getName().equals( "" ) ) {
6235 if ( phy.isRooted() ) {
6239 if ( !p.hasNext() ) {
6243 if ( phy == null ) {
6246 if ( phy.getNumberOfExternalNodes() != 4 ) {
6249 if ( !phy.getName().equals( "" ) ) {
6252 if ( !phy.isRooted() ) {
6256 if ( !p.hasNext() ) {
6260 if ( phy == null ) {
6263 if ( phy.getNumberOfExternalNodes() != 5 ) {
6264 System.out.println( phy.getNumberOfExternalNodes() );
6267 if ( !phy.getName().equals( "" ) ) {
6270 if ( !phy.isRooted() ) {
6274 if ( !p.hasNext() ) {
6278 if ( phy == null ) {
6281 if ( phy.getNumberOfExternalNodes() != 3 ) {
6284 if ( !phy.getName().equals( "" ) ) {
6287 if ( phy.isRooted() ) {
6291 if ( !p.hasNext() ) {
6295 if ( phy == null ) {
6298 if ( phy.getNumberOfExternalNodes() != 2 ) {
6301 if ( !phy.getName().equals( "" ) ) {
6304 if ( !phy.isRooted() ) {
6308 if ( !p.hasNext() ) {
6312 if ( phy.getNumberOfExternalNodes() != 3 ) {
6315 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6318 if ( !phy.isRooted() ) {
6322 if ( !p.hasNext() ) {
6326 if ( phy.getNumberOfExternalNodes() != 3 ) {
6329 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6332 if ( !phy.getName().equals( "tree 8" ) ) {
6336 if ( !p.hasNext() ) {
6340 if ( phy.getNumberOfExternalNodes() != 3 ) {
6343 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6346 if ( !phy.getName().equals( "tree 9" ) ) {
6350 if ( !p.hasNext() ) {
6354 if ( phy.getNumberOfExternalNodes() != 3 ) {
6357 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6360 if ( !phy.getName().equals( "tree 10" ) ) {
6363 if ( !phy.isRooted() ) {
6367 if ( !p.hasNext() ) {
6371 if ( phy.getNumberOfExternalNodes() != 3 ) {
6374 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6377 if ( !phy.getName().equals( "tree 11" ) ) {
6380 if ( phy.isRooted() ) {
6384 if ( !p.hasNext() ) {
6388 if ( phy.getNumberOfExternalNodes() != 3 ) {
6391 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
6394 if ( !phy.getName().equals( "tree 12" ) ) {
6397 if ( !phy.isRooted() ) {
6401 if ( !p.hasNext() ) {
6405 if ( phy.getNumberOfExternalNodes() != 3 ) {
6408 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6411 if ( !phy.getName().equals( "tree 13" ) ) {
6414 if ( !phy.isRooted() ) {
6418 if ( !p.hasNext() ) {
6422 if ( phy.getNumberOfExternalNodes() != 10 ) {
6423 System.out.println( phy.getNumberOfExternalNodes() );
6428 .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;" ) ) {
6429 System.out.println( phy.toNewHampshire() );
6432 if ( !phy.getName().equals( "tree 14" ) ) {
6435 if ( !phy.isRooted() ) {
6439 if ( !p.hasNext() ) {
6443 if ( phy.getNumberOfExternalNodes() != 10 ) {
6444 System.out.println( phy.getNumberOfExternalNodes() );
6449 .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;" ) ) {
6450 System.out.println( phy.toNewHampshire() );
6453 if ( !phy.getName().equals( "tree 15" ) ) {
6456 if ( phy.isRooted() ) {
6460 if ( !p.hasNext() ) {
6464 if ( phy.getNumberOfExternalNodes() != 10 ) {
6465 System.out.println( phy.getNumberOfExternalNodes() );
6470 .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;" ) ) {
6471 System.out.println( phy.toNewHampshire() );
6474 if ( !phy.getName().equals( "tree 16" ) ) {
6477 if ( !phy.isRooted() ) {
6481 if ( !p.hasNext() ) {
6485 if ( phy.getNumberOfExternalNodes() != 10 ) {
6486 System.out.println( phy.getNumberOfExternalNodes() );
6491 .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;" ) ) {
6492 System.out.println( phy.toNewHampshire() );
6495 if ( !phy.getName().equals( "tree 17" ) ) {
6498 if ( phy.isRooted() ) {
6502 if ( p.hasNext() ) {
6506 if ( phy != null ) {
6511 if ( !p.hasNext() ) {
6515 if ( phy == null ) {
6518 if ( phy.getNumberOfExternalNodes() != 10 ) {
6521 if ( !phy.getName().equals( "tree 0" ) ) {
6525 if ( !p.hasNext() ) {
6529 if ( phy == null ) {
6532 if ( phy.getNumberOfExternalNodes() != 10 ) {
6535 if ( !phy.getName().equals( "tree 1" ) ) {
6539 if ( !p.hasNext() ) {
6543 if ( phy == null ) {
6546 if ( phy.getNumberOfExternalNodes() != 3 ) {
6549 if ( !phy.getName().equals( "" ) ) {
6552 if ( phy.isRooted() ) {
6556 if ( !p.hasNext() ) {
6560 if ( phy == null ) {
6563 if ( phy.getNumberOfExternalNodes() != 4 ) {
6566 if ( !phy.getName().equals( "" ) ) {
6569 if ( !phy.isRooted() ) {
6573 if ( !p.hasNext() ) {
6577 if ( phy == null ) {
6580 if ( phy.getNumberOfExternalNodes() != 5 ) {
6581 System.out.println( phy.getNumberOfExternalNodes() );
6584 if ( !phy.getName().equals( "" ) ) {
6587 if ( !phy.isRooted() ) {
6591 if ( !p.hasNext() ) {
6595 if ( phy == null ) {
6598 if ( phy.getNumberOfExternalNodes() != 3 ) {
6601 if ( !phy.getName().equals( "" ) ) {
6604 if ( phy.isRooted() ) {
6608 catch ( final Exception e ) {
6609 e.printStackTrace( System.out );
6615 private static boolean testNexusTreeParsingTranslating() {
6617 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6618 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6619 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
6620 if ( phylogenies.length != 1 ) {
6623 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6626 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6629 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6632 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6635 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6636 .equals( "Aranaeus" ) ) {
6640 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
6641 if ( phylogenies.length != 3 ) {
6644 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6647 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6650 if ( phylogenies[ 0 ].isRooted() ) {
6653 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6656 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6659 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6660 .equals( "Aranaeus" ) ) {
6663 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6666 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6669 if ( phylogenies[ 1 ].isRooted() ) {
6672 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6675 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6678 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6679 .equals( "Aranaeus" ) ) {
6682 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6685 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6688 if ( !phylogenies[ 2 ].isRooted() ) {
6691 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6694 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6697 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6698 .equals( "Aranaeus" ) ) {
6702 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
6703 if ( phylogenies.length != 3 ) {
6706 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6709 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6712 if ( phylogenies[ 0 ].isRooted() ) {
6715 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6718 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6721 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6722 .equals( "Aranaeus" ) ) {
6725 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6728 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6731 if ( phylogenies[ 1 ].isRooted() ) {
6734 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6737 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6740 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6741 .equals( "Aranaeus" ) ) {
6744 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6747 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6750 if ( !phylogenies[ 2 ].isRooted() ) {
6753 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6756 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6759 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6760 .equals( "Aranaeus" ) ) {
6764 catch ( final Exception e ) {
6765 e.printStackTrace( System.out );
6771 private static boolean testNHParsing() {
6773 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6774 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
6775 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
6778 final NHXParser nhxp = new NHXParser();
6779 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
6780 nhxp.setReplaceUnderscores( true );
6781 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
6782 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
6785 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
6788 final Phylogeny p1b = factory
6789 .create( " \n \t \b \r \f ; ( \n \t \b \r \f; A ; \n \t \b \r \f, \n \t \b \r \f; B ; \n \t \b \r \f 1 \n \t \b \r \f ; \n \t \b \r \f );;;;; \n \t \b \r \f;;; \n \t \b \r \f ",
6790 new NHXParser() )[ 0 ];
6791 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
6794 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
6797 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
6798 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
6799 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
6800 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
6801 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
6802 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
6803 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
6804 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
6805 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
6806 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
6807 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
6808 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
6809 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
6811 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
6814 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
6817 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
6820 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
6823 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
6824 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
6825 final String p16_S = "((A,B),C)";
6826 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
6827 if ( p16.length != 1 ) {
6830 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
6833 final String p17_S = "(C,(A,B))";
6834 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
6835 if ( p17.length != 1 ) {
6838 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
6841 final String p18_S = "((A,B),(C,D))";
6842 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
6843 if ( p18.length != 1 ) {
6846 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
6849 final String p19_S = "(((A,B),C),D)";
6850 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
6851 if ( p19.length != 1 ) {
6854 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
6857 final String p20_S = "(A,(B,(C,D)))";
6858 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
6859 if ( p20.length != 1 ) {
6862 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
6865 final String p21_S = "(A,(B,(C,(D,E))))";
6866 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
6867 if ( p21.length != 1 ) {
6870 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
6873 final String p22_S = "((((A,B),C),D),E)";
6874 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
6875 if ( p22.length != 1 ) {
6878 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
6881 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6882 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
6883 if ( p23.length != 1 ) {
6884 System.out.println( "xl=" + p23.length );
6888 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
6891 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6892 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
6893 if ( p24.length != 1 ) {
6896 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
6899 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6900 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6901 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
6902 if ( p241.length != 2 ) {
6905 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
6908 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
6911 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
6912 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
6913 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
6914 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
6915 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
6916 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
6917 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
6918 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
6919 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
6920 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
6923 final String p26_S = "(A,B)ab";
6924 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
6925 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
6928 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6929 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
6930 if ( p27s.length != 1 ) {
6931 System.out.println( "xxl=" + p27s.length );
6935 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6936 System.out.println( p27s[ 0 ].toNewHampshireX() );
6940 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
6942 if ( p27.length != 1 ) {
6943 System.out.println( "yl=" + p27.length );
6947 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6948 System.out.println( p27[ 0 ].toNewHampshireX() );
6952 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6953 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6954 final String p28_S3 = "(A,B)ab";
6955 final String p28_S4 = "((((A,B),C),D),;E;)";
6956 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
6958 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
6961 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
6964 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
6967 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
6970 if ( p28.length != 4 ) {
6973 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";
6974 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
6975 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
6978 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";
6979 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
6980 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
6983 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
6984 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
6985 if ( ( p32.length != 0 ) ) {
6988 final String p33_S = "A";
6989 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
6990 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
6993 final String p34_S = "B;";
6994 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
6995 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
6998 final String p35_S = "B:0.2";
6999 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
7000 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
7003 final String p36_S = "(A)";
7004 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
7005 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
7008 final String p37_S = "((A))";
7009 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
7010 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
7013 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7014 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
7015 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
7018 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7019 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
7020 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
7023 final String p40_S = "(A,B,C)";
7024 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
7025 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
7028 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
7029 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
7030 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
7033 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
7034 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
7035 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7038 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)";
7039 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7040 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7043 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)))";
7044 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7045 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7048 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7049 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7050 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7053 final String p46_S = "";
7054 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7055 if ( p46.length != 0 ) {
7058 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7059 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7062 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7063 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7066 final Phylogeny p49 = factory
7067 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7068 new NHXParser() )[ 0 ];
7069 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7072 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7073 if ( p50.getNode( "A" ) == null ) {
7076 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7077 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7080 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7083 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7084 .equals( "((A,B)88:2.0,C);" ) ) {
7087 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7088 if ( p51.getNode( "A(A" ) == null ) {
7091 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7092 if ( p52.getNode( "A(A" ) == null ) {
7095 final Phylogeny p53 = factory
7096 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7097 new NHXParser() )[ 0 ];
7098 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7102 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7103 if ( p54.getNode( "A" ) == null ) {
7106 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7107 .equals( "((A,B)[88],C);" ) ) {
7111 catch ( final Exception e ) {
7112 e.printStackTrace( System.out );
7118 private static boolean testNHParsingIter() {
7120 final String p0_str = "(A,B);";
7121 final NHXParser p = new NHXParser();
7122 p.setSource( p0_str );
7123 if ( !p.hasNext() ) {
7126 final Phylogeny p0 = p.next();
7127 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7128 System.out.println( p0.toNewHampshire() );
7131 if ( p.hasNext() ) {
7134 if ( p.next() != null ) {
7138 final String p00_str = "(A,B)root;";
7139 p.setSource( p00_str );
7140 final Phylogeny p00 = p.next();
7141 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7142 System.out.println( p00.toNewHampshire() );
7146 final String p000_str = "A;";
7147 p.setSource( p000_str );
7148 final Phylogeny p000 = p.next();
7149 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7150 System.out.println( p000.toNewHampshire() );
7154 final String p0000_str = "A";
7155 p.setSource( p0000_str );
7156 final Phylogeny p0000 = p.next();
7157 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7158 System.out.println( p0000.toNewHampshire() );
7162 p.setSource( "(A)" );
7163 final Phylogeny p00000 = p.next();
7164 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7165 System.out.println( p00000.toNewHampshire() );
7169 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7170 p.setSource( p1_str );
7171 if ( !p.hasNext() ) {
7174 final Phylogeny p1_0 = p.next();
7175 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7176 System.out.println( p1_0.toNewHampshire() );
7179 if ( !p.hasNext() ) {
7182 final Phylogeny p1_1 = p.next();
7183 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7184 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7187 if ( !p.hasNext() ) {
7190 final Phylogeny p1_2 = p.next();
7191 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7192 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7195 if ( !p.hasNext() ) {
7198 final Phylogeny p1_3 = p.next();
7199 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7200 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7203 if ( p.hasNext() ) {
7206 if ( p.next() != null ) {
7210 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7211 p.setSource( p2_str );
7212 if ( !p.hasNext() ) {
7215 Phylogeny p2_0 = p.next();
7216 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7217 System.out.println( p2_0.toNewHampshire() );
7220 if ( !p.hasNext() ) {
7223 Phylogeny p2_1 = p.next();
7224 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7225 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7228 if ( !p.hasNext() ) {
7231 Phylogeny p2_2 = p.next();
7232 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7233 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7236 if ( !p.hasNext() ) {
7239 Phylogeny p2_3 = p.next();
7240 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7241 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7244 if ( !p.hasNext() ) {
7247 Phylogeny p2_4 = p.next();
7248 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7249 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7252 if ( p.hasNext() ) {
7255 if ( p.next() != null ) {
7260 if ( !p.hasNext() ) {
7264 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7265 System.out.println( p2_0.toNewHampshire() );
7268 if ( !p.hasNext() ) {
7272 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7273 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7276 if ( !p.hasNext() ) {
7280 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7281 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7284 if ( !p.hasNext() ) {
7288 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7289 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7292 if ( !p.hasNext() ) {
7296 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7297 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7300 if ( p.hasNext() ) {
7303 if ( p.next() != null ) {
7307 final String p3_str = "((A,B),C)abc";
7308 p.setSource( p3_str );
7309 if ( !p.hasNext() ) {
7312 final Phylogeny p3_0 = p.next();
7313 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7316 if ( p.hasNext() ) {
7319 if ( p.next() != null ) {
7323 final String p4_str = "((A,B)ab,C)abc";
7324 p.setSource( p4_str );
7325 if ( !p.hasNext() ) {
7328 final Phylogeny p4_0 = p.next();
7329 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7332 if ( p.hasNext() ) {
7335 if ( p.next() != null ) {
7339 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7340 p.setSource( p5_str );
7341 if ( !p.hasNext() ) {
7344 final Phylogeny p5_0 = p.next();
7345 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7348 if ( p.hasNext() ) {
7351 if ( p.next() != null ) {
7355 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7356 p.setSource( p6_str );
7357 if ( !p.hasNext() ) {
7360 Phylogeny p6_0 = p.next();
7361 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7364 if ( p.hasNext() ) {
7367 if ( p.next() != null ) {
7371 if ( !p.hasNext() ) {
7375 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7378 if ( p.hasNext() ) {
7381 if ( p.next() != null ) {
7385 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7386 p.setSource( p7_str );
7387 if ( !p.hasNext() ) {
7390 Phylogeny p7_0 = p.next();
7391 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7394 if ( p.hasNext() ) {
7397 if ( p.next() != null ) {
7401 if ( !p.hasNext() ) {
7405 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7408 if ( p.hasNext() ) {
7411 if ( p.next() != null ) {
7415 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
7416 p.setSource( p8_str );
7417 if ( !p.hasNext() ) {
7420 Phylogeny p8_0 = p.next();
7421 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7424 if ( !p.hasNext() ) {
7427 if ( !p.hasNext() ) {
7430 Phylogeny p8_1 = p.next();
7431 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7434 if ( p.hasNext() ) {
7437 if ( p.next() != null ) {
7441 if ( !p.hasNext() ) {
7445 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7448 if ( !p.hasNext() ) {
7452 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7455 if ( p.hasNext() ) {
7458 if ( p.next() != null ) {
7464 if ( p.hasNext() ) {
7468 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
7469 if ( !p.hasNext() ) {
7472 Phylogeny p_27 = p.next();
7473 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7474 System.out.println( p_27.toNewHampshireX() );
7478 if ( p.hasNext() ) {
7481 if ( p.next() != null ) {
7485 if ( !p.hasNext() ) {
7489 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7490 System.out.println( p_27.toNewHampshireX() );
7494 if ( p.hasNext() ) {
7497 if ( p.next() != null ) {
7501 catch ( final Exception e ) {
7502 e.printStackTrace( System.out );
7508 private static boolean testNHXconversion() {
7510 final PhylogenyNode n1 = new PhylogenyNode();
7511 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7512 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7513 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7514 final PhylogenyNode n5 = PhylogenyNode
7515 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
7516 final PhylogenyNode n6 = PhylogenyNode
7517 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
7518 if ( !n1.toNewHampshireX().equals( "" ) ) {
7521 if ( !n2.toNewHampshireX().equals( "" ) ) {
7524 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
7527 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
7530 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
7533 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
7534 System.out.println( n6.toNewHampshireX() );
7538 catch ( final Exception e ) {
7539 e.printStackTrace( System.out );
7545 private static boolean testNHXNodeParsing() {
7547 final PhylogenyNode n1 = new PhylogenyNode();
7548 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7549 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7550 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7551 final PhylogenyNode n5 = PhylogenyNode
7552 .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]" );
7553 if ( !n3.getName().equals( "n3" ) ) {
7556 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7559 if ( n3.isDuplication() ) {
7562 if ( n3.isHasAssignedEvent() ) {
7565 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
7568 if ( !n4.getName().equals( "n4" ) ) {
7571 if ( n4.getDistanceToParent() != 0.01 ) {
7574 if ( !n5.getName().equals( "n5" ) ) {
7577 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
7580 if ( n5.getDistanceToParent() != 0.1 ) {
7583 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
7586 if ( !n5.isDuplication() ) {
7589 if ( !n5.isHasAssignedEvent() ) {
7592 final PhylogenyNode n8 = PhylogenyNode
7593 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
7594 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7595 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7598 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
7601 final PhylogenyNode n9 = PhylogenyNode
7602 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
7603 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7604 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
7607 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
7610 final PhylogenyNode n10 = PhylogenyNode
7611 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7612 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
7615 final PhylogenyNode n20 = PhylogenyNode
7616 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7617 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7620 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
7623 final PhylogenyNode n20x = PhylogenyNode
7624 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7625 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
7628 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
7631 final PhylogenyNode n20xx = PhylogenyNode
7632 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7633 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
7636 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
7639 final PhylogenyNode n20xxx = PhylogenyNode
7640 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7641 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
7644 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
7647 final PhylogenyNode n20xxxx = PhylogenyNode
7648 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7649 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
7652 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
7655 final PhylogenyNode n21 = PhylogenyNode
7656 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7657 if ( !n21.getName().equals( "N21_PIG" ) ) {
7660 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
7663 final PhylogenyNode n21x = PhylogenyNode
7664 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7665 if ( !n21x.getName().equals( "n21_PIG" ) ) {
7668 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
7671 final PhylogenyNode n22 = PhylogenyNode
7672 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7673 if ( !n22.getName().equals( "n22/PIG" ) ) {
7676 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
7679 final PhylogenyNode n23 = PhylogenyNode
7680 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7681 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
7684 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
7687 final PhylogenyNode a = PhylogenyNode
7688 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7689 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7692 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
7695 final PhylogenyNode c1 = PhylogenyNode
7696 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
7697 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7698 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
7701 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
7704 final PhylogenyNode c2 = PhylogenyNode
7705 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
7706 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7707 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
7710 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
7713 final PhylogenyNode e3 = PhylogenyNode
7714 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7715 if ( !e3.getName().equals( "n10_RAT~" ) ) {
7718 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
7721 final PhylogenyNode n11 = PhylogenyNode
7722 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
7723 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7724 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
7727 if ( n11.getDistanceToParent() != 0.4 ) {
7730 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
7733 final PhylogenyNode n12 = PhylogenyNode
7734 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
7735 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7736 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
7739 if ( n12.getDistanceToParent() != 0.4 ) {
7742 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
7745 final PhylogenyNode o = PhylogenyNode
7746 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7747 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
7750 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
7753 if ( n1.getName().compareTo( "" ) != 0 ) {
7756 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7759 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7762 if ( n2.getName().compareTo( "" ) != 0 ) {
7765 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7768 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7771 final PhylogenyNode n00 = PhylogenyNode
7772 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
7773 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
7776 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
7779 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
7780 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
7783 final PhylogenyNode n13 = PhylogenyNode
7784 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7785 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
7788 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
7791 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7794 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7797 final PhylogenyNode n14 = PhylogenyNode
7798 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7799 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
7802 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
7805 final PhylogenyNode n15 = PhylogenyNode
7806 .createInstanceFromNhxString( "something_wicked[123]",
7807 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7808 if ( !n15.getName().equals( "something_wicked" ) ) {
7811 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
7814 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
7817 final PhylogenyNode n16 = PhylogenyNode
7818 .createInstanceFromNhxString( "something_wicked2[9]",
7819 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7820 if ( !n16.getName().equals( "something_wicked2" ) ) {
7823 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
7826 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
7829 final PhylogenyNode n17 = PhylogenyNode
7830 .createInstanceFromNhxString( "something_wicked3[a]",
7831 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7832 if ( !n17.getName().equals( "something_wicked3" ) ) {
7835 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
7838 final PhylogenyNode n18 = PhylogenyNode
7839 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7840 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
7843 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
7846 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
7849 final PhylogenyNode n19 = PhylogenyNode
7850 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7851 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
7854 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7857 final PhylogenyNode n30 = PhylogenyNode
7858 .createInstanceFromNhxString( "blah_1234567-roejojoej",
7859 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7860 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
7863 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7866 final PhylogenyNode n31 = PhylogenyNode
7867 .createInstanceFromNhxString( "blah_12345678-roejojoej",
7868 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7869 if ( n31.getNodeData().isHasTaxonomy() ) {
7872 final PhylogenyNode n32 = PhylogenyNode
7873 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7874 if ( n32.getNodeData().isHasTaxonomy() ) {
7877 final PhylogenyNode n40 = PhylogenyNode
7878 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7879 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7882 final PhylogenyNode n41 = PhylogenyNode
7883 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7884 if ( n41.getNodeData().isHasTaxonomy() ) {
7887 final PhylogenyNode n42 = PhylogenyNode
7888 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7889 if ( n42.getNodeData().isHasTaxonomy() ) {
7892 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
7893 NHXParser.TAXONOMY_EXTRACTION.NO );
7894 if ( n43.getNodeData().isHasTaxonomy() ) {
7897 final PhylogenyNode n44 = PhylogenyNode
7898 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7899 if ( n44.getNodeData().isHasTaxonomy() ) {
7903 catch ( final Exception e ) {
7904 e.printStackTrace( System.out );
7910 private static boolean testNHXParsing() {
7912 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7913 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
7914 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
7917 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]";
7918 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
7919 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7922 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]";
7923 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
7924 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
7927 final Phylogeny[] p3 = factory
7928 .create( "[ comment&&NHX,())))](((((((A:0.2[&&NHX:S=qwerty]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=asdf]):0.4[&&NHX:S=zxc]):0.5[&&NHX:S=a]):0.6[&&NHX:S=asd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq]",
7930 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7933 final Phylogeny[] p4 = factory
7934 .create( "(((((((A:0.2[&&NHX:S=qwerty]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=asdf]):0.4[&&NHX:S=zxc]):0.5[&&NHX:S=a]):0.6[&&NHX:S=asd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq][comment(]",
7936 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7939 final Phylogeny[] p5 = factory
7940 .create( "[] ( [][ ][ ] ([((( &&NHXcomment only![[[[[[]([]((((A:0.2[&&NHX:S=q[comment )))]werty][,,,,))]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=a[comment,,))]sdf])[comment(((]:0.4[&&NHX:S=zxc][comment(((][comment(((]):0.5[&&NHX:S=a]):0.6[&&NHX:S=a[comment(((]sd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq][comment(((]",
7942 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7945 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)";
7946 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)";
7947 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
7948 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
7951 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)))";
7952 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)))";
7953 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
7954 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
7957 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]) ))[,,, ])))))))";
7958 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
7959 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
7960 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
7963 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
7964 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7967 final Phylogeny p10 = factory
7968 .create( " [79] ( (A [co mment] :0 .2[comment],B:0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],C: 0.1)[comment]root:0.1[100] [comment]",
7969 new NHXParser() )[ 0 ];
7970 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7974 catch ( final Exception e ) {
7975 e.printStackTrace( System.out );
7981 private static boolean testNHXParsingMB() {
7983 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7984 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
7985 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7986 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
7987 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
7988 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
7989 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7990 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
7991 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
7992 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
7993 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
7996 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
7999 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
8000 0.1100000000000000e+00 ) ) {
8003 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
8006 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
8009 final Phylogeny p2 = factory
8010 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
8011 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8012 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8013 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8014 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8015 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8016 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8017 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8018 + "7.369400000000000e-02}])",
8019 new NHXParser() )[ 0 ];
8020 if ( p2.getNode( "1" ) == null ) {
8023 if ( p2.getNode( "2" ) == null ) {
8027 catch ( final Exception e ) {
8028 e.printStackTrace( System.out );
8035 private static boolean testNHXParsingQuotes() {
8037 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8038 final NHXParser p = new NHXParser();
8039 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
8040 if ( phylogenies_0.length != 5 ) {
8043 final Phylogeny phy = phylogenies_0[ 4 ];
8044 if ( phy.getNumberOfExternalNodes() != 7 ) {
8047 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
8050 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
8053 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
8054 .getScientificName().equals( "hsapiens" ) ) {
8057 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
8060 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
8063 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
8066 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
8069 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8072 final NHXParser p1p = new NHXParser();
8073 p1p.setIgnoreQuotes( true );
8074 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8075 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8078 final NHXParser p2p = new NHXParser();
8079 p1p.setIgnoreQuotes( false );
8080 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8081 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8084 final NHXParser p3p = new NHXParser();
8085 p3p.setIgnoreQuotes( false );
8086 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8087 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8090 final NHXParser p4p = new NHXParser();
8091 p4p.setIgnoreQuotes( false );
8092 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8093 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8096 final Phylogeny p10 = factory
8097 .create( " [79] ( (\"A \n\tB \" [co mment] :0 .2[comment],'B':0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],'C (or D?\\//;,))': 0.1)[comment]'\nroot is here (cool, was! ) ':0.1[100] [comment]",
8098 new NHXParser() )[ 0 ];
8099 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]";
8100 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8103 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8104 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8108 final Phylogeny p12 = factory
8109 .create( " [79] ( (\"A \n\tB \" [[][] :0 .2[comment][\t&\t&\n N\tH\tX:S=mo\tnkey !],'\tB\t\b\t\n\f\rB B ':0.0\b3[])\t[com ment]: 0. 5 \t[ 9 1 ][ \ncomment],'C\t (or D?\\//;,))': 0.\b1)[comment]'\nroot \tis here (cool, \b\t\n\f\r was! ) ':0.1[100] [comment]",
8110 new NHXParser() )[ 0 ];
8111 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]";
8112 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8115 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8116 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8119 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;";
8120 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8123 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8124 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8128 catch ( final Exception e ) {
8129 e.printStackTrace( System.out );
8135 private static boolean testNodeRemoval() {
8137 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8138 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8139 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8140 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8143 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8144 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8145 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8148 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8149 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8150 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8154 catch ( final Exception e ) {
8155 e.printStackTrace( System.out );
8161 private static boolean testPhylogenyBranch() {
8163 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8164 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8165 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8166 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8167 if ( !a1b1.equals( a1b1 ) ) {
8170 if ( !a1b1.equals( b1a1 ) ) {
8173 if ( !b1a1.equals( a1b1 ) ) {
8176 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8177 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8178 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8179 if ( a1_b1.equals( b1_a1 ) ) {
8182 if ( a1_b1.equals( a1_b1_ ) ) {
8185 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8186 if ( !a1_b1.equals( b1_a1_ ) ) {
8189 if ( a1_b1_.equals( b1_a1_ ) ) {
8192 if ( !a1_b1_.equals( b1_a1 ) ) {
8196 catch ( final Exception e ) {
8197 e.printStackTrace( System.out );
8203 private static boolean testPhyloXMLparsingOfDistributionElement() {
8205 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8206 PhyloXmlParser xml_parser = null;
8208 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8210 catch ( final Exception e ) {
8211 // Do nothing -- means were not running from jar.
8213 if ( xml_parser == null ) {
8214 xml_parser = new PhyloXmlParser();
8215 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8216 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8219 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8222 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8224 if ( xml_parser.getErrorCount() > 0 ) {
8225 System.out.println( xml_parser.getErrorMessages().toString() );
8228 if ( phylogenies_0.length != 1 ) {
8231 final Phylogeny t1 = phylogenies_0[ 0 ];
8232 PhylogenyNode n = null;
8233 Distribution d = null;
8234 n = t1.getNode( "root node" );
8235 if ( !n.getNodeData().isHasDistribution() ) {
8238 if ( n.getNodeData().getDistributions().size() != 1 ) {
8241 d = n.getNodeData().getDistribution();
8242 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8245 if ( d.getPoints().size() != 1 ) {
8248 if ( d.getPolygons() != null ) {
8251 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8254 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8257 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8260 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8263 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8266 n = t1.getNode( "node a" );
8267 if ( !n.getNodeData().isHasDistribution() ) {
8270 if ( n.getNodeData().getDistributions().size() != 2 ) {
8273 d = n.getNodeData().getDistribution( 1 );
8274 if ( !d.getDesc().equals( "San Diego" ) ) {
8277 if ( d.getPoints().size() != 1 ) {
8280 if ( d.getPolygons() != null ) {
8283 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8286 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8289 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8292 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8295 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8298 n = t1.getNode( "node bb" );
8299 if ( !n.getNodeData().isHasDistribution() ) {
8302 if ( n.getNodeData().getDistributions().size() != 1 ) {
8305 d = n.getNodeData().getDistribution( 0 );
8306 if ( d.getPoints().size() != 3 ) {
8309 if ( d.getPolygons().size() != 2 ) {
8312 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8315 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8318 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8321 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8324 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8327 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8330 Polygon p = d.getPolygons().get( 0 );
8331 if ( p.getPoints().size() != 3 ) {
8334 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8337 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8340 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8343 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8346 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8349 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8352 p = d.getPolygons().get( 1 );
8353 if ( p.getPoints().size() != 3 ) {
8356 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8359 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8362 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8366 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
8367 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
8368 if ( rt.length != 1 ) {
8371 final Phylogeny t1_rt = rt[ 0 ];
8372 n = t1_rt.getNode( "root node" );
8373 if ( !n.getNodeData().isHasDistribution() ) {
8376 if ( n.getNodeData().getDistributions().size() != 1 ) {
8379 d = n.getNodeData().getDistribution();
8380 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8383 if ( d.getPoints().size() != 1 ) {
8386 if ( d.getPolygons() != null ) {
8389 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8392 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8395 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8398 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8401 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8404 n = t1_rt.getNode( "node a" );
8405 if ( !n.getNodeData().isHasDistribution() ) {
8408 if ( n.getNodeData().getDistributions().size() != 2 ) {
8411 d = n.getNodeData().getDistribution( 1 );
8412 if ( !d.getDesc().equals( "San Diego" ) ) {
8415 if ( d.getPoints().size() != 1 ) {
8418 if ( d.getPolygons() != null ) {
8421 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8424 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8427 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8430 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8433 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8436 n = t1_rt.getNode( "node bb" );
8437 if ( !n.getNodeData().isHasDistribution() ) {
8440 if ( n.getNodeData().getDistributions().size() != 1 ) {
8443 d = n.getNodeData().getDistribution( 0 );
8444 if ( d.getPoints().size() != 3 ) {
8447 if ( d.getPolygons().size() != 2 ) {
8450 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8453 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8456 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8459 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8462 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8465 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8468 p = d.getPolygons().get( 0 );
8469 if ( p.getPoints().size() != 3 ) {
8472 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8475 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8478 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8481 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8484 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8487 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8490 p = d.getPolygons().get( 1 );
8491 if ( p.getPoints().size() != 3 ) {
8494 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8497 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8500 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8504 catch ( final Exception e ) {
8505 e.printStackTrace( System.out );
8511 private static boolean testPostOrderIterator() {
8513 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8514 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8515 PhylogenyNodeIterator it0;
8516 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
8519 for( it0.reset(); it0.hasNext(); ) {
8522 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8523 final PhylogenyNodeIterator it = t1.iteratorPostorder();
8524 if ( !it.next().getName().equals( "A" ) ) {
8527 if ( !it.next().getName().equals( "B" ) ) {
8530 if ( !it.next().getName().equals( "ab" ) ) {
8533 if ( !it.next().getName().equals( "C" ) ) {
8536 if ( !it.next().getName().equals( "D" ) ) {
8539 if ( !it.next().getName().equals( "cd" ) ) {
8542 if ( !it.next().getName().equals( "abcd" ) ) {
8545 if ( !it.next().getName().equals( "E" ) ) {
8548 if ( !it.next().getName().equals( "F" ) ) {
8551 if ( !it.next().getName().equals( "ef" ) ) {
8554 if ( !it.next().getName().equals( "G" ) ) {
8557 if ( !it.next().getName().equals( "H" ) ) {
8560 if ( !it.next().getName().equals( "gh" ) ) {
8563 if ( !it.next().getName().equals( "efgh" ) ) {
8566 if ( !it.next().getName().equals( "r" ) ) {
8569 if ( it.hasNext() ) {
8573 catch ( final Exception e ) {
8574 e.printStackTrace( System.out );
8580 private static boolean testPreOrderIterator() {
8582 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8583 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8584 PhylogenyNodeIterator it0;
8585 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
8588 for( it0.reset(); it0.hasNext(); ) {
8591 PhylogenyNodeIterator it = t0.iteratorPreorder();
8592 if ( !it.next().getName().equals( "r" ) ) {
8595 if ( !it.next().getName().equals( "ab" ) ) {
8598 if ( !it.next().getName().equals( "A" ) ) {
8601 if ( !it.next().getName().equals( "B" ) ) {
8604 if ( !it.next().getName().equals( "cd" ) ) {
8607 if ( !it.next().getName().equals( "C" ) ) {
8610 if ( !it.next().getName().equals( "D" ) ) {
8613 if ( it.hasNext() ) {
8616 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8617 it = t1.iteratorPreorder();
8618 if ( !it.next().getName().equals( "r" ) ) {
8621 if ( !it.next().getName().equals( "abcd" ) ) {
8624 if ( !it.next().getName().equals( "ab" ) ) {
8627 if ( !it.next().getName().equals( "A" ) ) {
8630 if ( !it.next().getName().equals( "B" ) ) {
8633 if ( !it.next().getName().equals( "cd" ) ) {
8636 if ( !it.next().getName().equals( "C" ) ) {
8639 if ( !it.next().getName().equals( "D" ) ) {
8642 if ( !it.next().getName().equals( "efgh" ) ) {
8645 if ( !it.next().getName().equals( "ef" ) ) {
8648 if ( !it.next().getName().equals( "E" ) ) {
8651 if ( !it.next().getName().equals( "F" ) ) {
8654 if ( !it.next().getName().equals( "gh" ) ) {
8657 if ( !it.next().getName().equals( "G" ) ) {
8660 if ( !it.next().getName().equals( "H" ) ) {
8663 if ( it.hasNext() ) {
8667 catch ( final Exception e ) {
8668 e.printStackTrace( System.out );
8674 private static boolean testPropertiesMap() {
8676 final PropertiesMap pm = new PropertiesMap();
8677 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8678 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8679 final Property p2 = new Property( "something:else",
8681 "improbable:research",
8684 pm.addProperty( p0 );
8685 pm.addProperty( p1 );
8686 pm.addProperty( p2 );
8687 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
8690 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
8693 if ( pm.getProperties().size() != 3 ) {
8696 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
8699 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8702 if ( pm.getProperties().size() != 3 ) {
8705 pm.removeProperty( "dimensions:diameter" );
8706 if ( pm.getProperties().size() != 2 ) {
8709 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
8712 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8716 catch ( final Exception e ) {
8717 e.printStackTrace( System.out );
8723 private static boolean testProteinId() {
8725 final ProteinId id1 = new ProteinId( "a" );
8726 final ProteinId id2 = new ProteinId( "a" );
8727 final ProteinId id3 = new ProteinId( "A" );
8728 final ProteinId id4 = new ProteinId( "b" );
8729 if ( !id1.equals( id1 ) ) {
8732 if ( id1.getId().equals( "x" ) ) {
8735 if ( id1.getId().equals( null ) ) {
8738 if ( !id1.equals( id2 ) ) {
8741 if ( id1.equals( id3 ) ) {
8744 if ( id1.hashCode() != id1.hashCode() ) {
8747 if ( id1.hashCode() != id2.hashCode() ) {
8750 if ( id1.hashCode() == id3.hashCode() ) {
8753 if ( id1.compareTo( id1 ) != 0 ) {
8756 if ( id1.compareTo( id2 ) != 0 ) {
8759 if ( id1.compareTo( id3 ) != 0 ) {
8762 if ( id1.compareTo( id4 ) >= 0 ) {
8765 if ( id4.compareTo( id1 ) <= 0 ) {
8768 if ( !id4.getId().equals( "b" ) ) {
8771 final ProteinId id5 = new ProteinId( " C " );
8772 if ( !id5.getId().equals( "C" ) ) {
8775 if ( id5.equals( id1 ) ) {
8779 catch ( final Exception e ) {
8780 e.printStackTrace( System.out );
8786 private static boolean testReIdMethods() {
8788 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8789 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
8790 final long count = PhylogenyNode.getNodeCount();
8792 if ( p.getNode( "r" ).getId() != count ) {
8795 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
8798 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
8801 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
8804 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
8807 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
8810 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
8813 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
8816 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
8819 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
8822 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
8825 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
8828 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
8831 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
8834 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
8838 catch ( final Exception e ) {
8839 e.printStackTrace( System.out );
8845 private static boolean testRerooting() {
8847 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8848 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",
8849 new NHXParser() )[ 0 ];
8850 if ( !t1.isRooted() ) {
8853 t1.reRoot( t1.getNode( "D" ) );
8854 t1.reRoot( t1.getNode( "CD" ) );
8855 t1.reRoot( t1.getNode( "A" ) );
8856 t1.reRoot( t1.getNode( "B" ) );
8857 t1.reRoot( t1.getNode( "AB" ) );
8858 t1.reRoot( t1.getNode( "D" ) );
8859 t1.reRoot( t1.getNode( "C" ) );
8860 t1.reRoot( t1.getNode( "CD" ) );
8861 t1.reRoot( t1.getNode( "A" ) );
8862 t1.reRoot( t1.getNode( "B" ) );
8863 t1.reRoot( t1.getNode( "AB" ) );
8864 t1.reRoot( t1.getNode( "D" ) );
8865 t1.reRoot( t1.getNode( "D" ) );
8866 t1.reRoot( t1.getNode( "C" ) );
8867 t1.reRoot( t1.getNode( "A" ) );
8868 t1.reRoot( t1.getNode( "B" ) );
8869 t1.reRoot( t1.getNode( "AB" ) );
8870 t1.reRoot( t1.getNode( "C" ) );
8871 t1.reRoot( t1.getNode( "D" ) );
8872 t1.reRoot( t1.getNode( "CD" ) );
8873 t1.reRoot( t1.getNode( "D" ) );
8874 t1.reRoot( t1.getNode( "A" ) );
8875 t1.reRoot( t1.getNode( "B" ) );
8876 t1.reRoot( t1.getNode( "AB" ) );
8877 t1.reRoot( t1.getNode( "C" ) );
8878 t1.reRoot( t1.getNode( "D" ) );
8879 t1.reRoot( t1.getNode( "CD" ) );
8880 t1.reRoot( t1.getNode( "D" ) );
8881 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
8884 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
8887 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
8890 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
8893 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
8896 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
8899 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",
8900 new NHXParser() )[ 0 ];
8901 t2.reRoot( t2.getNode( "A" ) );
8902 t2.reRoot( t2.getNode( "D" ) );
8903 t2.reRoot( t2.getNode( "ABC" ) );
8904 t2.reRoot( t2.getNode( "A" ) );
8905 t2.reRoot( t2.getNode( "B" ) );
8906 t2.reRoot( t2.getNode( "D" ) );
8907 t2.reRoot( t2.getNode( "C" ) );
8908 t2.reRoot( t2.getNode( "ABC" ) );
8909 t2.reRoot( t2.getNode( "A" ) );
8910 t2.reRoot( t2.getNode( "B" ) );
8911 t2.reRoot( t2.getNode( "AB" ) );
8912 t2.reRoot( t2.getNode( "AB" ) );
8913 t2.reRoot( t2.getNode( "D" ) );
8914 t2.reRoot( t2.getNode( "C" ) );
8915 t2.reRoot( t2.getNode( "B" ) );
8916 t2.reRoot( t2.getNode( "AB" ) );
8917 t2.reRoot( t2.getNode( "D" ) );
8918 t2.reRoot( t2.getNode( "D" ) );
8919 t2.reRoot( t2.getNode( "ABC" ) );
8920 t2.reRoot( t2.getNode( "A" ) );
8921 t2.reRoot( t2.getNode( "B" ) );
8922 t2.reRoot( t2.getNode( "AB" ) );
8923 t2.reRoot( t2.getNode( "D" ) );
8924 t2.reRoot( t2.getNode( "C" ) );
8925 t2.reRoot( t2.getNode( "ABC" ) );
8926 t2.reRoot( t2.getNode( "A" ) );
8927 t2.reRoot( t2.getNode( "B" ) );
8928 t2.reRoot( t2.getNode( "AB" ) );
8929 t2.reRoot( t2.getNode( "D" ) );
8930 t2.reRoot( t2.getNode( "D" ) );
8931 t2.reRoot( t2.getNode( "C" ) );
8932 t2.reRoot( t2.getNode( "A" ) );
8933 t2.reRoot( t2.getNode( "B" ) );
8934 t2.reRoot( t2.getNode( "AB" ) );
8935 t2.reRoot( t2.getNode( "C" ) );
8936 t2.reRoot( t2.getNode( "D" ) );
8937 t2.reRoot( t2.getNode( "ABC" ) );
8938 t2.reRoot( t2.getNode( "D" ) );
8939 t2.reRoot( t2.getNode( "A" ) );
8940 t2.reRoot( t2.getNode( "B" ) );
8941 t2.reRoot( t2.getNode( "AB" ) );
8942 t2.reRoot( t2.getNode( "C" ) );
8943 t2.reRoot( t2.getNode( "D" ) );
8944 t2.reRoot( t2.getNode( "ABC" ) );
8945 t2.reRoot( t2.getNode( "D" ) );
8946 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8949 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8952 t2.reRoot( t2.getNode( "ABC" ) );
8953 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8956 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8959 t2.reRoot( t2.getNode( "AB" ) );
8960 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8963 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8966 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8969 t2.reRoot( t2.getNode( "AB" ) );
8970 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8973 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8976 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8979 t2.reRoot( t2.getNode( "D" ) );
8980 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8983 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8986 t2.reRoot( t2.getNode( "ABC" ) );
8987 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8990 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8993 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
8994 new NHXParser() )[ 0 ];
8995 t3.reRoot( t3.getNode( "B" ) );
8996 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8999 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9002 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9005 t3.reRoot( t3.getNode( "B" ) );
9006 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9009 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9012 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9015 t3.reRoot( t3.getRoot() );
9016 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9019 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9022 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9026 catch ( final Exception e ) {
9027 e.printStackTrace( System.out );
9033 private static boolean testSDIse() {
9035 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9036 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
9037 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
9038 gene1.setRooted( true );
9039 species1.setRooted( true );
9040 final SDI sdi = new SDI( gene1, species1 );
9041 if ( !gene1.getRoot().isDuplication() ) {
9044 final Phylogeny species2 = factory
9045 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9046 new NHXParser() )[ 0 ];
9047 final Phylogeny gene2 = factory
9048 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9049 new NHXParser() )[ 0 ];
9050 species2.setRooted( true );
9051 gene2.setRooted( true );
9052 final SDI sdi2 = new SDI( gene2, species2 );
9053 if ( sdi2.getDuplicationsSum() != 0 ) {
9056 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
9059 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
9062 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
9065 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
9068 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9071 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9074 final Phylogeny species3 = factory
9075 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9076 new NHXParser() )[ 0 ];
9077 final Phylogeny gene3 = factory
9078 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9079 new NHXParser() )[ 0 ];
9080 species3.setRooted( true );
9081 gene3.setRooted( true );
9082 final SDI sdi3 = new SDI( gene3, species3 );
9083 if ( sdi3.getDuplicationsSum() != 1 ) {
9086 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9089 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9092 final Phylogeny species4 = factory
9093 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9094 new NHXParser() )[ 0 ];
9095 final Phylogeny gene4 = factory
9096 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9097 new NHXParser() )[ 0 ];
9098 species4.setRooted( true );
9099 gene4.setRooted( true );
9100 final SDI sdi4 = new SDI( gene4, species4 );
9101 if ( sdi4.getDuplicationsSum() != 1 ) {
9104 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9107 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9110 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9113 if ( species4.getNumberOfExternalNodes() != 6 ) {
9116 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9119 final Phylogeny species5 = factory
9120 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9121 new NHXParser() )[ 0 ];
9122 final Phylogeny gene5 = factory
9123 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9124 new NHXParser() )[ 0 ];
9125 species5.setRooted( true );
9126 gene5.setRooted( true );
9127 final SDI sdi5 = new SDI( gene5, species5 );
9128 if ( sdi5.getDuplicationsSum() != 2 ) {
9131 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9134 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9137 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9140 if ( species5.getNumberOfExternalNodes() != 6 ) {
9143 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9146 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9147 // Conjecture for Comparing Molecular Phylogenies"
9148 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9149 final Phylogeny species6 = factory
9150 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
9151 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9152 new NHXParser() )[ 0 ];
9153 final Phylogeny gene6 = factory
9154 .create( "(((1:0.1[&&NHX:S=1],2:0.1[&&NHX:S=2])1-2:0.1,3:0.1[&&NHX:S=3])1-2-3:0.1,"
9155 + "((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,"
9156 + "(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;",
9157 new NHXParser() )[ 0 ];
9158 species6.setRooted( true );
9159 gene6.setRooted( true );
9160 final SDI sdi6 = new SDI( gene6, species6 );
9161 if ( sdi6.getDuplicationsSum() != 3 ) {
9164 if ( !gene6.getNode( "r" ).isDuplication() ) {
9167 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9170 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9173 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9176 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9179 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9182 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9185 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9188 sdi6.computeMappingCostL();
9189 if ( sdi6.computeMappingCostL() != 17 ) {
9192 if ( species6.getNumberOfExternalNodes() != 9 ) {
9195 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9198 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9199 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9200 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9201 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9202 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9203 species7.setRooted( true );
9204 final Phylogeny gene7_1 = Test
9205 .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])" );
9206 gene7_1.setRooted( true );
9207 final SDI sdi7 = new SDI( gene7_1, species7 );
9208 if ( sdi7.getDuplicationsSum() != 0 ) {
9211 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9214 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9217 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9220 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9223 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9226 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9229 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9232 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9235 final Phylogeny gene7_2 = Test
9236 .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])" );
9237 gene7_2.setRooted( true );
9238 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9239 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9242 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9245 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9248 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9251 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9254 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9257 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9260 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9263 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9266 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9270 catch ( final Exception e ) {
9276 private static boolean testSDIunrooted() {
9278 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9279 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9280 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9281 final Iterator<PhylogenyBranch> iter = l.iterator();
9282 PhylogenyBranch br = iter.next();
9283 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9286 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9290 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9293 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9297 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9300 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9304 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9307 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9311 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9314 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9318 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9321 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9325 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9328 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9332 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9335 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9339 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9342 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9346 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9349 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9353 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9356 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9360 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
9363 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
9367 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9370 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9374 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
9377 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
9381 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
9384 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
9387 if ( iter.hasNext() ) {
9390 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
9391 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
9392 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
9394 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9397 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9401 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9404 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9408 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9411 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9414 if ( iter1.hasNext() ) {
9417 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
9418 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
9419 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
9421 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9424 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9428 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9431 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9435 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9438 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9441 if ( iter2.hasNext() ) {
9444 final Phylogeny species0 = factory
9445 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9446 new NHXParser() )[ 0 ];
9447 final Phylogeny gene1 = factory
9448 .create( "(((((A:0.6[&&NHX:S=A],B:0.1[&&NHX:S=B])ab:0.1,C:0.1[&&NHX:S=C])abc:0.3,D:1.0[&&NHX:S=D])abcd:0.2,E:0.1[&&NHX:S=E])abcde:0.2,F:0.2[&&NHX:S=F])",
9449 new NHXParser() )[ 0 ];
9450 species0.setRooted( true );
9451 gene1.setRooted( true );
9452 final SDIR sdi_unrooted = new SDIR();
9453 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
9454 if ( sdi_unrooted.getCount() != 1 ) {
9457 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
9460 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
9463 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
9466 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9469 final Phylogeny gene2 = factory
9470 .create( "(((((A:2.6[&&NHX:S=A],B:0.1[&&NHX:S=B])ab:0.1,C:0.1[&&NHX:S=C])abc:0.3,D:1.0[&&NHX:S=D])abcd:0.2,E:0.1[&&NHX:S=E])abcde:0.2,F:0.2[&&NHX:S=F])",
9471 new NHXParser() )[ 0 ];
9472 gene2.setRooted( true );
9473 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
9474 if ( sdi_unrooted.getCount() != 1 ) {
9477 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9480 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9483 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
9486 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9489 final Phylogeny species6 = factory
9490 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
9491 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9492 new NHXParser() )[ 0 ];
9493 final Phylogeny gene6 = factory
9494 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
9495 + "(((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],"
9496 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9497 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9498 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9499 new NHXParser() )[ 0 ];
9500 species6.setRooted( true );
9501 gene6.setRooted( true );
9502 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
9503 if ( sdi_unrooted.getCount() != 1 ) {
9506 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9509 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9512 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9515 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9518 if ( !p6[ 0 ].getRoot().isDuplication() ) {
9521 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9524 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9527 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
9530 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9533 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
9536 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
9539 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9543 final Phylogeny species7 = factory
9544 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
9545 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9546 new NHXParser() )[ 0 ];
9547 final Phylogeny gene7 = factory
9548 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
9549 + "(((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],"
9550 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9551 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9552 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9553 new NHXParser() )[ 0 ];
9554 species7.setRooted( true );
9555 gene7.setRooted( true );
9556 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
9557 if ( sdi_unrooted.getCount() != 1 ) {
9560 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9563 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9566 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9569 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
9572 if ( !p7[ 0 ].getRoot().isDuplication() ) {
9575 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9578 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9581 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
9584 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9587 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
9590 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
9593 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9597 final Phylogeny species8 = factory
9598 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
9599 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9600 new NHXParser() )[ 0 ];
9601 final Phylogeny gene8 = factory
9602 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
9603 + "(((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],"
9604 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9605 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9606 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9607 new NHXParser() )[ 0 ];
9608 species8.setRooted( true );
9609 gene8.setRooted( true );
9610 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
9611 if ( sdi_unrooted.getCount() != 1 ) {
9614 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9617 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9620 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9623 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9626 if ( !p8[ 0 ].getRoot().isDuplication() ) {
9629 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9632 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9635 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
9638 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9641 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
9644 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
9647 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9652 catch ( final Exception e ) {
9653 e.printStackTrace( System.out );
9659 private static boolean testSequenceIdParsing() {
9661 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
9662 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9663 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9665 System.out.println( "value =" + id.getValue() );
9666 System.out.println( "provider=" + id.getSource() );
9671 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
9672 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9673 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9675 System.out.println( "value =" + id.getValue() );
9676 System.out.println( "provider=" + id.getSource() );
9681 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
9682 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9683 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9685 System.out.println( "value =" + id.getValue() );
9686 System.out.println( "provider=" + id.getSource() );
9691 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
9692 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9693 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
9695 System.out.println( "value =" + id.getValue() );
9696 System.out.println( "provider=" + id.getSource() );
9701 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
9702 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9703 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
9705 System.out.println( "value =" + id.getValue() );
9706 System.out.println( "provider=" + id.getSource() );
9711 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
9712 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9713 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
9715 System.out.println( "value =" + id.getValue() );
9716 System.out.println( "provider=" + id.getSource() );
9721 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
9722 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9723 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
9725 System.out.println( "value =" + id.getValue() );
9726 System.out.println( "provider=" + id.getSource() );
9731 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
9732 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9733 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
9735 System.out.println( "value =" + id.getValue() );
9736 System.out.println( "provider=" + id.getSource() );
9741 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
9742 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9743 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
9745 System.out.println( "value =" + id.getValue() );
9746 System.out.println( "provider=" + id.getSource() );
9751 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
9752 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9753 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
9755 System.out.println( "value =" + id.getValue() );
9756 System.out.println( "provider=" + id.getSource() );
9760 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
9762 System.out.println( "value =" + id.getValue() );
9763 System.out.println( "provider=" + id.getSource() );
9767 catch ( final Exception e ) {
9768 e.printStackTrace( System.out );
9774 private static boolean testSequenceWriter() {
9776 final String n = ForesterUtil.LINE_SEPARATOR;
9777 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
9780 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
9783 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
9786 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
9789 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
9790 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
9793 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
9794 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
9798 catch ( final Exception e ) {
9799 e.printStackTrace();
9805 private static boolean testSpecies() {
9807 final Species s1 = new BasicSpecies( "a" );
9808 final Species s2 = new BasicSpecies( "a" );
9809 final Species s3 = new BasicSpecies( "A" );
9810 final Species s4 = new BasicSpecies( "b" );
9811 if ( !s1.equals( s1 ) ) {
9814 if ( s1.getSpeciesId().equals( "x" ) ) {
9817 if ( s1.getSpeciesId().equals( null ) ) {
9820 if ( !s1.equals( s2 ) ) {
9823 if ( s1.equals( s3 ) ) {
9826 if ( s1.hashCode() != s1.hashCode() ) {
9829 if ( s1.hashCode() != s2.hashCode() ) {
9832 if ( s1.hashCode() == s3.hashCode() ) {
9835 if ( s1.compareTo( s1 ) != 0 ) {
9838 if ( s1.compareTo( s2 ) != 0 ) {
9841 if ( s1.compareTo( s3 ) != 0 ) {
9844 if ( s1.compareTo( s4 ) >= 0 ) {
9847 if ( s4.compareTo( s1 ) <= 0 ) {
9850 if ( !s4.getSpeciesId().equals( "b" ) ) {
9853 final Species s5 = new BasicSpecies( " C " );
9854 if ( !s5.getSpeciesId().equals( "C" ) ) {
9857 if ( s5.equals( s1 ) ) {
9861 catch ( final Exception e ) {
9862 e.printStackTrace( System.out );
9868 private static boolean testSplit() {
9870 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9871 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
9872 //Archaeopteryx.createApplication( p0 );
9873 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
9874 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9875 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9876 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9877 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9878 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9879 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9880 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9881 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
9882 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
9883 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
9884 // System.out.println( s0.toString() );
9886 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
9887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9889 if ( s0.match( query_nodes ) ) {
9892 query_nodes = new HashSet<PhylogenyNode>();
9893 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9894 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9895 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9896 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9897 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9900 if ( !s0.match( query_nodes ) ) {
9904 query_nodes = new HashSet<PhylogenyNode>();
9905 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9906 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9907 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9908 if ( !s0.match( query_nodes ) ) {
9912 query_nodes = new HashSet<PhylogenyNode>();
9913 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9914 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9915 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9916 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9917 if ( !s0.match( query_nodes ) ) {
9921 query_nodes = new HashSet<PhylogenyNode>();
9922 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9923 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9924 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9925 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9926 if ( !s0.match( query_nodes ) ) {
9930 query_nodes = new HashSet<PhylogenyNode>();
9931 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9932 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9933 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9934 if ( !s0.match( query_nodes ) ) {
9938 query_nodes = new HashSet<PhylogenyNode>();
9939 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9940 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9941 if ( !s0.match( query_nodes ) ) {
9945 query_nodes = new HashSet<PhylogenyNode>();
9946 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9947 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9948 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9949 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9950 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9951 if ( !s0.match( query_nodes ) ) {
9955 query_nodes = new HashSet<PhylogenyNode>();
9956 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9957 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9958 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9959 if ( !s0.match( query_nodes ) ) {
9963 query_nodes = new HashSet<PhylogenyNode>();
9964 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9965 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9966 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9968 if ( !s0.match( query_nodes ) ) {
9972 query_nodes = new HashSet<PhylogenyNode>();
9973 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9974 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9975 if ( s0.match( query_nodes ) ) {
9979 query_nodes = new HashSet<PhylogenyNode>();
9980 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9981 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9982 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9983 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9984 if ( s0.match( query_nodes ) ) {
9988 query_nodes = new HashSet<PhylogenyNode>();
9989 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9990 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9991 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9992 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9993 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9994 if ( s0.match( query_nodes ) ) {
9998 query_nodes = new HashSet<PhylogenyNode>();
9999 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10000 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10001 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10002 if ( s0.match( query_nodes ) ) {
10006 query_nodes = new HashSet<PhylogenyNode>();
10007 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10008 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10009 if ( s0.match( query_nodes ) ) {
10013 query_nodes = new HashSet<PhylogenyNode>();
10014 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10015 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10016 if ( s0.match( query_nodes ) ) {
10020 query_nodes = new HashSet<PhylogenyNode>();
10021 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10022 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10023 if ( s0.match( query_nodes ) ) {
10027 query_nodes = new HashSet<PhylogenyNode>();
10028 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10029 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10030 if ( s0.match( query_nodes ) ) {
10034 query_nodes = new HashSet<PhylogenyNode>();
10035 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10036 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10037 if ( s0.match( query_nodes ) ) {
10041 query_nodes = new HashSet<PhylogenyNode>();
10042 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10043 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10044 if ( s0.match( query_nodes ) ) {
10048 query_nodes = new HashSet<PhylogenyNode>();
10049 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10050 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10051 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10052 if ( s0.match( query_nodes ) ) {
10056 query_nodes = new HashSet<PhylogenyNode>();
10057 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10058 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10059 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10060 if ( s0.match( query_nodes ) ) {
10064 query_nodes = new HashSet<PhylogenyNode>();
10065 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10066 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10067 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10068 if ( s0.match( query_nodes ) ) {
10072 query_nodes = new HashSet<PhylogenyNode>();
10073 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10074 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10075 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10076 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10077 if ( s0.match( query_nodes ) ) {
10081 // query_nodes = new HashSet<PhylogenyNode>();
10082 // query_nodes.add( new PhylogenyNode( "X" ) );
10083 // query_nodes.add( new PhylogenyNode( "Y" ) );
10084 // query_nodes.add( new PhylogenyNode( "A" ) );
10085 // query_nodes.add( new PhylogenyNode( "B" ) );
10086 // query_nodes.add( new PhylogenyNode( "C" ) );
10087 // query_nodes.add( new PhylogenyNode( "D" ) );
10088 // query_nodes.add( new PhylogenyNode( "E" ) );
10089 // query_nodes.add( new PhylogenyNode( "F" ) );
10090 // query_nodes.add( new PhylogenyNode( "G" ) );
10091 // if ( !s0.match( query_nodes ) ) {
10094 // query_nodes = new HashSet<PhylogenyNode>();
10095 // query_nodes.add( new PhylogenyNode( "X" ) );
10096 // query_nodes.add( new PhylogenyNode( "Y" ) );
10097 // query_nodes.add( new PhylogenyNode( "A" ) );
10098 // query_nodes.add( new PhylogenyNode( "B" ) );
10099 // query_nodes.add( new PhylogenyNode( "C" ) );
10100 // if ( !s0.match( query_nodes ) ) {
10104 // query_nodes = new HashSet<PhylogenyNode>();
10105 // query_nodes.add( new PhylogenyNode( "X" ) );
10106 // query_nodes.add( new PhylogenyNode( "Y" ) );
10107 // query_nodes.add( new PhylogenyNode( "D" ) );
10108 // query_nodes.add( new PhylogenyNode( "E" ) );
10109 // query_nodes.add( new PhylogenyNode( "F" ) );
10110 // query_nodes.add( new PhylogenyNode( "G" ) );
10111 // if ( !s0.match( query_nodes ) ) {
10115 // query_nodes = new HashSet<PhylogenyNode>();
10116 // query_nodes.add( new PhylogenyNode( "X" ) );
10117 // query_nodes.add( new PhylogenyNode( "Y" ) );
10118 // query_nodes.add( new PhylogenyNode( "A" ) );
10119 // query_nodes.add( new PhylogenyNode( "B" ) );
10120 // query_nodes.add( new PhylogenyNode( "C" ) );
10121 // query_nodes.add( new PhylogenyNode( "D" ) );
10122 // if ( !s0.match( query_nodes ) ) {
10126 // query_nodes = new HashSet<PhylogenyNode>();
10127 // query_nodes.add( new PhylogenyNode( "X" ) );
10128 // query_nodes.add( new PhylogenyNode( "Y" ) );
10129 // query_nodes.add( new PhylogenyNode( "E" ) );
10130 // query_nodes.add( new PhylogenyNode( "F" ) );
10131 // query_nodes.add( new PhylogenyNode( "G" ) );
10132 // if ( !s0.match( query_nodes ) ) {
10136 // query_nodes = new HashSet<PhylogenyNode>();
10137 // query_nodes.add( new PhylogenyNode( "X" ) );
10138 // query_nodes.add( new PhylogenyNode( "Y" ) );
10139 // query_nodes.add( new PhylogenyNode( "F" ) );
10140 // query_nodes.add( new PhylogenyNode( "G" ) );
10141 // if ( !s0.match( query_nodes ) ) {
10145 query_nodes = new HashSet<PhylogenyNode>();
10146 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10147 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10148 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10149 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10150 if ( s0.match( query_nodes ) ) {
10154 query_nodes = new HashSet<PhylogenyNode>();
10155 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10156 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10157 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10158 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10159 if ( s0.match( query_nodes ) ) {
10162 ///////////////////////////
10164 query_nodes = new HashSet<PhylogenyNode>();
10165 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10166 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10167 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10168 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10169 if ( s0.match( query_nodes ) ) {
10173 query_nodes = new HashSet<PhylogenyNode>();
10174 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10175 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10176 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10177 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10178 if ( s0.match( query_nodes ) ) {
10182 query_nodes = new HashSet<PhylogenyNode>();
10183 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10184 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10185 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10186 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10187 if ( s0.match( query_nodes ) ) {
10191 query_nodes = new HashSet<PhylogenyNode>();
10192 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10193 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10194 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10195 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10196 if ( s0.match( query_nodes ) ) {
10200 query_nodes = new HashSet<PhylogenyNode>();
10201 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10202 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10203 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10204 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10205 if ( s0.match( query_nodes ) ) {
10209 query_nodes = new HashSet<PhylogenyNode>();
10210 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10211 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10212 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10213 if ( s0.match( query_nodes ) ) {
10217 query_nodes = new HashSet<PhylogenyNode>();
10218 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10219 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10220 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10221 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10222 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10223 if ( s0.match( query_nodes ) ) {
10227 query_nodes = new HashSet<PhylogenyNode>();
10228 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10229 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10230 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10231 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10232 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10233 if ( s0.match( query_nodes ) ) {
10237 query_nodes = new HashSet<PhylogenyNode>();
10238 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10239 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10240 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10241 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10242 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10243 if ( s0.match( query_nodes ) ) {
10247 query_nodes = new HashSet<PhylogenyNode>();
10248 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10249 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10250 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10251 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10252 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10253 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10254 if ( s0.match( query_nodes ) ) {
10258 catch ( final Exception e ) {
10259 e.printStackTrace();
10265 private static boolean testSplitStrict() {
10267 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10268 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10269 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10270 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10271 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10272 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10273 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10274 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10275 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10276 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10277 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
10278 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10279 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10280 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10281 if ( s0.match( query_nodes ) ) {
10284 query_nodes = new HashSet<PhylogenyNode>();
10285 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10286 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10287 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10288 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10289 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10290 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10292 if ( !s0.match( query_nodes ) ) {
10296 query_nodes = new HashSet<PhylogenyNode>();
10297 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10298 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10299 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10300 if ( !s0.match( query_nodes ) ) {
10304 query_nodes = new HashSet<PhylogenyNode>();
10305 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10306 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10307 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10308 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10309 if ( !s0.match( query_nodes ) ) {
10313 query_nodes = new HashSet<PhylogenyNode>();
10314 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10315 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10316 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10317 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10318 if ( !s0.match( query_nodes ) ) {
10322 query_nodes = new HashSet<PhylogenyNode>();
10323 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10324 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10325 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10326 if ( !s0.match( query_nodes ) ) {
10330 query_nodes = new HashSet<PhylogenyNode>();
10331 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10332 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10333 if ( !s0.match( query_nodes ) ) {
10337 query_nodes = new HashSet<PhylogenyNode>();
10338 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10339 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10340 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10341 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10342 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10343 if ( !s0.match( query_nodes ) ) {
10347 query_nodes = new HashSet<PhylogenyNode>();
10348 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10349 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10350 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10351 if ( !s0.match( query_nodes ) ) {
10355 query_nodes = new HashSet<PhylogenyNode>();
10356 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10357 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10358 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10359 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10360 if ( !s0.match( query_nodes ) ) {
10364 query_nodes = new HashSet<PhylogenyNode>();
10365 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10366 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10367 if ( s0.match( query_nodes ) ) {
10371 query_nodes = new HashSet<PhylogenyNode>();
10372 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10373 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10374 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10375 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10376 if ( s0.match( query_nodes ) ) {
10380 query_nodes = new HashSet<PhylogenyNode>();
10381 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10382 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10383 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10384 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10385 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10386 if ( s0.match( query_nodes ) ) {
10390 query_nodes = new HashSet<PhylogenyNode>();
10391 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10392 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10393 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10394 if ( s0.match( query_nodes ) ) {
10398 query_nodes = new HashSet<PhylogenyNode>();
10399 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10401 if ( s0.match( query_nodes ) ) {
10405 query_nodes = new HashSet<PhylogenyNode>();
10406 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10407 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10408 if ( s0.match( query_nodes ) ) {
10412 query_nodes = new HashSet<PhylogenyNode>();
10413 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10414 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10415 if ( s0.match( query_nodes ) ) {
10419 query_nodes = new HashSet<PhylogenyNode>();
10420 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10421 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10422 if ( s0.match( query_nodes ) ) {
10426 query_nodes = new HashSet<PhylogenyNode>();
10427 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10428 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10429 if ( s0.match( query_nodes ) ) {
10433 query_nodes = new HashSet<PhylogenyNode>();
10434 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10435 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10436 if ( s0.match( query_nodes ) ) {
10440 query_nodes = new HashSet<PhylogenyNode>();
10441 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10442 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10443 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10444 if ( s0.match( query_nodes ) ) {
10448 query_nodes = new HashSet<PhylogenyNode>();
10449 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10450 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10451 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10452 if ( s0.match( query_nodes ) ) {
10456 query_nodes = new HashSet<PhylogenyNode>();
10457 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10458 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10459 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10460 if ( s0.match( query_nodes ) ) {
10464 query_nodes = new HashSet<PhylogenyNode>();
10465 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10466 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10467 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10468 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10469 if ( s0.match( query_nodes ) ) {
10473 catch ( final Exception e ) {
10474 e.printStackTrace();
10480 private static boolean testSubtreeDeletion() {
10482 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10483 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10484 t1.deleteSubtree( t1.getNode( "A" ), false );
10485 if ( t1.getNumberOfExternalNodes() != 5 ) {
10488 t1.toNewHampshireX();
10489 t1.deleteSubtree( t1.getNode( "E" ), false );
10490 if ( t1.getNumberOfExternalNodes() != 4 ) {
10493 t1.toNewHampshireX();
10494 t1.deleteSubtree( t1.getNode( "F" ), false );
10495 if ( t1.getNumberOfExternalNodes() != 3 ) {
10498 t1.toNewHampshireX();
10499 t1.deleteSubtree( t1.getNode( "D" ), false );
10500 t1.toNewHampshireX();
10501 if ( t1.getNumberOfExternalNodes() != 3 ) {
10504 t1.deleteSubtree( t1.getNode( "def" ), false );
10505 t1.toNewHampshireX();
10506 if ( t1.getNumberOfExternalNodes() != 2 ) {
10509 t1.deleteSubtree( t1.getNode( "B" ), false );
10510 t1.toNewHampshireX();
10511 if ( t1.getNumberOfExternalNodes() != 1 ) {
10514 t1.deleteSubtree( t1.getNode( "C" ), false );
10515 t1.toNewHampshireX();
10516 if ( t1.getNumberOfExternalNodes() != 1 ) {
10519 t1.deleteSubtree( t1.getNode( "abc" ), false );
10520 t1.toNewHampshireX();
10521 if ( t1.getNumberOfExternalNodes() != 1 ) {
10524 t1.deleteSubtree( t1.getNode( "r" ), false );
10525 if ( t1.getNumberOfExternalNodes() != 0 ) {
10528 if ( !t1.isEmpty() ) {
10531 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10532 t2.deleteSubtree( t2.getNode( "A" ), false );
10533 t2.toNewHampshireX();
10534 if ( t2.getNumberOfExternalNodes() != 5 ) {
10537 t2.deleteSubtree( t2.getNode( "abc" ), false );
10538 t2.toNewHampshireX();
10539 if ( t2.getNumberOfExternalNodes() != 3 ) {
10542 t2.deleteSubtree( t2.getNode( "def" ), false );
10543 t2.toNewHampshireX();
10544 if ( t2.getNumberOfExternalNodes() != 1 ) {
10548 catch ( final Exception e ) {
10549 e.printStackTrace( System.out );
10555 private static boolean testSupportCount() {
10557 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10558 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
10559 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
10560 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
10561 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
10562 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
10563 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
10565 SupportCount.count( t0_1, phylogenies_1, true, false );
10566 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
10567 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
10568 + "(((((A,B),C),D),E),((F,G),X))"
10569 + "(((((A,Y),B),C),D),((F,G),E))"
10570 + "(((((A,B),C),D),E),(F,G))"
10571 + "(((((A,B),C),D),E),(F,G))"
10572 + "(((((A,B),C),D),E),(F,G))"
10573 + "(((((A,B),C),D),E),(F,G),Z)"
10574 + "(((((A,B),C),D),E),(F,G))"
10575 + "((((((A,B),C),D),E),F),G)"
10576 + "(((((X,Y),F,G),E),((A,B),C)),D)",
10578 SupportCount.count( t0_2, phylogenies_2, true, false );
10579 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
10580 while ( it.hasNext() ) {
10581 final PhylogenyNode n = it.next();
10582 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
10586 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
10587 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
10588 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
10589 SupportCount.count( t0_3, phylogenies_3, true, false );
10590 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
10591 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
10594 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
10597 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
10600 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
10603 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
10606 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
10609 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
10612 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
10615 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
10618 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
10621 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10622 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
10623 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
10624 SupportCount.count( t0_4, phylogenies_4, true, false );
10625 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
10626 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
10629 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
10632 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
10635 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
10638 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
10641 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
10644 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
10647 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
10650 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
10653 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
10656 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10657 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10658 double d = SupportCount.compare( b1, a, true, true, true );
10659 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
10662 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10663 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10664 d = SupportCount.compare( b2, a, true, true, true );
10665 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
10668 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10669 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
10670 d = SupportCount.compare( b3, a, true, true, true );
10671 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
10674 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
10675 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
10676 d = SupportCount.compare( b4, a, true, true, false );
10677 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
10681 catch ( final Exception e ) {
10682 e.printStackTrace( System.out );
10688 private static boolean testSupportTransfer() {
10690 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10691 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)",
10692 new NHXParser() )[ 0 ];
10693 final Phylogeny p2 = factory
10694 .create( "(((A:0.1,B:0.3)ab:0.4,C)abc:0.5,((D,E)de,(F,G)fg,(H,I)hi:0.59)defghi)", new NHXParser() )[ 0 ];
10695 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
10698 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
10701 support_transfer.moveBranchLengthsToBootstrap( p1 );
10702 support_transfer.transferSupportValues( p1, p2 );
10703 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
10706 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
10709 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
10712 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
10715 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
10718 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
10721 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
10724 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
10728 catch ( final Exception e ) {
10729 e.printStackTrace( System.out );
10735 private static boolean testTaxonomyExtraction() {
10737 final PhylogenyNode n0 = PhylogenyNode
10738 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10739 if ( n0.getNodeData().isHasTaxonomy() ) {
10742 final PhylogenyNode n1 = PhylogenyNode
10743 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10744 if ( n1.getNodeData().isHasTaxonomy() ) {
10745 System.out.println( n1.toString() );
10748 final PhylogenyNode n2x = PhylogenyNode
10749 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10750 if ( n2x.getNodeData().isHasTaxonomy() ) {
10753 final PhylogenyNode n3 = PhylogenyNode
10754 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10755 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10756 System.out.println( n3.toString() );
10759 final PhylogenyNode n4 = PhylogenyNode
10760 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10761 if ( n4.getNodeData().isHasTaxonomy() ) {
10762 System.out.println( n4.toString() );
10765 final PhylogenyNode n5 = PhylogenyNode
10766 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10767 if ( n5.getNodeData().isHasTaxonomy() ) {
10768 System.out.println( n5.toString() );
10771 final PhylogenyNode n6 = PhylogenyNode
10772 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10773 if ( n6.getNodeData().isHasTaxonomy() ) {
10774 System.out.println( n6.toString() );
10777 final PhylogenyNode n7 = PhylogenyNode
10778 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10779 if ( n7.getNodeData().isHasTaxonomy() ) {
10780 System.out.println( n7.toString() );
10783 final PhylogenyNode n8 = PhylogenyNode
10784 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10785 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10786 System.out.println( n8.toString() );
10789 final PhylogenyNode n9 = PhylogenyNode
10790 .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10791 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10792 System.out.println( n9.toString() );
10795 final PhylogenyNode n10x = PhylogenyNode
10796 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10797 if ( n10x.getNodeData().isHasTaxonomy() ) {
10798 System.out.println( n10x.toString() );
10801 final PhylogenyNode n10xx = PhylogenyNode
10802 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10803 if ( n10xx.getNodeData().isHasTaxonomy() ) {
10804 System.out.println( n10xx.toString() );
10807 final PhylogenyNode n10 = PhylogenyNode
10808 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10809 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
10810 System.out.println( n10.toString() );
10813 final PhylogenyNode n11 = PhylogenyNode
10814 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10815 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
10816 System.out.println( n11.toString() );
10819 final PhylogenyNode n12 = PhylogenyNode
10820 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
10821 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10822 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
10823 System.out.println( n12.toString() );
10826 final PhylogenyNode n13 = PhylogenyNode
10827 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10828 if ( n13.getNodeData().isHasTaxonomy() ) {
10829 System.out.println( n13.toString() );
10833 catch ( final Exception e ) {
10834 e.printStackTrace( System.out );
10840 private static boolean testTreeMethods() {
10842 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10843 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
10844 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
10845 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
10846 System.out.println( t0.toNewHampshireX() );
10849 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
10850 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
10851 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
10854 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
10857 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
10861 catch ( final Exception e ) {
10862 e.printStackTrace( System.out );
10868 private static boolean testSequenceDbWsTools1() {
10870 final PhylogenyNode n = new PhylogenyNode();
10871 n.setName( "NP_001025424" );
10872 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10873 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10874 || !acc.getValue().equals( "NP_001025424" ) ) {
10877 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10878 acc = SequenceDbWsTools.obtainSeqAccession( n );
10879 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10880 || !acc.getValue().equals( "NP_001025424" ) ) {
10883 n.setName( "NP_001025424.1" );
10884 acc = SequenceDbWsTools.obtainSeqAccession( n );
10885 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10886 || !acc.getValue().equals( "NP_001025424" ) ) {
10889 n.setName( "NM_001030253" );
10890 acc = SequenceDbWsTools.obtainSeqAccession( n );
10891 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10892 || !acc.getValue().equals( "NM_001030253" ) ) {
10895 n.setName( "BCL2_HUMAN" );
10896 acc = SequenceDbWsTools.obtainSeqAccession( n );
10897 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10898 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10899 System.out.println( acc.toString() );
10902 n.setName( "P10415" );
10903 acc = SequenceDbWsTools.obtainSeqAccession( n );
10904 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10905 || !acc.getValue().equals( "P10415" ) ) {
10906 System.out.println( acc.toString() );
10909 n.setName( " P10415 " );
10910 acc = SequenceDbWsTools.obtainSeqAccession( n );
10911 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10912 || !acc.getValue().equals( "P10415" ) ) {
10913 System.out.println( acc.toString() );
10916 n.setName( "_P10415|" );
10917 acc = SequenceDbWsTools.obtainSeqAccession( n );
10918 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10919 || !acc.getValue().equals( "P10415" ) ) {
10920 System.out.println( acc.toString() );
10923 n.setName( "AY695820" );
10924 acc = SequenceDbWsTools.obtainSeqAccession( n );
10925 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10926 || !acc.getValue().equals( "AY695820" ) ) {
10927 System.out.println( acc.toString() );
10930 n.setName( "_AY695820_" );
10931 acc = SequenceDbWsTools.obtainSeqAccession( n );
10932 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10933 || !acc.getValue().equals( "AY695820" ) ) {
10934 System.out.println( acc.toString() );
10937 n.setName( "AAA59452" );
10938 acc = SequenceDbWsTools.obtainSeqAccession( n );
10939 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10940 || !acc.getValue().equals( "AAA59452" ) ) {
10941 System.out.println( acc.toString() );
10944 n.setName( "_AAA59452_" );
10945 acc = SequenceDbWsTools.obtainSeqAccession( n );
10946 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10947 || !acc.getValue().equals( "AAA59452" ) ) {
10948 System.out.println( acc.toString() );
10951 n.setName( "AAA59452.1" );
10952 acc = SequenceDbWsTools.obtainSeqAccession( n );
10953 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10954 || !acc.getValue().equals( "AAA59452.1" ) ) {
10955 System.out.println( acc.toString() );
10958 n.setName( "_AAA59452.1_" );
10959 acc = SequenceDbWsTools.obtainSeqAccession( n );
10960 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10961 || !acc.getValue().equals( "AAA59452.1" ) ) {
10962 System.out.println( acc.toString() );
10965 n.setName( "GI:94894583" );
10966 acc = SequenceDbWsTools.obtainSeqAccession( n );
10967 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10968 || !acc.getValue().equals( "94894583" ) ) {
10969 System.out.println( acc.toString() );
10973 catch ( final Exception e ) {
10979 private static boolean testSequenceDbWsTools2() {
10981 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
10982 SequenceDbWsTools.obtainSeqInformation( n1 );
10983 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
10986 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10989 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10992 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
10995 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
10996 SequenceDbWsTools.obtainSeqInformation( n2 );
10997 System.out.println( n2.toString() );
10998 if ( !n2.getNodeData().getSequence().getName()
10999 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
11002 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11005 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11008 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11011 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11012 SequenceDbWsTools.obtainSeqInformation( n3 );
11013 System.out.println( "n=" + n3.toString() );
11014 if ( !n3.getNodeData().getSequence().getName()
11015 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11018 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11021 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11024 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11028 catch ( final IOException e ) {
11029 System.out.println();
11030 System.out.println( "the following might be due to absence internet connection:" );
11031 e.printStackTrace( System.out );
11034 catch ( final Exception e ) {
11035 e.printStackTrace();
11041 private static boolean testUniprotEntryRetrieval() {
11043 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
11044 if ( !entry.getAccession().equals( "P12345" ) ) {
11047 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
11050 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
11053 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
11056 if ( !entry.getGeneName().equals( "GOT2" ) ) {
11059 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
11063 catch ( final IOException e ) {
11064 System.out.println();
11065 System.out.println( "the following might be due to absence internet connection:" );
11066 e.printStackTrace( System.out );
11069 catch ( final Exception e ) {
11075 private static boolean testUniprotTaxonomySearch() {
11077 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
11079 if ( results.size() != 1 ) {
11082 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11085 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11088 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11091 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11094 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11098 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
11099 if ( results.size() != 1 ) {
11102 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11105 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11108 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11111 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11114 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11118 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
11119 if ( results.size() != 1 ) {
11122 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11125 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11128 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11131 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11134 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11138 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
11139 if ( results.size() != 1 ) {
11142 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11145 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11148 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11151 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11154 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11157 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
11160 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
11163 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11164 .equals( "Nematostella vectensis" ) ) {
11165 System.out.println( results.get( 0 ).getLineage() );
11170 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
11171 if ( results.size() != 1 ) {
11174 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11177 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11180 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11183 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11186 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11189 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11190 .equals( "Xenopus tropicalis" ) ) {
11191 System.out.println( results.get( 0 ).getLineage() );
11196 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
11197 if ( results.size() != 1 ) {
11200 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11203 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11206 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11209 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11212 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11215 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11216 .equals( "Xenopus tropicalis" ) ) {
11217 System.out.println( results.get( 0 ).getLineage() );
11222 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
11223 if ( results.size() != 1 ) {
11226 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11229 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11232 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11235 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11238 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11241 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11242 .equals( "Xenopus tropicalis" ) ) {
11243 System.out.println( results.get( 0 ).getLineage() );
11247 catch ( final IOException e ) {
11248 System.out.println();
11249 System.out.println( "the following might be due to absence internet connection:" );
11250 e.printStackTrace( System.out );
11253 catch ( final Exception e ) {
11259 private static boolean testWabiTxSearch() {
11261 String result = "";
11262 result = TxSearch.searchSimple( "nematostella" );
11263 result = TxSearch.getTxId( "nematostella" );
11264 if ( !result.equals( "45350" ) ) {
11267 result = TxSearch.getTxName( "45350" );
11268 if ( !result.equals( "Nematostella" ) ) {
11271 result = TxSearch.getTxId( "nematostella vectensis" );
11272 if ( !result.equals( "45351" ) ) {
11275 result = TxSearch.getTxName( "45351" );
11276 if ( !result.equals( "Nematostella vectensis" ) ) {
11279 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
11280 if ( !result.equals( "536089" ) ) {
11283 result = TxSearch.getTxName( "536089" );
11284 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
11287 final List<String> queries = new ArrayList<String>();
11288 queries.add( "Campylobacter coli" );
11289 queries.add( "Escherichia coli" );
11290 queries.add( "Arabidopsis" );
11291 queries.add( "Trichoplax" );
11292 queries.add( "Samanea saman" );
11293 queries.add( "Kluyveromyces marxianus" );
11294 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
11295 queries.add( "Bornavirus parrot/PDD/2008" );
11296 final List<RANKS> ranks = new ArrayList<RANKS>();
11297 ranks.add( RANKS.SUPERKINGDOM );
11298 ranks.add( RANKS.KINGDOM );
11299 ranks.add( RANKS.FAMILY );
11300 ranks.add( RANKS.GENUS );
11301 ranks.add( RANKS.TRIBE );
11302 result = TxSearch.searchLineage( queries, ranks );
11303 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
11304 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
11306 catch ( final Exception e ) {
11307 System.out.println();
11308 System.out.println( "the following might be due to absence internet connection:" );
11309 e.printStackTrace( System.out );