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;
40 import org.forester.application.support_transfer;
41 import org.forester.archaeopteryx.AptxUtil;
42 import org.forester.development.DevelopmentTools;
43 import org.forester.evoinference.TestPhylogenyReconstruction;
44 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
45 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
46 import org.forester.go.TestGo;
47 import org.forester.io.parsers.FastaParser;
48 import org.forester.io.parsers.GeneralMsaParser;
49 import org.forester.io.parsers.HmmscanPerDomainTableParser;
50 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
51 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
52 import org.forester.io.parsers.nexus.NexusCharactersParser;
53 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
54 import org.forester.io.parsers.nhx.NHXParser;
55 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
56 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
57 import org.forester.io.parsers.tol.TolParser;
58 import org.forester.io.parsers.util.ParserUtils;
59 import org.forester.io.writers.PhylogenyWriter;
60 import org.forester.io.writers.SequenceWriter;
61 import org.forester.msa.BasicMsa;
62 import org.forester.msa.Mafft;
63 import org.forester.msa.Msa;
64 import org.forester.msa.MsaInferrer;
65 import org.forester.msa.MsaMethods;
66 import org.forester.pccx.TestPccx;
67 import org.forester.phylogeny.Phylogeny;
68 import org.forester.phylogeny.PhylogenyBranch;
69 import org.forester.phylogeny.PhylogenyMethods;
70 import org.forester.phylogeny.PhylogenyNode;
71 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
72 import org.forester.phylogeny.data.Accession;
73 import org.forester.phylogeny.data.BinaryCharacters;
74 import org.forester.phylogeny.data.BranchWidth;
75 import org.forester.phylogeny.data.Confidence;
76 import org.forester.phylogeny.data.Distribution;
77 import org.forester.phylogeny.data.DomainArchitecture;
78 import org.forester.phylogeny.data.Event;
79 import org.forester.phylogeny.data.Identifier;
80 import org.forester.phylogeny.data.PhylogenyData;
81 import org.forester.phylogeny.data.PhylogenyDataUtil;
82 import org.forester.phylogeny.data.Polygon;
83 import org.forester.phylogeny.data.PropertiesMap;
84 import org.forester.phylogeny.data.Property;
85 import org.forester.phylogeny.data.Property.AppliesTo;
86 import org.forester.phylogeny.data.ProteinDomain;
87 import org.forester.phylogeny.data.Taxonomy;
88 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
89 import org.forester.phylogeny.factories.PhylogenyFactory;
90 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
91 import org.forester.protein.Protein;
92 import org.forester.rio.TestRIO;
93 import org.forester.sdi.SDI;
94 import org.forester.sdi.SDIR;
95 import org.forester.sdi.TestGSDI;
96 import org.forester.sequence.BasicSequence;
97 import org.forester.sequence.Sequence;
98 import org.forester.surfacing.TestSurfacing;
99 import org.forester.tools.ConfidenceAssessor;
100 import org.forester.tools.SupportCount;
101 import org.forester.tools.TreeSplitMatrix;
102 import org.forester.util.AsciiHistogram;
103 import org.forester.util.BasicDescriptiveStatistics;
104 import org.forester.util.BasicTable;
105 import org.forester.util.BasicTableParser;
106 import org.forester.util.DescriptiveStatistics;
107 import org.forester.util.ForesterConstants;
108 import org.forester.util.ForesterUtil;
109 import org.forester.util.GeneralTable;
110 import org.forester.util.SequenceIdParser;
111 import org.forester.ws.seqdb.SequenceDatabaseEntry;
112 import org.forester.ws.seqdb.SequenceDbWsTools;
113 import org.forester.ws.seqdb.UniProtTaxonomy;
114 import org.forester.ws.wabi.TxSearch;
115 import org.forester.ws.wabi.TxSearch.RANKS;
116 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
117 import org.forester.ws.wabi.TxSearch.TAX_RANK;
119 @SuppressWarnings( "unused")
120 public final class Test {
122 private final static double ZERO_DIFF = 1.0E-9;
123 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
124 + ForesterUtil.getFileSeparator() + "test_data"
125 + ForesterUtil.getFileSeparator();
126 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
127 + ForesterUtil.getFileSeparator() + "resources"
128 + ForesterUtil.getFileSeparator();
129 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
130 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
131 + ForesterConstants.PHYLO_XML_VERSION + "/"
132 + ForesterConstants.PHYLO_XML_XSD;
133 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
134 + ForesterConstants.PHYLO_XML_VERSION + "/"
135 + ForesterConstants.PHYLO_XML_XSD;
137 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
138 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
142 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
143 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
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( "Sequence writer: " );
178 if ( testSequenceWriter() ) {
179 System.out.println( "OK." );
183 System.out.println( "failed." );
186 System.out.print( "Sequence id parsing: " );
187 if ( testSequenceIdParsing() ) {
188 System.out.println( "OK." );
192 System.out.println( "failed." );
195 System.out.print( "Hmmscan output parser: " );
196 if ( testHmmscanOutputParser() ) {
197 System.out.println( "OK." );
201 System.out.println( "failed." );
204 System.out.print( "Basic node methods: " );
205 if ( Test.testBasicNodeMethods() ) {
206 System.out.println( "OK." );
210 System.out.println( "failed." );
213 System.out.print( "Taxonomy code extraction: " );
214 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
215 System.out.println( "OK." );
219 System.out.println( "failed." );
222 System.out.print( "Taxonomy extraction (general): " );
223 if ( Test.testTaxonomyExtraction() ) {
224 System.out.println( "OK." );
228 System.out.println( "failed." );
231 System.out.print( "UniProtKB id extraction: " );
232 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
233 System.out.println( "OK." );
237 System.out.println( "failed." );
240 System.out.print( "Uri for Aptx web sequence accession: " );
241 if ( Test.testCreateUriForSeqWeb() ) {
242 System.out.println( "OK." );
246 System.out.println( "failed." );
249 System.out.print( "Basic node construction and parsing of NHX (node level): " );
250 if ( Test.testNHXNodeParsing() ) {
251 System.out.println( "OK." );
255 System.out.println( "failed." );
258 System.out.print( "NHX parsing iterating: " );
259 if ( Test.testNHParsingIter() ) {
260 System.out.println( "OK." );
264 System.out.println( "failed." );
267 System.out.print( "NH parsing: " );
268 if ( Test.testNHParsing() ) {
269 System.out.println( "OK." );
273 System.out.println( "failed." );
276 System.out.print( "Conversion to NHX (node level): " );
277 if ( Test.testNHXconversion() ) {
278 System.out.println( "OK." );
282 System.out.println( "failed." );
285 System.out.print( "NHX parsing: " );
286 if ( Test.testNHXParsing() ) {
287 System.out.println( "OK." );
291 System.out.println( "failed." );
294 System.out.print( "NHX parsing with quotes: " );
295 if ( Test.testNHXParsingQuotes() ) {
296 System.out.println( "OK." );
300 System.out.println( "failed." );
303 System.out.print( "NHX parsing (MrBayes): " );
304 if ( Test.testNHXParsingMB() ) {
305 System.out.println( "OK." );
309 System.out.println( "failed." );
312 System.out.print( "Nexus characters parsing: " );
313 if ( Test.testNexusCharactersParsing() ) {
314 System.out.println( "OK." );
318 System.out.println( "failed." );
321 System.out.print( "Nexus tree parsing iterating: " );
322 if ( Test.testNexusTreeParsingIterating() ) {
323 System.out.println( "OK." );
327 System.out.println( "failed." );
330 System.out.print( "Nexus tree parsing: " );
331 if ( Test.testNexusTreeParsing() ) {
332 System.out.println( "OK." );
336 System.out.println( "failed." );
339 System.out.print( "Nexus tree parsing (translating): " );
340 if ( Test.testNexusTreeParsingTranslating() ) {
341 System.out.println( "OK." );
345 System.out.println( "failed." );
348 System.out.print( "Nexus matrix parsing: " );
349 if ( Test.testNexusMatrixParsing() ) {
350 System.out.println( "OK." );
354 System.out.println( "failed." );
357 System.out.print( "Basic phyloXML parsing: " );
358 if ( Test.testBasicPhyloXMLparsing() ) {
359 System.out.println( "OK." );
363 System.out.println( "failed." );
366 System.out.print( "Basic phyloXML parsing (validating against schema): " );
367 if ( testBasicPhyloXMLparsingValidating() ) {
368 System.out.println( "OK." );
372 System.out.println( "failed." );
375 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
376 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
377 System.out.println( "OK." );
381 System.out.println( "failed." );
384 System.out.print( "phyloXML Distribution Element: " );
385 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
386 System.out.println( "OK." );
390 System.out.println( "failed." );
393 System.out.print( "Tol XML parsing: " );
394 if ( Test.testBasicTolXMLparsing() ) {
395 System.out.println( "OK." );
399 System.out.println( "failed." );
402 System.out.print( "Copying of node data: " );
403 if ( Test.testCopyOfNodeData() ) {
404 System.out.println( "OK." );
408 System.out.println( "failed." );
411 System.out.print( "Basic tree methods: " );
412 if ( Test.testBasicTreeMethods() ) {
413 System.out.println( "OK." );
417 System.out.println( "failed." );
420 System.out.print( "Tree methods: " );
421 if ( Test.testTreeMethods() ) {
422 System.out.println( "OK." );
426 System.out.println( "failed." );
429 System.out.print( "Postorder Iterator: " );
430 if ( Test.testPostOrderIterator() ) {
431 System.out.println( "OK." );
435 System.out.println( "failed." );
438 System.out.print( "Preorder Iterator: " );
439 if ( Test.testPreOrderIterator() ) {
440 System.out.println( "OK." );
444 System.out.println( "failed." );
447 System.out.print( "Levelorder Iterator: " );
448 if ( Test.testLevelOrderIterator() ) {
449 System.out.println( "OK." );
453 System.out.println( "failed." );
456 System.out.print( "Re-id methods: " );
457 if ( Test.testReIdMethods() ) {
458 System.out.println( "OK." );
462 System.out.println( "failed." );
465 System.out.print( "Methods on last external nodes: " );
466 if ( Test.testLastExternalNodeMethods() ) {
467 System.out.println( "OK." );
471 System.out.println( "failed." );
474 System.out.print( "Methods on external nodes: " );
475 if ( Test.testExternalNodeRelatedMethods() ) {
476 System.out.println( "OK." );
480 System.out.println( "failed." );
483 System.out.print( "Deletion of external nodes: " );
484 if ( Test.testDeletionOfExternalNodes() ) {
485 System.out.println( "OK." );
489 System.out.println( "failed." );
492 System.out.print( "Subtree deletion: " );
493 if ( Test.testSubtreeDeletion() ) {
494 System.out.println( "OK." );
498 System.out.println( "failed." );
501 System.out.print( "Phylogeny branch: " );
502 if ( Test.testPhylogenyBranch() ) {
503 System.out.println( "OK." );
507 System.out.println( "failed." );
510 System.out.print( "Rerooting: " );
511 if ( Test.testRerooting() ) {
512 System.out.println( "OK." );
516 System.out.println( "failed." );
519 System.out.print( "Mipoint rooting: " );
520 if ( Test.testMidpointrooting() ) {
521 System.out.println( "OK." );
525 System.out.println( "failed." );
528 System.out.print( "Node removal: " );
529 if ( Test.testNodeRemoval() ) {
530 System.out.println( "OK." );
534 System.out.println( "failed." );
537 System.out.print( "Support count: " );
538 if ( Test.testSupportCount() ) {
539 System.out.println( "OK." );
543 System.out.println( "failed." );
546 System.out.print( "Support transfer: " );
547 if ( Test.testSupportTransfer() ) {
548 System.out.println( "OK." );
552 System.out.println( "failed." );
555 System.out.print( "Finding of LCA: " );
556 if ( Test.testGetLCA() ) {
557 System.out.println( "OK." );
561 System.out.println( "failed." );
564 System.out.print( "Finding of LCA 2: " );
565 if ( Test.testGetLCA2() ) {
566 System.out.println( "OK." );
570 System.out.println( "failed." );
573 System.out.print( "Calculation of distance between nodes: " );
574 if ( Test.testGetDistance() ) {
575 System.out.println( "OK." );
579 System.out.println( "failed." );
582 System.out.print( "Descriptive statistics: " );
583 if ( Test.testDescriptiveStatistics() ) {
584 System.out.println( "OK." );
588 System.out.println( "failed." );
591 System.out.print( "Data objects and methods: " );
592 if ( Test.testDataObjects() ) {
593 System.out.println( "OK." );
597 System.out.println( "failed." );
600 System.out.print( "Properties map: " );
601 if ( Test.testPropertiesMap() ) {
602 System.out.println( "OK." );
606 System.out.println( "failed." );
609 System.out.print( "SDIse: " );
610 if ( Test.testSDIse() ) {
611 System.out.println( "OK." );
615 System.out.println( "failed." );
618 System.out.print( "SDIunrooted: " );
619 if ( Test.testSDIunrooted() ) {
620 System.out.println( "OK." );
624 System.out.println( "failed." );
627 System.out.print( "GSDI: " );
628 if ( TestGSDI.test() ) {
629 System.out.println( "OK." );
633 System.out.println( "failed." );
636 System.out.print( "RIO: " );
637 if ( TestRIO.test() ) {
638 System.out.println( "OK." );
642 System.out.println( "failed." );
645 System.out.print( "Phylogeny reconstruction:" );
646 System.out.println();
647 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
648 System.out.println( "OK." );
652 System.out.println( "failed." );
655 System.out.print( "Analysis of domain architectures: " );
656 System.out.println();
657 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
658 System.out.println( "OK." );
662 System.out.println( "failed." );
665 System.out.print( "GO: " );
666 System.out.println();
667 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
668 System.out.println( "OK." );
672 System.out.println( "failed." );
675 System.out.print( "Modeling tools: " );
676 if ( TestPccx.test() ) {
677 System.out.println( "OK." );
681 System.out.println( "failed." );
684 System.out.print( "Split Matrix strict: " );
685 if ( Test.testSplitStrict() ) {
686 System.out.println( "OK." );
690 System.out.println( "failed." );
693 System.out.print( "Split Matrix: " );
694 if ( Test.testSplit() ) {
695 System.out.println( "OK." );
699 System.out.println( "failed." );
702 System.out.print( "Confidence Assessor: " );
703 if ( Test.testConfidenceAssessor() ) {
704 System.out.println( "OK." );
708 System.out.println( "failed." );
711 System.out.print( "Basic table: " );
712 if ( Test.testBasicTable() ) {
713 System.out.println( "OK." );
717 System.out.println( "failed." );
720 System.out.print( "General table: " );
721 if ( Test.testGeneralTable() ) {
722 System.out.println( "OK." );
726 System.out.println( "failed." );
729 System.out.print( "Amino acid sequence: " );
730 if ( Test.testAminoAcidSequence() ) {
731 System.out.println( "OK." );
735 System.out.println( "failed." );
738 System.out.print( "General MSA parser: " );
739 if ( Test.testGeneralMsaParser() ) {
740 System.out.println( "OK." );
744 System.out.println( "failed." );
747 System.out.print( "Fasta parser for msa: " );
748 if ( Test.testFastaParser() ) {
749 System.out.println( "OK." );
753 System.out.println( "failed." );
756 System.out.print( "Creation of balanced phylogeny: " );
757 if ( Test.testCreateBalancedPhylogeny() ) {
758 System.out.println( "OK." );
762 System.out.println( "failed." );
765 System.out.print( "EMBL Entry Retrieval: " );
766 if ( Test.testEmblEntryRetrieval() ) {
767 System.out.println( "OK." );
771 System.out.println( "failed." );
774 System.out.print( "Uniprot Entry Retrieval: " );
775 if ( Test.testUniprotEntryRetrieval() ) {
776 System.out.println( "OK." );
780 System.out.println( "failed." );
783 System.out.print( "Uniprot Taxonomy Search: " );
784 if ( Test.testUniprotTaxonomySearch() ) {
785 System.out.println( "OK." );
789 System.out.println( "failed." );
794 final String os = ForesterUtil.OS_NAME.toLowerCase();
795 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
796 path = "/usr/local/bin/mafft";
798 else if ( os.indexOf( "win" ) >= 0 ) {
799 path = "C:\\Program Files\\mafft-win\\mafft.bat";
802 path = "/home/czmasek/bin/mafft";
804 if ( !MsaInferrer.isInstalled( path ) ) {
807 if ( !MsaInferrer.isInstalled( path ) ) {
808 path = "/usr/local/bin/mafft";
810 if ( MsaInferrer.isInstalled( path ) ) {
811 System.out.print( "MAFFT (external program): " );
812 if ( Test.testMafft( path ) ) {
813 System.out.println( "OK." );
817 System.out.println( "failed [will not count towards failed tests]" );
821 System.out.print( "Next nodes with collapsed: " );
822 if ( Test.testNextNodeWithCollapsing() ) {
823 System.out.println( "OK." );
827 System.out.println( "failed." );
830 System.out.print( "Simple MSA quality: " );
831 if ( Test.testMsaQualityMethod() ) {
832 System.out.println( "OK." );
836 System.out.println( "failed." );
839 System.out.println();
840 final Runtime rt = java.lang.Runtime.getRuntime();
841 final long free_memory = rt.freeMemory() / 1000000;
842 final long total_memory = rt.totalMemory() / 1000000;
843 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
844 + free_memory + "MB, total memory: " + total_memory + "MB)" );
845 System.out.println();
846 System.out.println( "Successful tests: " + succeeded );
847 System.out.println( "Failed tests: " + failed );
848 System.out.println();
850 System.out.println( "OK." );
853 System.out.println( "Not OK." );
857 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
859 PhylogenyNode n = new PhylogenyNode();
860 n.setName( "tr|B3RJ64" );
861 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
864 n.setName( "tr.B3RJ64" );
865 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
868 n.setName( "tr=B3RJ64" );
869 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
872 n.setName( "tr-B3RJ64" );
873 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
876 n.setName( "tr/B3RJ64" );
877 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
880 n.setName( "tr\\B3RJ64" );
881 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
884 n.setName( "tr_B3RJ64" );
885 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
888 n.setName( " tr|B3RJ64 " );
889 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
892 n.setName( "-tr|B3RJ64-" );
893 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
896 n.setName( "-tr=B3RJ64-" );
897 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
900 n.setName( "_tr=B3RJ64_" );
901 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
904 n.setName( " tr_tr|B3RJ64_sp|123 " );
905 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
908 n.setName( "sp|B3RJ64" );
909 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
912 n.setName( "ssp|B3RJ64" );
913 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
916 n.setName( "sp|B3RJ64C" );
917 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
920 n.setName( "sp B3RJ64" );
921 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
924 n.setName( "sp|B3RJ6X" );
925 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
928 n.setName( "sp|B3RJ6" );
929 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
932 n.setName( "K1PYK7_CRAGI" );
933 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
936 n.setName( "K1PYK7_PEA" );
937 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PEA" ) ) {
940 n.setName( "K1PYK7_RAT" );
941 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_RAT" ) ) {
944 n.setName( "K1PYK7_PIG" );
945 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PIG" ) ) {
948 n.setName( "~K1PYK7_PIG~" );
949 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PIG" ) ) {
952 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
953 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
956 n.setName( "K1PYKX_CRAGI" );
957 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
960 n.setName( "XXXXX_CRAGI" );
961 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "XXXXX_CRAGI" ) ) {
964 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
965 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "H3IB65" ) ) {
968 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
969 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
972 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
973 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "Q86U06" ) ) {
976 n = new PhylogenyNode();
977 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
978 seq.setSymbol( "K1PYK7_CRAGI" );
979 n.getNodeData().addSequence( seq );
980 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
983 seq.setSymbol( "tr|B3RJ64" );
984 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
987 n = new PhylogenyNode();
988 seq = new org.forester.phylogeny.data.Sequence();
989 seq.setName( "K1PYK7_CRAGI" );
990 n.getNodeData().addSequence( seq );
991 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
994 seq.setName( "tr|B3RJ64" );
995 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
998 n = new PhylogenyNode();
999 seq = new org.forester.phylogeny.data.Sequence();
1000 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
1001 n.getNodeData().addSequence( seq );
1002 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK8_CRAGI" ) ) {
1005 n = new PhylogenyNode();
1006 seq = new org.forester.phylogeny.data.Sequence();
1007 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
1008 n.getNodeData().addSequence( seq );
1009 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
1013 n = new PhylogenyNode();
1014 n.setName( "ACP19736" );
1015 if ( !ForesterUtil.extractGenbankAccessor( n ).equals( "ACP19736" ) ) {
1018 n = new PhylogenyNode();
1019 n.setName( "_ACP19736_" );
1020 if ( !ForesterUtil.extractGenbankAccessor( n ).equals( "ACP19736" ) ) {
1024 catch ( final Exception e ) {
1025 e.printStackTrace( System.out );
1031 private static boolean testCreateUriForSeqWeb() {
1033 final PhylogenyNode n = new PhylogenyNode();
1034 n.setName( "tr|B3RJ64" );
1035 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
1038 n.setName( "B0LM41_HUMAN" );
1039 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
1042 n.setName( "NP_001025424" );
1043 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
1046 n.setName( "_NM_001030253-" );
1047 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
1050 n.setName( "XM_002122186" );
1051 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
1054 n.setName( "dgh_AAA34956_gdg" );
1055 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
1058 n.setName( "j40f4_Q06891.1_fndn2 fnr3" );
1059 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "Q06891.1" ) ) {
1062 n.setName( "GI:394892" );
1063 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
1064 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
1067 n.setName( "gi_394892" );
1068 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
1069 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
1072 n.setName( "gi6335_gi_394892_56635_Gi_43" );
1073 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
1074 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
1078 catch ( final Exception e ) {
1079 e.printStackTrace( System.out );
1085 private static boolean testExtractTaxonomyCodeFromNodeName() {
1087 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1088 .equals( "MOUSE" ) ) {
1091 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1092 .equals( "RAT" ) ) {
1095 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
1098 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
1099 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1100 .equals( "MOUSE" ) ) {
1103 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE_function = 23445",
1104 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1105 .equals( "MOUSE" ) ) {
1108 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
1109 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1110 .equals( "MOUSE" ) ) {
1113 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
1114 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
1117 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
1118 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
1121 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
1122 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
1125 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT_function = 23445",
1126 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
1129 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
1130 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
1133 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
1134 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
1137 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
1138 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
1141 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1142 .equals( "RAT" ) ) {
1145 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
1146 .equals( "PIG" ) ) {
1150 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1151 .equals( "MOUSE" ) ) {
1154 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
1155 .equals( "MOUSE" ) ) {
1158 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE_", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1159 .equals( "MOUSE" ) ) {
1162 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE_", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1163 .equals( "MOUSE" ) ) {
1166 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE_", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ) != null ) {
1169 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "x_MOUSE_x", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1170 .equals( "MOUSE" ) ) {
1174 catch ( final Exception e ) {
1175 e.printStackTrace( System.out );
1181 private static boolean testBasicNodeMethods() {
1183 if ( PhylogenyNode.getNodeCount() != 0 ) {
1186 final PhylogenyNode n1 = new PhylogenyNode();
1187 final PhylogenyNode n2 = PhylogenyNode
1188 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1189 final PhylogenyNode n3 = PhylogenyNode
1190 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1191 final PhylogenyNode n4 = PhylogenyNode
1192 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1193 if ( n1.isHasAssignedEvent() ) {
1196 if ( PhylogenyNode.getNodeCount() != 4 ) {
1199 if ( n3.getIndicator() != 0 ) {
1202 if ( n3.getNumberOfExternalNodes() != 1 ) {
1205 if ( !n3.isExternal() ) {
1208 if ( !n3.isRoot() ) {
1211 if ( !n4.getName().equals( "n4" ) ) {
1215 catch ( final Exception e ) {
1216 e.printStackTrace( System.out );
1222 private static boolean testBasicPhyloXMLparsing() {
1224 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1225 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1226 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1228 if ( xml_parser.getErrorCount() > 0 ) {
1229 System.out.println( xml_parser.getErrorMessages().toString() );
1232 if ( phylogenies_0.length != 4 ) {
1235 final Phylogeny t1 = phylogenies_0[ 0 ];
1236 final Phylogeny t2 = phylogenies_0[ 1 ];
1237 final Phylogeny t3 = phylogenies_0[ 2 ];
1238 final Phylogeny t4 = phylogenies_0[ 3 ];
1239 if ( t1.getNumberOfExternalNodes() != 1 ) {
1242 if ( !t1.isRooted() ) {
1245 if ( t1.isRerootable() ) {
1248 if ( !t1.getType().equals( "gene_tree" ) ) {
1251 if ( t2.getNumberOfExternalNodes() != 2 ) {
1254 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1257 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1260 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1263 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1266 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1269 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1272 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1273 .startsWith( "actgtgggggt" ) ) {
1276 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1277 .startsWith( "ctgtgatgcat" ) ) {
1280 if ( t3.getNumberOfExternalNodes() != 4 ) {
1283 if ( !t1.getName().equals( "t1" ) ) {
1286 if ( !t2.getName().equals( "t2" ) ) {
1289 if ( !t3.getName().equals( "t3" ) ) {
1292 if ( !t4.getName().equals( "t4" ) ) {
1295 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1298 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1301 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1304 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1305 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1308 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1311 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1314 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1317 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1318 .equals( "apoptosis" ) ) {
1321 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1322 .equals( "GO:0006915" ) ) {
1325 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1326 .equals( "UniProtKB" ) ) {
1329 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1330 .equals( "experimental" ) ) {
1333 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1334 .equals( "function" ) ) {
1337 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1338 .getValue() != 1 ) {
1341 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1342 .getType().equals( "ml" ) ) {
1345 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1346 .equals( "apoptosis" ) ) {
1349 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1350 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1353 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1354 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1357 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1358 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1361 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1362 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1365 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1366 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1369 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1370 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1373 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1374 .equals( "GO:0005829" ) ) {
1377 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1378 .equals( "intracellular organelle" ) ) {
1381 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1384 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1385 .equals( "UniProt link" ) ) ) {
1388 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1392 catch ( final Exception e ) {
1393 e.printStackTrace( System.out );
1399 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1401 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1402 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1403 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1404 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1407 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1409 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1411 if ( xml_parser.getErrorCount() > 0 ) {
1412 System.out.println( xml_parser.getErrorMessages().toString() );
1415 if ( phylogenies_0.length != 4 ) {
1418 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1419 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1420 if ( phylogenies_t1.length != 1 ) {
1423 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1424 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1427 if ( !t1_rt.isRooted() ) {
1430 if ( t1_rt.isRerootable() ) {
1433 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1436 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1437 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1438 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1439 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1442 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1445 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1448 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1451 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1452 .startsWith( "actgtgggggt" ) ) {
1455 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1456 .startsWith( "ctgtgatgcat" ) ) {
1459 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1460 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1461 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1462 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1463 if ( phylogenies_1.length != 1 ) {
1466 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1467 if ( !t3_rt.getName().equals( "t3" ) ) {
1470 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1473 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1476 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1479 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1482 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1483 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1486 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1489 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1492 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1493 .equals( "UniProtKB" ) ) {
1496 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1497 .equals( "apoptosis" ) ) {
1500 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1501 .equals( "GO:0006915" ) ) {
1504 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1505 .equals( "UniProtKB" ) ) {
1508 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1509 .equals( "experimental" ) ) {
1512 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1513 .equals( "function" ) ) {
1516 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1517 .getValue() != 1 ) {
1520 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1521 .getType().equals( "ml" ) ) {
1524 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1525 .equals( "apoptosis" ) ) {
1528 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1529 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1532 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1533 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1536 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1537 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1540 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1541 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1544 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1545 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1548 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1549 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1552 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1553 .equals( "GO:0005829" ) ) {
1556 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1557 .equals( "intracellular organelle" ) ) {
1560 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1563 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1564 .equals( "UniProt link" ) ) ) {
1567 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1570 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1573 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1574 .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." ) ) ) {
1577 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1580 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1583 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1586 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1589 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1590 .equals( "ncbi" ) ) {
1593 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1596 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1597 .getName().equals( "B" ) ) {
1600 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1601 .getFrom() != 21 ) {
1604 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1607 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1608 .getLength() != 24 ) {
1611 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1612 .getConfidence() != 2144 ) {
1615 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1616 .equals( "pfam" ) ) {
1619 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1622 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1625 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1628 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1631 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1632 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1635 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1638 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1641 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1644 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1647 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1650 if ( taxbb.getSynonyms().size() != 2 ) {
1653 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1656 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1659 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1662 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1665 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1668 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1669 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1673 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1676 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1679 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1682 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1685 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1688 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1691 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1695 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1698 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1699 .equalsIgnoreCase( "435" ) ) {
1702 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1705 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1706 .equalsIgnoreCase( "443.7" ) ) {
1709 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1712 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1715 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1716 .equalsIgnoreCase( "433" ) ) {
1720 catch ( final Exception e ) {
1721 e.printStackTrace( System.out );
1727 private static boolean testBasicPhyloXMLparsingValidating() {
1729 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1730 PhyloXmlParser xml_parser = null;
1732 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1734 catch ( final Exception e ) {
1735 // Do nothing -- means were not running from jar.
1737 if ( xml_parser == null ) {
1738 xml_parser = new PhyloXmlParser();
1739 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1740 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1743 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1746 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1748 if ( xml_parser.getErrorCount() > 0 ) {
1749 System.out.println( xml_parser.getErrorMessages().toString() );
1752 if ( phylogenies_0.length != 4 ) {
1755 final Phylogeny t1 = phylogenies_0[ 0 ];
1756 final Phylogeny t2 = phylogenies_0[ 1 ];
1757 final Phylogeny t3 = phylogenies_0[ 2 ];
1758 final Phylogeny t4 = phylogenies_0[ 3 ];
1759 if ( !t1.getName().equals( "t1" ) ) {
1762 if ( !t2.getName().equals( "t2" ) ) {
1765 if ( !t3.getName().equals( "t3" ) ) {
1768 if ( !t4.getName().equals( "t4" ) ) {
1771 if ( t1.getNumberOfExternalNodes() != 1 ) {
1774 if ( t2.getNumberOfExternalNodes() != 2 ) {
1777 if ( t3.getNumberOfExternalNodes() != 4 ) {
1780 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
1781 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
1782 if ( xml_parser.getErrorCount() > 0 ) {
1783 System.out.println( "errors:" );
1784 System.out.println( xml_parser.getErrorMessages().toString() );
1787 if ( phylogenies_1.length != 4 ) {
1790 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
1792 if ( xml_parser.getErrorCount() > 0 ) {
1793 System.out.println( "errors:" );
1794 System.out.println( xml_parser.getErrorMessages().toString() );
1797 if ( phylogenies_2.length != 1 ) {
1800 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
1803 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
1805 if ( xml_parser.getErrorCount() > 0 ) {
1806 System.out.println( xml_parser.getErrorMessages().toString() );
1809 if ( phylogenies_3.length != 2 ) {
1812 final Phylogeny a = phylogenies_3[ 0 ];
1813 if ( !a.getName().equals( "tree 4" ) ) {
1816 if ( a.getNumberOfExternalNodes() != 3 ) {
1819 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
1822 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
1825 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
1827 if ( xml_parser.getErrorCount() > 0 ) {
1828 System.out.println( xml_parser.getErrorMessages().toString() );
1831 if ( phylogenies_4.length != 1 ) {
1834 final Phylogeny s = phylogenies_4[ 0 ];
1835 if ( s.getNumberOfExternalNodes() != 6 ) {
1838 s.getNode( "first" );
1840 s.getNode( "\"<a'b&c'd\">\"" );
1841 s.getNode( "'''\"" );
1842 s.getNode( "\"\"\"" );
1843 s.getNode( "dick & doof" );
1845 catch ( final Exception e ) {
1846 e.printStackTrace( System.out );
1852 private static boolean testBasicTable() {
1854 final BasicTable<String> t0 = new BasicTable<String>();
1855 if ( t0.getNumberOfColumns() != 0 ) {
1858 if ( t0.getNumberOfRows() != 0 ) {
1861 t0.setValue( 3, 2, "23" );
1862 t0.setValue( 10, 1, "error" );
1863 t0.setValue( 10, 1, "110" );
1864 t0.setValue( 9, 1, "19" );
1865 t0.setValue( 1, 10, "101" );
1866 t0.setValue( 10, 10, "1010" );
1867 t0.setValue( 100, 10, "10100" );
1868 t0.setValue( 0, 0, "00" );
1869 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
1872 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
1875 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
1878 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
1881 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
1884 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
1887 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
1890 if ( t0.getNumberOfColumns() != 101 ) {
1893 if ( t0.getNumberOfRows() != 11 ) {
1896 if ( t0.getValueAsString( 49, 4 ) != null ) {
1899 final String l = ForesterUtil.getLineSeparator();
1900 final StringBuffer source = new StringBuffer();
1901 source.append( "" + l );
1902 source.append( "# 1 1 1 1 1 1 1 1" + l );
1903 source.append( " 00 01 02 03" + l );
1904 source.append( " 10 11 12 13 " + l );
1905 source.append( "20 21 22 23 " + l );
1906 source.append( " 30 31 32 33" + l );
1907 source.append( "40 41 42 43" + l );
1908 source.append( " # 1 1 1 1 1 " + l );
1909 source.append( "50 51 52 53 54" + l );
1910 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
1911 if ( t1.getNumberOfColumns() != 5 ) {
1914 if ( t1.getNumberOfRows() != 6 ) {
1917 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
1920 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
1923 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
1926 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
1929 final StringBuffer source1 = new StringBuffer();
1930 source1.append( "" + l );
1931 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
1932 source1.append( " 00; 01 ;02;03" + l );
1933 source1.append( " 10; 11; 12; 13 " + l );
1934 source1.append( "20; 21; 22; 23 " + l );
1935 source1.append( " 30; 31; 32; 33" + l );
1936 source1.append( "40;41;42;43" + l );
1937 source1.append( " # 1 1 1 1 1 " + l );
1938 source1.append( ";;;50 ; ;52; 53;;54 " + l );
1939 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
1940 if ( t2.getNumberOfColumns() != 5 ) {
1943 if ( t2.getNumberOfRows() != 6 ) {
1946 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
1949 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
1952 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
1955 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
1958 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
1961 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
1964 final StringBuffer source2 = new StringBuffer();
1965 source2.append( "" + l );
1966 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
1967 source2.append( " 00; 01 ;02;03" + l );
1968 source2.append( " 10; 11; 12; 13 " + l );
1969 source2.append( "20; 21; 22; 23 " + l );
1970 source2.append( " " + l );
1971 source2.append( " 30; 31; 32; 33" + l );
1972 source2.append( "40;41;42;43" + l );
1973 source2.append( " comment: 1 1 1 1 1 " + l );
1974 source2.append( ";;;50 ; 52; 53;;54 " + l );
1975 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
1981 if ( tl.size() != 2 ) {
1984 final BasicTable<String> t3 = tl.get( 0 );
1985 final BasicTable<String> t4 = tl.get( 1 );
1986 if ( t3.getNumberOfColumns() != 4 ) {
1989 if ( t3.getNumberOfRows() != 3 ) {
1992 if ( t4.getNumberOfColumns() != 4 ) {
1995 if ( t4.getNumberOfRows() != 3 ) {
1998 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2001 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2005 catch ( final Exception e ) {
2006 e.printStackTrace( System.out );
2012 private static boolean testBasicTolXMLparsing() {
2014 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2015 final TolParser parser = new TolParser();
2016 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2017 if ( parser.getErrorCount() > 0 ) {
2018 System.out.println( parser.getErrorMessages().toString() );
2021 if ( phylogenies_0.length != 1 ) {
2024 final Phylogeny t1 = phylogenies_0[ 0 ];
2025 if ( t1.getNumberOfExternalNodes() != 5 ) {
2028 if ( !t1.isRooted() ) {
2031 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2034 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2037 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2040 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2043 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2044 if ( parser.getErrorCount() > 0 ) {
2045 System.out.println( parser.getErrorMessages().toString() );
2048 if ( phylogenies_1.length != 1 ) {
2051 final Phylogeny t2 = phylogenies_1[ 0 ];
2052 if ( t2.getNumberOfExternalNodes() != 664 ) {
2055 if ( !t2.isRooted() ) {
2058 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2061 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2064 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2067 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2070 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2073 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2074 .equals( "Aquifex" ) ) {
2077 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2078 if ( parser.getErrorCount() > 0 ) {
2079 System.out.println( parser.getErrorMessages().toString() );
2082 if ( phylogenies_2.length != 1 ) {
2085 final Phylogeny t3 = phylogenies_2[ 0 ];
2086 if ( t3.getNumberOfExternalNodes() != 184 ) {
2089 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2092 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2095 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2098 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2099 if ( parser.getErrorCount() > 0 ) {
2100 System.out.println( parser.getErrorMessages().toString() );
2103 if ( phylogenies_3.length != 1 ) {
2106 final Phylogeny t4 = phylogenies_3[ 0 ];
2107 if ( t4.getNumberOfExternalNodes() != 1 ) {
2110 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2113 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2116 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2119 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2120 if ( parser.getErrorCount() > 0 ) {
2121 System.out.println( parser.getErrorMessages().toString() );
2124 if ( phylogenies_4.length != 1 ) {
2127 final Phylogeny t5 = phylogenies_4[ 0 ];
2128 if ( t5.getNumberOfExternalNodes() != 13 ) {
2131 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2134 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2137 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2141 catch ( final Exception e ) {
2142 e.printStackTrace( System.out );
2148 private static boolean testBasicTreeMethods() {
2150 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2151 final Phylogeny t1 = factory.create();
2152 if ( !t1.isEmpty() ) {
2155 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2156 if ( t2.getNumberOfExternalNodes() != 4 ) {
2159 if ( t2.getHeight() != 8.5 ) {
2162 if ( !t2.isCompletelyBinary() ) {
2165 if ( t2.isEmpty() ) {
2168 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2169 if ( t3.getNumberOfExternalNodes() != 5 ) {
2172 if ( t3.getHeight() != 11 ) {
2175 if ( t3.isCompletelyBinary() ) {
2178 final PhylogenyNode n = t3.getNode( "ABC" );
2179 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 ];
2180 if ( t4.getNumberOfExternalNodes() != 9 ) {
2183 if ( t4.getHeight() != 11 ) {
2186 if ( t4.isCompletelyBinary() ) {
2189 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)" );
2190 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2191 if ( t5.getNumberOfExternalNodes() != 8 ) {
2194 if ( t5.getHeight() != 15 ) {
2197 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)" );
2198 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2199 if ( t6.getHeight() != 15 ) {
2202 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)" );
2203 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2204 if ( t7.getHeight() != 15 ) {
2207 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)" );
2208 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2209 if ( t8.getNumberOfExternalNodes() != 10 ) {
2212 if ( t8.getHeight() != 15 ) {
2215 final char[] a9 = new char[] { 'a' };
2216 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2217 if ( t9.getHeight() != 0 ) {
2220 final char[] a10 = new char[] { 'a', ':', '6' };
2221 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2222 if ( t10.getHeight() != 6 ) {
2226 catch ( final Exception e ) {
2227 e.printStackTrace( System.out );
2233 private static boolean testTreeMethods() {
2235 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2236 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
2237 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
2238 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
2239 System.out.println( t0.toNewHampshireX() );
2242 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
2243 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
2244 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
2247 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
2250 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
2254 catch ( final Exception e ) {
2255 e.printStackTrace( System.out );
2261 private static boolean testConfidenceAssessor() {
2263 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2264 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2265 final Phylogeny[] ev0 = factory
2266 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2268 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2269 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2272 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2275 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2276 final Phylogeny[] ev1 = factory
2277 .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)));",
2279 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2280 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2283 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2286 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2287 final Phylogeny[] ev_b = factory
2288 .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",
2290 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2291 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2294 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2298 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2299 final Phylogeny[] ev1x = factory
2300 .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)));",
2302 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2303 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2306 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2309 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2310 final Phylogeny[] ev_bx = factory
2311 .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",
2313 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2314 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2317 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2321 final Phylogeny[] t2 = factory
2322 .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);",
2324 final Phylogeny[] ev2 = factory
2325 .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);",
2327 for( final Phylogeny target : t2 ) {
2328 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2331 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2332 new NHXParser() )[ 0 ];
2333 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2334 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2335 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2338 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2341 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2345 catch ( final Exception e ) {
2346 e.printStackTrace();
2352 private static boolean testCopyOfNodeData() {
2354 final PhylogenyNode n1 = PhylogenyNode
2355 .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]" );
2356 final PhylogenyNode n2 = n1.copyNodeData();
2357 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2361 catch ( final Exception e ) {
2362 e.printStackTrace();
2368 private static boolean testDataObjects() {
2370 final Confidence s0 = new Confidence();
2371 final Confidence s1 = new Confidence();
2372 if ( !s0.isEqual( s1 ) ) {
2375 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2376 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2377 if ( s2.isEqual( s1 ) ) {
2380 if ( !s2.isEqual( s3 ) ) {
2383 final Confidence s4 = ( Confidence ) s3.copy();
2384 if ( !s4.isEqual( s3 ) ) {
2391 final Taxonomy t1 = new Taxonomy();
2392 final Taxonomy t2 = new Taxonomy();
2393 final Taxonomy t3 = new Taxonomy();
2394 final Taxonomy t4 = new Taxonomy();
2395 final Taxonomy t5 = new Taxonomy();
2396 t1.setIdentifier( new Identifier( "ecoli" ) );
2397 t1.setTaxonomyCode( "ECOLI" );
2398 t1.setScientificName( "E. coli" );
2399 t1.setCommonName( "coli" );
2400 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2401 if ( !t1.isEqual( t0 ) ) {
2404 t2.setIdentifier( new Identifier( "ecoli" ) );
2405 t2.setTaxonomyCode( "OTHER" );
2406 t2.setScientificName( "what" );
2407 t2.setCommonName( "something" );
2408 if ( !t1.isEqual( t2 ) ) {
2411 t2.setIdentifier( new Identifier( "nemve" ) );
2412 if ( t1.isEqual( t2 ) ) {
2415 t1.setIdentifier( null );
2416 t3.setTaxonomyCode( "ECOLI" );
2417 t3.setScientificName( "what" );
2418 t3.setCommonName( "something" );
2419 if ( !t1.isEqual( t3 ) ) {
2422 t1.setIdentifier( null );
2423 t1.setTaxonomyCode( "" );
2424 t4.setScientificName( "E. ColI" );
2425 t4.setCommonName( "something" );
2426 if ( !t1.isEqual( t4 ) ) {
2429 t4.setScientificName( "B. subtilis" );
2430 t4.setCommonName( "something" );
2431 if ( t1.isEqual( t4 ) ) {
2434 t1.setIdentifier( null );
2435 t1.setTaxonomyCode( "" );
2436 t1.setScientificName( "" );
2437 t5.setCommonName( "COLI" );
2438 if ( !t1.isEqual( t5 ) ) {
2441 t5.setCommonName( "vibrio" );
2442 if ( t1.isEqual( t5 ) ) {
2447 final Identifier id0 = new Identifier( "123", "pfam" );
2448 final Identifier id1 = ( Identifier ) id0.copy();
2449 if ( !id1.isEqual( id1 ) ) {
2452 if ( !id1.isEqual( id0 ) ) {
2455 if ( !id0.isEqual( id1 ) ) {
2462 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
2463 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
2464 if ( !pd1.isEqual( pd1 ) ) {
2467 if ( !pd1.isEqual( pd0 ) ) {
2472 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
2473 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
2474 if ( !pd3.isEqual( pd3 ) ) {
2477 if ( !pd2.isEqual( pd3 ) ) {
2480 if ( !pd0.isEqual( pd3 ) ) {
2485 // DomainArchitecture
2486 // ------------------
2487 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
2488 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
2489 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
2490 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
2491 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
2492 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
2497 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
2498 if ( ds0.getNumberOfDomains() != 4 ) {
2501 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
2502 if ( !ds0.isEqual( ds0 ) ) {
2505 if ( !ds0.isEqual( ds1 ) ) {
2508 if ( ds1.getNumberOfDomains() != 4 ) {
2511 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
2516 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
2517 if ( ds0.isEqual( ds2 ) ) {
2523 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
2524 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
2525 System.out.println( ds3.toNHX() );
2528 if ( ds3.getNumberOfDomains() != 3 ) {
2533 final Event e1 = new Event( Event.EventType.fusion );
2534 if ( e1.isDuplication() ) {
2537 if ( !e1.isFusion() ) {
2540 if ( !e1.asText().toString().equals( "fusion" ) ) {
2543 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
2546 final Event e11 = new Event( Event.EventType.fusion );
2547 if ( !e11.isEqual( e1 ) ) {
2550 if ( !e11.toNHX().toString().equals( "" ) ) {
2553 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
2554 if ( e2.isDuplication() ) {
2557 if ( !e2.isSpeciationOrDuplication() ) {
2560 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
2563 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
2566 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
2569 if ( e11.isEqual( e2 ) ) {
2572 final Event e2c = ( Event ) e2.copy();
2573 if ( !e2c.isEqual( e2 ) ) {
2576 Event e3 = new Event( 1, 2, 3 );
2577 if ( e3.isDuplication() ) {
2580 if ( e3.isSpeciation() ) {
2583 if ( e3.isGeneLoss() ) {
2586 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2589 final Event e3c = ( Event ) e3.copy();
2590 final Event e3cc = ( Event ) e3c.copy();
2591 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
2595 if ( !e3c.isEqual( e3cc ) ) {
2598 Event e4 = new Event( 1, 2, 3 );
2599 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2602 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
2605 final Event e4c = ( Event ) e4.copy();
2607 final Event e4cc = ( Event ) e4c.copy();
2608 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2611 if ( !e4c.isEqual( e4cc ) ) {
2614 final Event e5 = new Event();
2615 if ( !e5.isUnassigned() ) {
2618 if ( !e5.asText().toString().equals( "unassigned" ) ) {
2621 if ( !e5.asSimpleText().toString().equals( "" ) ) {
2624 final Event e6 = new Event( 1, 0, 0 );
2625 if ( !e6.asText().toString().equals( "duplication" ) ) {
2628 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
2631 final Event e7 = new Event( 0, 1, 0 );
2632 if ( !e7.asText().toString().equals( "speciation" ) ) {
2635 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
2638 final Event e8 = new Event( 0, 0, 1 );
2639 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
2642 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
2646 catch ( final Exception e ) {
2647 e.printStackTrace( System.out );
2653 private static boolean testDeletionOfExternalNodes() {
2655 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2656 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
2657 final PhylogenyWriter w = new PhylogenyWriter();
2658 if ( t0.isEmpty() ) {
2661 if ( t0.getNumberOfExternalNodes() != 1 ) {
2664 t0.deleteSubtree( t0.getNode( "A" ), false );
2665 if ( t0.getNumberOfExternalNodes() != 0 ) {
2668 if ( !t0.isEmpty() ) {
2671 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
2672 if ( t1.getNumberOfExternalNodes() != 2 ) {
2675 t1.deleteSubtree( t1.getNode( "A" ), false );
2676 if ( t1.getNumberOfExternalNodes() != 1 ) {
2679 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
2682 t1.deleteSubtree( t1.getNode( "B" ), false );
2683 if ( t1.getNumberOfExternalNodes() != 1 ) {
2686 t1.deleteSubtree( t1.getNode( "r" ), false );
2687 if ( !t1.isEmpty() ) {
2690 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
2691 if ( t2.getNumberOfExternalNodes() != 3 ) {
2694 t2.deleteSubtree( t2.getNode( "B" ), false );
2695 if ( t2.getNumberOfExternalNodes() != 2 ) {
2698 t2.toNewHampshireX();
2699 PhylogenyNode n = t2.getNode( "A" );
2700 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2703 t2.deleteSubtree( t2.getNode( "A" ), false );
2704 if ( t2.getNumberOfExternalNodes() != 2 ) {
2707 t2.deleteSubtree( t2.getNode( "C" ), true );
2708 if ( t2.getNumberOfExternalNodes() != 1 ) {
2711 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2712 if ( t3.getNumberOfExternalNodes() != 4 ) {
2715 t3.deleteSubtree( t3.getNode( "B" ), true );
2716 if ( t3.getNumberOfExternalNodes() != 3 ) {
2719 n = t3.getNode( "A" );
2720 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2723 n = n.getNextExternalNode();
2724 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2727 t3.deleteSubtree( t3.getNode( "A" ), true );
2728 if ( t3.getNumberOfExternalNodes() != 2 ) {
2731 n = t3.getNode( "C" );
2732 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2735 t3.deleteSubtree( t3.getNode( "C" ), true );
2736 if ( t3.getNumberOfExternalNodes() != 1 ) {
2739 t3.deleteSubtree( t3.getNode( "D" ), true );
2740 if ( t3.getNumberOfExternalNodes() != 0 ) {
2743 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2744 if ( t4.getNumberOfExternalNodes() != 6 ) {
2747 t4.deleteSubtree( t4.getNode( "B2" ), true );
2748 if ( t4.getNumberOfExternalNodes() != 5 ) {
2751 String s = w.toNewHampshire( t4, false, true ).toString();
2752 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2755 t4.deleteSubtree( t4.getNode( "B11" ), true );
2756 if ( t4.getNumberOfExternalNodes() != 4 ) {
2759 t4.deleteSubtree( t4.getNode( "C" ), true );
2760 if ( t4.getNumberOfExternalNodes() != 3 ) {
2763 n = t4.getNode( "A" );
2764 n = n.getNextExternalNode();
2765 if ( !n.getName().equals( "B12" ) ) {
2768 n = n.getNextExternalNode();
2769 if ( !n.getName().equals( "D" ) ) {
2772 s = w.toNewHampshire( t4, false, true ).toString();
2773 if ( !s.equals( "((A,B12),D);" ) ) {
2776 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2777 t5.deleteSubtree( t5.getNode( "A" ), true );
2778 if ( t5.getNumberOfExternalNodes() != 5 ) {
2781 s = w.toNewHampshire( t5, false, true ).toString();
2782 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
2785 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2786 t6.deleteSubtree( t6.getNode( "B11" ), true );
2787 if ( t6.getNumberOfExternalNodes() != 5 ) {
2790 s = w.toNewHampshire( t6, false, false ).toString();
2791 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
2794 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2795 t7.deleteSubtree( t7.getNode( "B12" ), true );
2796 if ( t7.getNumberOfExternalNodes() != 5 ) {
2799 s = w.toNewHampshire( t7, false, true ).toString();
2800 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
2803 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2804 t8.deleteSubtree( t8.getNode( "B2" ), true );
2805 if ( t8.getNumberOfExternalNodes() != 5 ) {
2808 s = w.toNewHampshire( t8, false, false ).toString();
2809 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2812 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2813 t9.deleteSubtree( t9.getNode( "C" ), true );
2814 if ( t9.getNumberOfExternalNodes() != 5 ) {
2817 s = w.toNewHampshire( t9, false, true ).toString();
2818 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
2821 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2822 t10.deleteSubtree( t10.getNode( "D" ), true );
2823 if ( t10.getNumberOfExternalNodes() != 5 ) {
2826 s = w.toNewHampshire( t10, false, true ).toString();
2827 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
2830 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
2831 t11.deleteSubtree( t11.getNode( "A" ), true );
2832 if ( t11.getNumberOfExternalNodes() != 2 ) {
2835 s = w.toNewHampshire( t11, false, true ).toString();
2836 if ( !s.equals( "(B,C);" ) ) {
2839 t11.deleteSubtree( t11.getNode( "C" ), true );
2840 if ( t11.getNumberOfExternalNodes() != 1 ) {
2843 s = w.toNewHampshire( t11, false, false ).toString();
2844 if ( !s.equals( "B;" ) ) {
2847 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
2848 t12.deleteSubtree( t12.getNode( "B2" ), true );
2849 if ( t12.getNumberOfExternalNodes() != 8 ) {
2852 s = w.toNewHampshire( t12, false, true ).toString();
2853 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
2856 t12.deleteSubtree( t12.getNode( "B3" ), true );
2857 if ( t12.getNumberOfExternalNodes() != 7 ) {
2860 s = w.toNewHampshire( t12, false, true ).toString();
2861 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
2864 t12.deleteSubtree( t12.getNode( "C3" ), true );
2865 if ( t12.getNumberOfExternalNodes() != 6 ) {
2868 s = w.toNewHampshire( t12, false, true ).toString();
2869 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
2872 t12.deleteSubtree( t12.getNode( "A1" ), true );
2873 if ( t12.getNumberOfExternalNodes() != 5 ) {
2876 s = w.toNewHampshire( t12, false, true ).toString();
2877 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
2880 t12.deleteSubtree( t12.getNode( "B1" ), true );
2881 if ( t12.getNumberOfExternalNodes() != 4 ) {
2884 s = w.toNewHampshire( t12, false, true ).toString();
2885 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
2888 t12.deleteSubtree( t12.getNode( "A3" ), true );
2889 if ( t12.getNumberOfExternalNodes() != 3 ) {
2892 s = w.toNewHampshire( t12, false, true ).toString();
2893 if ( !s.equals( "(A2,(C1,C2));" ) ) {
2896 t12.deleteSubtree( t12.getNode( "A2" ), true );
2897 if ( t12.getNumberOfExternalNodes() != 2 ) {
2900 s = w.toNewHampshire( t12, false, true ).toString();
2901 if ( !s.equals( "(C1,C2);" ) ) {
2904 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
2905 t13.deleteSubtree( t13.getNode( "D" ), true );
2906 if ( t13.getNumberOfExternalNodes() != 4 ) {
2909 s = w.toNewHampshire( t13, false, true ).toString();
2910 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
2913 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
2914 t14.deleteSubtree( t14.getNode( "E" ), true );
2915 if ( t14.getNumberOfExternalNodes() != 5 ) {
2918 s = w.toNewHampshire( t14, false, true ).toString();
2919 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
2922 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
2923 t15.deleteSubtree( t15.getNode( "B2" ), true );
2924 if ( t15.getNumberOfExternalNodes() != 11 ) {
2927 t15.deleteSubtree( t15.getNode( "B1" ), true );
2928 if ( t15.getNumberOfExternalNodes() != 10 ) {
2931 t15.deleteSubtree( t15.getNode( "B3" ), true );
2932 if ( t15.getNumberOfExternalNodes() != 9 ) {
2935 t15.deleteSubtree( t15.getNode( "B4" ), true );
2936 if ( t15.getNumberOfExternalNodes() != 8 ) {
2939 t15.deleteSubtree( t15.getNode( "A1" ), true );
2940 if ( t15.getNumberOfExternalNodes() != 7 ) {
2943 t15.deleteSubtree( t15.getNode( "C4" ), true );
2944 if ( t15.getNumberOfExternalNodes() != 6 ) {
2948 catch ( final Exception e ) {
2949 e.printStackTrace( System.out );
2955 private static boolean testDescriptiveStatistics() {
2957 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
2958 dss1.addValue( 82 );
2959 dss1.addValue( 78 );
2960 dss1.addValue( 70 );
2961 dss1.addValue( 58 );
2962 dss1.addValue( 42 );
2963 if ( dss1.getN() != 5 ) {
2966 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
2969 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
2972 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
2975 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
2978 if ( !Test.isEqual( dss1.median(), 70 ) ) {
2981 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
2984 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
2987 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
2990 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
2993 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
2996 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
2999 dss1.addValue( 123 );
3000 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3003 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3006 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3009 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3010 dss2.addValue( -1.85 );
3011 dss2.addValue( 57.5 );
3012 dss2.addValue( 92.78 );
3013 dss2.addValue( 57.78 );
3014 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3017 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3020 final double[] a = dss2.getDataAsDoubleArray();
3021 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3024 dss2.addValue( -100 );
3025 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3028 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3031 final double[] ds = new double[ 14 ];
3046 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3047 if ( bins.length != 4 ) {
3050 if ( bins[ 0 ] != 2 ) {
3053 if ( bins[ 1 ] != 3 ) {
3056 if ( bins[ 2 ] != 4 ) {
3059 if ( bins[ 3 ] != 5 ) {
3062 final double[] ds1 = new double[ 9 ];
3072 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3073 if ( bins1.length != 4 ) {
3076 if ( bins1[ 0 ] != 2 ) {
3079 if ( bins1[ 1 ] != 3 ) {
3082 if ( bins1[ 2 ] != 0 ) {
3085 if ( bins1[ 3 ] != 4 ) {
3088 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3089 if ( bins1_1.length != 3 ) {
3092 if ( bins1_1[ 0 ] != 3 ) {
3095 if ( bins1_1[ 1 ] != 2 ) {
3098 if ( bins1_1[ 2 ] != 4 ) {
3101 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3102 if ( bins1_2.length != 3 ) {
3105 if ( bins1_2[ 0 ] != 2 ) {
3108 if ( bins1_2[ 1 ] != 2 ) {
3111 if ( bins1_2[ 2 ] != 2 ) {
3114 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3128 dss3.addValue( 10 );
3129 dss3.addValue( 10 );
3130 dss3.addValue( 10 );
3131 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3132 histo.toStringBuffer( 10, '=', 40, 5 );
3133 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3135 catch ( final Exception e ) {
3136 e.printStackTrace( System.out );
3142 private static boolean testDir( final String file ) {
3144 final File f = new File( file );
3145 if ( !f.exists() ) {
3148 if ( !f.isDirectory() ) {
3151 if ( !f.canRead() ) {
3155 catch ( final Exception e ) {
3161 private static boolean testExternalNodeRelatedMethods() {
3163 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3164 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3165 PhylogenyNode n = t1.getNode( "A" );
3166 n = n.getNextExternalNode();
3167 if ( !n.getName().equals( "B" ) ) {
3170 n = n.getNextExternalNode();
3171 if ( !n.getName().equals( "C" ) ) {
3174 n = n.getNextExternalNode();
3175 if ( !n.getName().equals( "D" ) ) {
3178 n = t1.getNode( "B" );
3179 while ( !n.isLastExternalNode() ) {
3180 n = n.getNextExternalNode();
3182 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3183 n = t2.getNode( "A" );
3184 n = n.getNextExternalNode();
3185 if ( !n.getName().equals( "B" ) ) {
3188 n = n.getNextExternalNode();
3189 if ( !n.getName().equals( "C" ) ) {
3192 n = n.getNextExternalNode();
3193 if ( !n.getName().equals( "D" ) ) {
3196 n = t2.getNode( "B" );
3197 while ( !n.isLastExternalNode() ) {
3198 n = n.getNextExternalNode();
3200 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3201 n = t3.getNode( "A" );
3202 n = n.getNextExternalNode();
3203 if ( !n.getName().equals( "B" ) ) {
3206 n = n.getNextExternalNode();
3207 if ( !n.getName().equals( "C" ) ) {
3210 n = n.getNextExternalNode();
3211 if ( !n.getName().equals( "D" ) ) {
3214 n = n.getNextExternalNode();
3215 if ( !n.getName().equals( "E" ) ) {
3218 n = n.getNextExternalNode();
3219 if ( !n.getName().equals( "F" ) ) {
3222 n = n.getNextExternalNode();
3223 if ( !n.getName().equals( "G" ) ) {
3226 n = n.getNextExternalNode();
3227 if ( !n.getName().equals( "H" ) ) {
3230 n = t3.getNode( "B" );
3231 while ( !n.isLastExternalNode() ) {
3232 n = n.getNextExternalNode();
3234 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3235 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3236 final PhylogenyNode node = iter.next();
3238 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3239 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3240 final PhylogenyNode node = iter.next();
3242 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
3243 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
3244 if ( !iter.next().getName().equals( "A" ) ) {
3247 if ( !iter.next().getName().equals( "B" ) ) {
3250 if ( !iter.next().getName().equals( "C" ) ) {
3253 if ( !iter.next().getName().equals( "D" ) ) {
3256 if ( !iter.next().getName().equals( "E" ) ) {
3259 if ( !iter.next().getName().equals( "F" ) ) {
3262 if ( iter.hasNext() ) {
3266 catch ( final Exception e ) {
3267 e.printStackTrace( System.out );
3273 private static boolean testGeneralTable() {
3275 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
3276 t0.setValue( 3, 2, "23" );
3277 t0.setValue( 10, 1, "error" );
3278 t0.setValue( 10, 1, "110" );
3279 t0.setValue( 9, 1, "19" );
3280 t0.setValue( 1, 10, "101" );
3281 t0.setValue( 10, 10, "1010" );
3282 t0.setValue( 100, 10, "10100" );
3283 t0.setValue( 0, 0, "00" );
3284 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3287 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3290 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3293 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3296 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3299 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3302 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3305 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
3308 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
3311 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
3312 t1.setValue( "3", "2", "23" );
3313 t1.setValue( "10", "1", "error" );
3314 t1.setValue( "10", "1", "110" );
3315 t1.setValue( "9", "1", "19" );
3316 t1.setValue( "1", "10", "101" );
3317 t1.setValue( "10", "10", "1010" );
3318 t1.setValue( "100", "10", "10100" );
3319 t1.setValue( "0", "0", "00" );
3320 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
3321 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
3324 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
3327 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
3330 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
3333 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
3336 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
3339 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
3342 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
3345 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
3348 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
3352 catch ( final Exception e ) {
3353 e.printStackTrace( System.out );
3359 private static boolean testGetDistance() {
3361 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3362 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",
3363 new NHXParser() )[ 0 ];
3364 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
3367 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
3370 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
3373 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
3376 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
3379 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
3382 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
3385 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
3388 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
3391 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
3394 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
3397 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
3400 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
3403 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
3406 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
3409 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
3412 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
3415 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
3418 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
3421 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
3424 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
3427 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
3430 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
3433 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
3436 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
3439 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
3442 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
3445 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
3448 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
3451 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
3454 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
3457 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",
3458 new NHXParser() )[ 0 ];
3459 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
3462 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
3465 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
3468 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
3471 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
3474 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
3477 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
3480 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
3483 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
3486 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
3489 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
3493 catch ( final Exception e ) {
3494 e.printStackTrace( System.out );
3500 private static boolean testGetLCA() {
3502 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3503 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
3504 new NHXParser() )[ 0 ];
3505 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
3506 if ( !A.getName().equals( "A" ) ) {
3509 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
3510 if ( !gh.getName().equals( "gh" ) ) {
3513 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
3514 if ( !ab.getName().equals( "ab" ) ) {
3517 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
3518 if ( !ab2.getName().equals( "ab" ) ) {
3521 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
3522 if ( !gh2.getName().equals( "gh" ) ) {
3525 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
3526 if ( !gh3.getName().equals( "gh" ) ) {
3529 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
3530 if ( !abc.getName().equals( "abc" ) ) {
3533 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
3534 if ( !abc2.getName().equals( "abc" ) ) {
3537 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
3538 if ( !abcd.getName().equals( "abcd" ) ) {
3541 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
3542 if ( !abcd2.getName().equals( "abcd" ) ) {
3545 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
3546 if ( !abcdef.getName().equals( "abcdef" ) ) {
3549 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
3550 if ( !abcdef2.getName().equals( "abcdef" ) ) {
3553 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
3554 if ( !abcdef3.getName().equals( "abcdef" ) ) {
3557 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
3558 if ( !abcdef4.getName().equals( "abcdef" ) ) {
3561 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
3562 if ( !abcde.getName().equals( "abcde" ) ) {
3565 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
3566 if ( !abcde2.getName().equals( "abcde" ) ) {
3569 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
3570 if ( !r.getName().equals( "abcdefgh" ) ) {
3573 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
3574 if ( !r2.getName().equals( "abcdefgh" ) ) {
3577 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
3578 if ( !r3.getName().equals( "abcdefgh" ) ) {
3581 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
3582 if ( !abcde3.getName().equals( "abcde" ) ) {
3585 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
3586 if ( !abcde4.getName().equals( "abcde" ) ) {
3589 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
3590 if ( !ab3.getName().equals( "ab" ) ) {
3593 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
3594 if ( !ab4.getName().equals( "ab" ) ) {
3597 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
3598 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
3599 if ( !cd.getName().equals( "cd" ) ) {
3602 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
3603 if ( !cd2.getName().equals( "cd" ) ) {
3606 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
3607 if ( !cde.getName().equals( "cde" ) ) {
3610 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
3611 if ( !cde2.getName().equals( "cde" ) ) {
3614 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
3615 if ( !cdef.getName().equals( "cdef" ) ) {
3618 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
3619 if ( !cdef2.getName().equals( "cdef" ) ) {
3622 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
3623 if ( !cdef3.getName().equals( "cdef" ) ) {
3626 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
3627 if ( !rt.getName().equals( "r" ) ) {
3630 final Phylogeny p3 = factory
3631 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
3632 new NHXParser() )[ 0 ];
3633 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
3634 if ( !bc_3.getName().equals( "bc" ) ) {
3637 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
3638 if ( !ac_3.getName().equals( "abc" ) ) {
3641 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
3642 if ( !ad_3.getName().equals( "abcde" ) ) {
3645 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
3646 if ( !af_3.getName().equals( "abcdef" ) ) {
3649 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
3650 if ( !ag_3.getName().equals( "" ) ) {
3653 if ( !ag_3.isRoot() ) {
3656 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
3657 if ( !al_3.getName().equals( "" ) ) {
3660 if ( !al_3.isRoot() ) {
3663 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
3664 if ( !kl_3.getName().equals( "" ) ) {
3667 if ( !kl_3.isRoot() ) {
3670 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
3671 if ( !fl_3.getName().equals( "" ) ) {
3674 if ( !fl_3.isRoot() ) {
3677 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
3678 if ( !gk_3.getName().equals( "ghijk" ) ) {
3681 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
3682 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
3683 if ( !r_4.getName().equals( "r" ) ) {
3686 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
3687 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
3688 if ( !r_5.getName().equals( "root" ) ) {
3691 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
3692 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
3693 if ( !r_6.getName().equals( "rot" ) ) {
3696 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
3697 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
3698 if ( !r_7.getName().equals( "rott" ) ) {
3702 catch ( final Exception e ) {
3703 e.printStackTrace( System.out );
3709 private static boolean testGetLCA2() {
3711 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3712 final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
3713 PhylogenyMethods.preOrderReId( p_a );
3714 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
3715 p_a.getNode( "a" ) );
3716 if ( !p_a_1.getName().equals( "a" ) ) {
3719 final Phylogeny p_b = factory.create( "((a)b)", new NHXParser() )[ 0 ];
3720 PhylogenyMethods.preOrderReId( p_b );
3721 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
3722 p_b.getNode( "a" ) );
3723 if ( !p_b_1.getName().equals( "b" ) ) {
3726 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
3727 p_b.getNode( "b" ) );
3728 if ( !p_b_2.getName().equals( "b" ) ) {
3731 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
3732 PhylogenyMethods.preOrderReId( p_c );
3733 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
3734 p_c.getNode( "a" ) );
3735 if ( !p_c_1.getName().equals( "b" ) ) {
3738 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
3739 p_c.getNode( "c" ) );
3740 if ( !p_c_2.getName().equals( "c" ) ) {
3741 System.out.println( p_c_2.getName() );
3745 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
3746 p_c.getNode( "b" ) );
3747 if ( !p_c_3.getName().equals( "b" ) ) {
3750 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
3751 p_c.getNode( "a" ) );
3752 if ( !p_c_4.getName().equals( "c" ) ) {
3755 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
3756 new NHXParser() )[ 0 ];
3757 PhylogenyMethods.preOrderReId( p1 );
3758 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3759 p1.getNode( "A" ) );
3760 if ( !A.getName().equals( "A" ) ) {
3763 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
3764 p1.getNode( "gh" ) );
3765 if ( !gh.getName().equals( "gh" ) ) {
3768 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3769 p1.getNode( "B" ) );
3770 if ( !ab.getName().equals( "ab" ) ) {
3773 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
3774 p1.getNode( "A" ) );
3775 if ( !ab2.getName().equals( "ab" ) ) {
3778 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
3779 p1.getNode( "G" ) );
3780 if ( !gh2.getName().equals( "gh" ) ) {
3783 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
3784 p1.getNode( "H" ) );
3785 if ( !gh3.getName().equals( "gh" ) ) {
3788 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
3789 p1.getNode( "A" ) );
3790 if ( !abc.getName().equals( "abc" ) ) {
3793 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3794 p1.getNode( "C" ) );
3795 if ( !abc2.getName().equals( "abc" ) ) {
3798 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3799 p1.getNode( "D" ) );
3800 if ( !abcd.getName().equals( "abcd" ) ) {
3803 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
3804 p1.getNode( "A" ) );
3805 if ( !abcd2.getName().equals( "abcd" ) ) {
3808 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3809 p1.getNode( "F" ) );
3810 if ( !abcdef.getName().equals( "abcdef" ) ) {
3813 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
3814 p1.getNode( "A" ) );
3815 if ( !abcdef2.getName().equals( "abcdef" ) ) {
3818 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
3819 p1.getNode( "F" ) );
3820 if ( !abcdef3.getName().equals( "abcdef" ) ) {
3823 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
3824 p1.getNode( "ab" ) );
3825 if ( !abcdef4.getName().equals( "abcdef" ) ) {
3828 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3829 p1.getNode( "E" ) );
3830 if ( !abcde.getName().equals( "abcde" ) ) {
3833 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
3834 p1.getNode( "A" ) );
3835 if ( !abcde2.getName().equals( "abcde" ) ) {
3838 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
3839 p1.getNode( "abcdefgh" ) );
3840 if ( !r.getName().equals( "abcdefgh" ) ) {
3843 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3844 p1.getNode( "H" ) );
3845 if ( !r2.getName().equals( "abcdefgh" ) ) {
3848 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
3849 p1.getNode( "A" ) );
3850 if ( !r3.getName().equals( "abcdefgh" ) ) {
3853 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
3854 p1.getNode( "abcde" ) );
3855 if ( !abcde3.getName().equals( "abcde" ) ) {
3858 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
3859 p1.getNode( "E" ) );
3860 if ( !abcde4.getName().equals( "abcde" ) ) {
3863 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
3864 p1.getNode( "B" ) );
3865 if ( !ab3.getName().equals( "ab" ) ) {
3868 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
3869 p1.getNode( "ab" ) );
3870 if ( !ab4.getName().equals( "ab" ) ) {
3873 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
3874 PhylogenyMethods.preOrderReId( p2 );
3875 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
3876 p2.getNode( "d" ) );
3877 if ( !cd.getName().equals( "cd" ) ) {
3880 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
3881 p2.getNode( "c" ) );
3882 if ( !cd2.getName().equals( "cd" ) ) {
3885 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
3886 p2.getNode( "e" ) );
3887 if ( !cde.getName().equals( "cde" ) ) {
3890 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
3891 p2.getNode( "c" ) );
3892 if ( !cde2.getName().equals( "cde" ) ) {
3895 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
3896 p2.getNode( "f" ) );
3897 if ( !cdef.getName().equals( "cdef" ) ) {
3900 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
3901 p2.getNode( "f" ) );
3902 if ( !cdef2.getName().equals( "cdef" ) ) {
3905 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
3906 p2.getNode( "d" ) );
3907 if ( !cdef3.getName().equals( "cdef" ) ) {
3910 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
3911 p2.getNode( "a" ) );
3912 if ( !rt.getName().equals( "r" ) ) {
3915 final Phylogeny p3 = factory
3916 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
3917 new NHXParser() )[ 0 ];
3918 PhylogenyMethods.preOrderReId( p3 );
3919 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
3920 p3.getNode( "c" ) );
3921 if ( !bc_3.getName().equals( "bc" ) ) {
3924 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
3925 p3.getNode( "c" ) );
3926 if ( !ac_3.getName().equals( "abc" ) ) {
3929 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
3930 p3.getNode( "d" ) );
3931 if ( !ad_3.getName().equals( "abcde" ) ) {
3934 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
3935 p3.getNode( "f" ) );
3936 if ( !af_3.getName().equals( "abcdef" ) ) {
3939 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
3940 p3.getNode( "g" ) );
3941 if ( !ag_3.getName().equals( "" ) ) {
3944 if ( !ag_3.isRoot() ) {
3947 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
3948 p3.getNode( "l" ) );
3949 if ( !al_3.getName().equals( "" ) ) {
3952 if ( !al_3.isRoot() ) {
3955 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
3956 p3.getNode( "l" ) );
3957 if ( !kl_3.getName().equals( "" ) ) {
3960 if ( !kl_3.isRoot() ) {
3963 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
3964 p3.getNode( "l" ) );
3965 if ( !fl_3.getName().equals( "" ) ) {
3968 if ( !fl_3.isRoot() ) {
3971 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
3972 p3.getNode( "k" ) );
3973 if ( !gk_3.getName().equals( "ghijk" ) ) {
3976 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
3977 PhylogenyMethods.preOrderReId( p4 );
3978 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
3979 p4.getNode( "c" ) );
3980 if ( !r_4.getName().equals( "r" ) ) {
3983 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
3984 PhylogenyMethods.preOrderReId( p5 );
3985 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
3986 p5.getNode( "c" ) );
3987 if ( !r_5.getName().equals( "root" ) ) {
3990 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
3991 PhylogenyMethods.preOrderReId( p6 );
3992 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
3993 p6.getNode( "a" ) );
3994 if ( !r_6.getName().equals( "rot" ) ) {
3997 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
3998 PhylogenyMethods.preOrderReId( p7 );
3999 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
4000 p7.getNode( "e" ) );
4001 if ( !r_7.getName().equals( "rott" ) ) {
4004 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4005 p7.getNode( "a" ) );
4006 if ( !r_71.getName().equals( "rott" ) ) {
4009 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4010 p7.getNode( "rott" ) );
4011 if ( !r_72.getName().equals( "rott" ) ) {
4014 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4015 p7.getNode( "a" ) );
4016 if ( !r_73.getName().equals( "rott" ) ) {
4019 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4020 p7.getNode( "rott" ) );
4021 if ( !r_74.getName().equals( "rott" ) ) {
4024 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4025 p7.getNode( "e" ) );
4026 if ( !r_75.getName().equals( "e" ) ) {
4030 catch ( final Exception e ) {
4031 e.printStackTrace( System.out );
4037 private static boolean testHmmscanOutputParser() {
4038 final String test_dir = Test.PATH_TO_TEST_DATA;
4040 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
4041 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4043 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
4044 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4045 final List<Protein> proteins = parser2.parse();
4046 if ( parser2.getProteinsEncountered() != 4 ) {
4049 if ( proteins.size() != 4 ) {
4052 if ( parser2.getDomainsEncountered() != 69 ) {
4055 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
4058 if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
4061 final Protein p1 = proteins.get( 0 );
4062 if ( p1.getNumberOfProteinDomains() != 15 ) {
4065 if ( p1.getLength() != 850 ) {
4068 final Protein p2 = proteins.get( 1 );
4069 if ( p2.getNumberOfProteinDomains() != 51 ) {
4072 if ( p2.getLength() != 1291 ) {
4075 final Protein p3 = proteins.get( 2 );
4076 if ( p3.getNumberOfProteinDomains() != 2 ) {
4079 final Protein p4 = proteins.get( 3 );
4080 if ( p4.getNumberOfProteinDomains() != 1 ) {
4083 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
4086 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
4089 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
4092 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
4095 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
4098 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
4101 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
4104 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
4107 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
4111 catch ( final Exception e ) {
4112 e.printStackTrace( System.out );
4118 private static boolean testLastExternalNodeMethods() {
4120 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4121 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
4122 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
4123 final PhylogenyNode n1 = t0.getNode( "A" );
4124 if ( n1.isLastExternalNode() ) {
4127 final PhylogenyNode n2 = t0.getNode( "B" );
4128 if ( n2.isLastExternalNode() ) {
4131 final PhylogenyNode n3 = t0.getNode( "C" );
4132 if ( n3.isLastExternalNode() ) {
4135 final PhylogenyNode n4 = t0.getNode( "D" );
4136 if ( !n4.isLastExternalNode() ) {
4140 catch ( final Exception e ) {
4141 e.printStackTrace( System.out );
4147 private static boolean testLevelOrderIterator() {
4149 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4150 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
4151 PhylogenyNodeIterator it0;
4152 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
4155 for( it0.reset(); it0.hasNext(); ) {
4158 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
4159 if ( !it.next().getName().equals( "r" ) ) {
4162 if ( !it.next().getName().equals( "ab" ) ) {
4165 if ( !it.next().getName().equals( "cd" ) ) {
4168 if ( !it.next().getName().equals( "A" ) ) {
4171 if ( !it.next().getName().equals( "B" ) ) {
4174 if ( !it.next().getName().equals( "C" ) ) {
4177 if ( !it.next().getName().equals( "D" ) ) {
4180 if ( it.hasNext() ) {
4183 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",
4184 new NHXParser() )[ 0 ];
4185 PhylogenyNodeIterator it2;
4186 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
4189 for( it2.reset(); it2.hasNext(); ) {
4192 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
4193 if ( !it3.next().getName().equals( "r" ) ) {
4196 if ( !it3.next().getName().equals( "abc" ) ) {
4199 if ( !it3.next().getName().equals( "defg" ) ) {
4202 if ( !it3.next().getName().equals( "A" ) ) {
4205 if ( !it3.next().getName().equals( "B" ) ) {
4208 if ( !it3.next().getName().equals( "C" ) ) {
4211 if ( !it3.next().getName().equals( "D" ) ) {
4214 if ( !it3.next().getName().equals( "E" ) ) {
4217 if ( !it3.next().getName().equals( "F" ) ) {
4220 if ( !it3.next().getName().equals( "G" ) ) {
4223 if ( !it3.next().getName().equals( "1" ) ) {
4226 if ( !it3.next().getName().equals( "2" ) ) {
4229 if ( !it3.next().getName().equals( "3" ) ) {
4232 if ( !it3.next().getName().equals( "4" ) ) {
4235 if ( !it3.next().getName().equals( "5" ) ) {
4238 if ( !it3.next().getName().equals( "6" ) ) {
4241 if ( !it3.next().getName().equals( "f1" ) ) {
4244 if ( !it3.next().getName().equals( "f2" ) ) {
4247 if ( !it3.next().getName().equals( "f3" ) ) {
4250 if ( !it3.next().getName().equals( "a" ) ) {
4253 if ( !it3.next().getName().equals( "b" ) ) {
4256 if ( !it3.next().getName().equals( "f21" ) ) {
4259 if ( !it3.next().getName().equals( "X" ) ) {
4262 if ( !it3.next().getName().equals( "Y" ) ) {
4265 if ( !it3.next().getName().equals( "Z" ) ) {
4268 if ( it3.hasNext() ) {
4271 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
4272 PhylogenyNodeIterator it4;
4273 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
4276 for( it4.reset(); it4.hasNext(); ) {
4279 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
4280 if ( !it5.next().getName().equals( "r" ) ) {
4283 if ( !it5.next().getName().equals( "A" ) ) {
4286 if ( !it5.next().getName().equals( "B" ) ) {
4289 if ( !it5.next().getName().equals( "C" ) ) {
4292 if ( !it5.next().getName().equals( "D" ) ) {
4295 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
4296 PhylogenyNodeIterator it6;
4297 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
4300 for( it6.reset(); it6.hasNext(); ) {
4303 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
4304 if ( !it7.next().getName().equals( "A" ) ) {
4307 if ( it.hasNext() ) {
4311 catch ( final Exception e ) {
4312 e.printStackTrace( System.out );
4318 private static boolean testNodeRemoval() {
4320 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4321 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
4322 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
4323 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
4326 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
4327 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
4328 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
4331 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
4332 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
4333 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
4337 catch ( final Exception e ) {
4338 e.printStackTrace( System.out );
4344 private static boolean testMidpointrooting() {
4346 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4347 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
4348 PhylogenyMethods.midpointRoot( t0 );
4349 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
4352 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
4355 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
4359 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",
4360 new NHXParser() )[ 0 ];
4361 if ( !t1.isRooted() ) {
4364 PhylogenyMethods.midpointRoot( t1 );
4365 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
4368 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
4371 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
4374 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
4377 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
4380 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
4383 t1.reRoot( t1.getNode( "A" ) );
4384 PhylogenyMethods.midpointRoot( t1 );
4385 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
4388 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
4391 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
4394 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
4397 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
4401 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
4405 catch ( final Exception e ) {
4406 e.printStackTrace( System.out );
4412 private static boolean testNexusCharactersParsing() {
4414 final NexusCharactersParser parser = new NexusCharactersParser();
4415 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
4417 String[] labels = parser.getCharStateLabels();
4418 if ( labels.length != 7 ) {
4421 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
4424 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
4427 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
4430 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
4433 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
4436 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
4439 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
4442 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
4444 labels = parser.getCharStateLabels();
4445 if ( labels.length != 7 ) {
4448 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
4451 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
4454 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
4457 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
4460 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
4463 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
4466 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
4470 catch ( final Exception e ) {
4471 e.printStackTrace( System.out );
4477 private static boolean testNexusMatrixParsing() {
4479 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
4480 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
4482 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
4483 if ( m.getNumberOfCharacters() != 9 ) {
4486 if ( m.getNumberOfIdentifiers() != 5 ) {
4489 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
4492 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
4495 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
4498 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
4501 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
4504 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
4507 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
4510 // if ( labels.length != 7 ) {
4513 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
4516 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
4519 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
4522 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
4525 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
4528 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
4531 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
4534 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
4536 // labels = parser.getCharStateLabels();
4537 // if ( labels.length != 7 ) {
4540 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
4543 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
4546 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
4549 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
4552 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
4555 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
4558 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
4562 catch ( final Exception e ) {
4563 e.printStackTrace( System.out );
4569 private static boolean testNexusTreeParsing() {
4571 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4572 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
4573 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
4574 if ( phylogenies.length != 1 ) {
4577 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
4580 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
4584 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
4585 if ( phylogenies.length != 1 ) {
4588 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
4591 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
4595 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
4596 if ( phylogenies.length != 1 ) {
4599 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
4602 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
4605 if ( phylogenies[ 0 ].isRooted() ) {
4609 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
4610 if ( phylogenies.length != 18 ) {
4613 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
4616 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
4619 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
4622 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
4625 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
4628 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
4631 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
4634 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
4637 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
4640 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
4643 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
4646 if ( phylogenies[ 8 ].isRooted() ) {
4649 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
4652 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
4655 if ( !phylogenies[ 9 ].isRooted() ) {
4658 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
4661 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
4664 if ( !phylogenies[ 10 ].isRooted() ) {
4667 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
4670 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
4673 if ( phylogenies[ 11 ].isRooted() ) {
4676 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
4679 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
4682 if ( !phylogenies[ 12 ].isRooted() ) {
4685 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
4688 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
4691 if ( !phylogenies[ 13 ].isRooted() ) {
4694 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
4697 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
4700 if ( !phylogenies[ 14 ].isRooted() ) {
4703 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
4706 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
4709 if ( phylogenies[ 15 ].isRooted() ) {
4712 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
4715 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
4718 if ( !phylogenies[ 16 ].isRooted() ) {
4721 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
4724 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
4727 if ( phylogenies[ 17 ].isRooted() ) {
4730 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
4734 catch ( final Exception e ) {
4735 e.printStackTrace( System.out );
4741 private static boolean testNexusTreeParsingIterating() {
4743 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
4744 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
4745 if ( !p.hasNext() ) {
4748 Phylogeny phy = p.next();
4749 if ( phy == null ) {
4752 if ( phy.getNumberOfExternalNodes() != 25 ) {
4755 if ( !phy.getName().equals( "" ) ) {
4758 if ( p.hasNext() ) {
4762 if ( phy != null ) {
4767 if ( !p.hasNext() ) {
4771 if ( phy == null ) {
4774 if ( phy.getNumberOfExternalNodes() != 25 ) {
4777 if ( !phy.getName().equals( "" ) ) {
4780 if ( p.hasNext() ) {
4784 if ( phy != null ) {
4788 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
4789 if ( !p.hasNext() ) {
4793 if ( phy == null ) {
4796 if ( phy.getNumberOfExternalNodes() != 10 ) {
4799 if ( !phy.getName().equals( "name" ) ) {
4802 if ( p.hasNext() ) {
4806 if ( phy != null ) {
4811 if ( !p.hasNext() ) {
4815 if ( phy == null ) {
4818 if ( phy.getNumberOfExternalNodes() != 10 ) {
4821 if ( !phy.getName().equals( "name" ) ) {
4824 if ( p.hasNext() ) {
4828 if ( phy != null ) {
4832 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
4833 if ( !p.hasNext() ) {
4837 if ( phy == null ) {
4840 if ( phy.getNumberOfExternalNodes() != 3 ) {
4843 if ( !phy.getName().equals( "" ) ) {
4846 if ( phy.isRooted() ) {
4849 if ( p.hasNext() ) {
4853 if ( phy != null ) {
4858 if ( !p.hasNext() ) {
4862 if ( phy == null ) {
4865 if ( phy.getNumberOfExternalNodes() != 3 ) {
4868 if ( !phy.getName().equals( "" ) ) {
4871 if ( p.hasNext() ) {
4875 if ( phy != null ) {
4879 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
4880 // if ( phylogenies.length != 18 ) {
4884 if ( !p.hasNext() ) {
4888 if ( phy == null ) {
4891 if ( phy.getNumberOfExternalNodes() != 10 ) {
4894 if ( !phy.getName().equals( "tree 0" ) ) {
4898 if ( !p.hasNext() ) {
4902 if ( phy == null ) {
4905 if ( phy.getNumberOfExternalNodes() != 10 ) {
4908 if ( !phy.getName().equals( "tree 1" ) ) {
4912 if ( !p.hasNext() ) {
4916 if ( phy == null ) {
4919 if ( phy.getNumberOfExternalNodes() != 3 ) {
4922 if ( !phy.getName().equals( "" ) ) {
4925 if ( phy.isRooted() ) {
4929 if ( !p.hasNext() ) {
4933 if ( phy == null ) {
4936 if ( phy.getNumberOfExternalNodes() != 4 ) {
4939 if ( !phy.getName().equals( "" ) ) {
4942 if ( !phy.isRooted() ) {
4946 if ( !p.hasNext() ) {
4950 if ( phy == null ) {
4953 if ( phy.getNumberOfExternalNodes() != 5 ) {
4954 System.out.println( phy.getNumberOfExternalNodes() );
4957 if ( !phy.getName().equals( "" ) ) {
4960 if ( !phy.isRooted() ) {
4964 if ( !p.hasNext() ) {
4968 if ( phy == null ) {
4971 if ( phy.getNumberOfExternalNodes() != 3 ) {
4974 if ( !phy.getName().equals( "" ) ) {
4977 if ( phy.isRooted() ) {
4981 if ( !p.hasNext() ) {
4985 if ( phy == null ) {
4988 if ( phy.getNumberOfExternalNodes() != 2 ) {
4991 if ( !phy.getName().equals( "" ) ) {
4994 if ( !phy.isRooted() ) {
4998 if ( !p.hasNext() ) {
5002 if ( phy.getNumberOfExternalNodes() != 3 ) {
5005 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
5008 if ( !phy.isRooted() ) {
5012 if ( !p.hasNext() ) {
5016 if ( phy.getNumberOfExternalNodes() != 3 ) {
5019 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
5022 if ( !phy.getName().equals( "tree 8" ) ) {
5026 if ( !p.hasNext() ) {
5030 if ( phy.getNumberOfExternalNodes() != 3 ) {
5033 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
5036 if ( !phy.getName().equals( "tree 9" ) ) {
5040 if ( !p.hasNext() ) {
5044 if ( phy.getNumberOfExternalNodes() != 3 ) {
5047 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
5050 if ( !phy.getName().equals( "tree 10" ) ) {
5053 if ( !phy.isRooted() ) {
5057 if ( !p.hasNext() ) {
5061 if ( phy.getNumberOfExternalNodes() != 3 ) {
5064 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
5067 if ( !phy.getName().equals( "tree 11" ) ) {
5070 if ( phy.isRooted() ) {
5074 if ( !p.hasNext() ) {
5078 if ( phy.getNumberOfExternalNodes() != 3 ) {
5081 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
5084 if ( !phy.getName().equals( "tree 12" ) ) {
5087 if ( !phy.isRooted() ) {
5091 if ( !p.hasNext() ) {
5095 if ( phy.getNumberOfExternalNodes() != 3 ) {
5098 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
5101 if ( !phy.getName().equals( "tree 13" ) ) {
5104 if ( !phy.isRooted() ) {
5108 if ( !p.hasNext() ) {
5112 if ( phy.getNumberOfExternalNodes() != 10 ) {
5113 System.out.println( phy.getNumberOfExternalNodes() );
5118 .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;" ) ) {
5119 System.out.println( phy.toNewHampshire() );
5122 if ( !phy.getName().equals( "tree 14" ) ) {
5125 if ( !phy.isRooted() ) {
5129 if ( !p.hasNext() ) {
5133 if ( phy.getNumberOfExternalNodes() != 10 ) {
5134 System.out.println( phy.getNumberOfExternalNodes() );
5139 .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;" ) ) {
5140 System.out.println( phy.toNewHampshire() );
5143 if ( !phy.getName().equals( "tree 15" ) ) {
5146 if ( phy.isRooted() ) {
5150 if ( !p.hasNext() ) {
5154 if ( phy.getNumberOfExternalNodes() != 10 ) {
5155 System.out.println( phy.getNumberOfExternalNodes() );
5160 .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;" ) ) {
5161 System.out.println( phy.toNewHampshire() );
5164 if ( !phy.getName().equals( "tree 16" ) ) {
5167 if ( !phy.isRooted() ) {
5171 if ( !p.hasNext() ) {
5175 if ( phy.getNumberOfExternalNodes() != 10 ) {
5176 System.out.println( phy.getNumberOfExternalNodes() );
5181 .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;" ) ) {
5182 System.out.println( phy.toNewHampshire() );
5185 if ( !phy.getName().equals( "tree 17" ) ) {
5188 if ( phy.isRooted() ) {
5192 if ( p.hasNext() ) {
5196 if ( phy != null ) {
5201 if ( !p.hasNext() ) {
5205 if ( phy == null ) {
5208 if ( phy.getNumberOfExternalNodes() != 10 ) {
5211 if ( !phy.getName().equals( "tree 0" ) ) {
5215 if ( !p.hasNext() ) {
5219 if ( phy == null ) {
5222 if ( phy.getNumberOfExternalNodes() != 10 ) {
5225 if ( !phy.getName().equals( "tree 1" ) ) {
5229 if ( !p.hasNext() ) {
5233 if ( phy == null ) {
5236 if ( phy.getNumberOfExternalNodes() != 3 ) {
5239 if ( !phy.getName().equals( "" ) ) {
5242 if ( phy.isRooted() ) {
5246 if ( !p.hasNext() ) {
5250 if ( phy == null ) {
5253 if ( phy.getNumberOfExternalNodes() != 4 ) {
5256 if ( !phy.getName().equals( "" ) ) {
5259 if ( !phy.isRooted() ) {
5263 if ( !p.hasNext() ) {
5267 if ( phy == null ) {
5270 if ( phy.getNumberOfExternalNodes() != 5 ) {
5271 System.out.println( phy.getNumberOfExternalNodes() );
5274 if ( !phy.getName().equals( "" ) ) {
5277 if ( !phy.isRooted() ) {
5281 if ( !p.hasNext() ) {
5285 if ( phy == null ) {
5288 if ( phy.getNumberOfExternalNodes() != 3 ) {
5291 if ( !phy.getName().equals( "" ) ) {
5294 if ( phy.isRooted() ) {
5298 catch ( final Exception e ) {
5299 e.printStackTrace( System.out );
5305 private static boolean testNexusTreeParsingTranslating() {
5307 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5308 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
5309 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
5310 if ( phylogenies.length != 1 ) {
5313 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5316 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
5319 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5322 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5325 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5326 .equals( "Aranaeus" ) ) {
5330 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
5331 if ( phylogenies.length != 3 ) {
5334 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5337 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
5340 if ( phylogenies[ 0 ].isRooted() ) {
5343 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5346 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5349 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5350 .equals( "Aranaeus" ) ) {
5353 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
5356 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
5359 if ( phylogenies[ 1 ].isRooted() ) {
5362 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5365 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5368 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5369 .equals( "Aranaeus" ) ) {
5372 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
5375 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
5378 if ( !phylogenies[ 2 ].isRooted() ) {
5381 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5384 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5387 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5388 .equals( "Aranaeus" ) ) {
5392 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
5393 if ( phylogenies.length != 3 ) {
5396 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5399 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
5402 if ( phylogenies[ 0 ].isRooted() ) {
5405 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5408 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5411 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5412 .equals( "Aranaeus" ) ) {
5415 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
5418 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
5421 if ( phylogenies[ 1 ].isRooted() ) {
5424 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5427 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5430 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5431 .equals( "Aranaeus" ) ) {
5434 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
5437 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
5440 if ( !phylogenies[ 2 ].isRooted() ) {
5443 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5446 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5449 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5450 .equals( "Aranaeus" ) ) {
5454 catch ( final Exception e ) {
5455 e.printStackTrace( System.out );
5461 private static boolean testNHParsing() {
5463 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5464 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
5465 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
5468 final NHXParser nhxp = new NHXParser();
5469 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
5470 nhxp.setReplaceUnderscores( true );
5471 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
5472 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
5475 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
5478 final Phylogeny p1b = factory
5479 .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 ",
5480 new NHXParser() )[ 0 ];
5481 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
5484 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
5487 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
5488 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
5489 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
5490 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
5491 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
5492 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
5493 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
5494 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
5495 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
5496 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
5497 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
5498 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
5499 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
5501 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
5504 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
5507 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
5510 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
5513 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
5514 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
5515 final String p16_S = "((A,B),C)";
5516 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
5517 if ( p16.length != 1 ) {
5520 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
5523 final String p17_S = "(C,(A,B))";
5524 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
5525 if ( p17.length != 1 ) {
5528 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
5531 final String p18_S = "((A,B),(C,D))";
5532 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
5533 if ( p18.length != 1 ) {
5536 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
5539 final String p19_S = "(((A,B),C),D)";
5540 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
5541 if ( p19.length != 1 ) {
5544 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
5547 final String p20_S = "(A,(B,(C,D)))";
5548 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
5549 if ( p20.length != 1 ) {
5552 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
5555 final String p21_S = "(A,(B,(C,(D,E))))";
5556 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
5557 if ( p21.length != 1 ) {
5560 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
5563 final String p22_S = "((((A,B),C),D),E)";
5564 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
5565 if ( p22.length != 1 ) {
5568 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
5571 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
5572 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
5573 if ( p23.length != 1 ) {
5574 System.out.println( "xl=" + p23.length );
5578 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
5581 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
5582 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
5583 if ( p24.length != 1 ) {
5586 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
5589 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
5590 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
5591 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
5592 if ( p241.length != 2 ) {
5595 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
5598 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
5601 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
5602 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
5603 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
5604 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
5605 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
5606 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
5607 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
5608 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
5609 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
5610 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
5613 final String p26_S = "(A,B)ab";
5614 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
5615 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
5618 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
5619 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
5620 if ( p27s.length != 1 ) {
5621 System.out.println( "xxl=" + p27s.length );
5625 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
5626 System.out.println( p27s[ 0 ].toNewHampshireX() );
5630 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
5632 if ( p27.length != 1 ) {
5633 System.out.println( "yl=" + p27.length );
5637 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
5638 System.out.println( p27[ 0 ].toNewHampshireX() );
5642 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
5643 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
5644 final String p28_S3 = "(A,B)ab";
5645 final String p28_S4 = "((((A,B),C),D),;E;)";
5646 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
5648 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
5651 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
5654 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
5657 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
5660 if ( p28.length != 4 ) {
5663 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";
5664 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
5665 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
5668 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";
5669 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
5670 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
5673 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
5674 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
5675 if ( ( p32.length != 0 ) ) {
5678 final String p33_S = "A";
5679 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
5680 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
5683 final String p34_S = "B;";
5684 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
5685 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
5688 final String p35_S = "B:0.2";
5689 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
5690 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
5693 final String p36_S = "(A)";
5694 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
5695 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
5698 final String p37_S = "((A))";
5699 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
5700 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
5703 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
5704 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
5705 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
5708 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
5709 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
5710 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
5713 final String p40_S = "(A,B,C)";
5714 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
5715 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
5718 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
5719 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
5720 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
5723 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
5724 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
5725 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
5728 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)";
5729 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
5730 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
5733 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)))";
5734 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
5735 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
5738 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
5739 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
5740 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
5743 final String p46_S = "";
5744 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
5745 if ( p46.length != 0 ) {
5748 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
5749 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
5752 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
5753 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
5756 final Phylogeny p49 = factory
5757 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
5758 new NHXParser() )[ 0 ];
5759 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
5762 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
5763 if ( p50.getNode( "A" ) == null ) {
5766 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
5767 .equals( "((A,B)ab:2.0[88],C);" ) ) {
5770 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
5773 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
5774 .equals( "((A,B)88:2.0,C);" ) ) {
5777 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
5778 if ( p51.getNode( "A(A" ) == null ) {
5781 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
5782 if ( p52.getNode( "A(A" ) == null ) {
5785 final Phylogeny p53 = factory
5786 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
5787 new NHXParser() )[ 0 ];
5788 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
5792 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
5793 if ( p54.getNode( "A" ) == null ) {
5796 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
5797 .equals( "((A,B)[88],C);" ) ) {
5801 catch ( final Exception e ) {
5802 e.printStackTrace( System.out );
5808 private static boolean testNHParsingIter() {
5810 final String p0_str = "(A,B);";
5811 final NHXParser p = new NHXParser();
5812 p.setSource( p0_str );
5813 if ( !p.hasNext() ) {
5816 final Phylogeny p0 = p.next();
5817 if ( !p0.toNewHampshire().equals( p0_str ) ) {
5818 System.out.println( p0.toNewHampshire() );
5821 if ( p.hasNext() ) {
5824 if ( p.next() != null ) {
5828 final String p00_str = "(A,B)root;";
5829 p.setSource( p00_str );
5830 final Phylogeny p00 = p.next();
5831 if ( !p00.toNewHampshire().equals( p00_str ) ) {
5832 System.out.println( p00.toNewHampshire() );
5836 final String p000_str = "A;";
5837 p.setSource( p000_str );
5838 final Phylogeny p000 = p.next();
5839 if ( !p000.toNewHampshire().equals( p000_str ) ) {
5840 System.out.println( p000.toNewHampshire() );
5844 final String p0000_str = "A";
5845 p.setSource( p0000_str );
5846 final Phylogeny p0000 = p.next();
5847 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
5848 System.out.println( p0000.toNewHampshire() );
5852 p.setSource( "(A)" );
5853 final Phylogeny p00000 = p.next();
5854 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
5855 System.out.println( p00000.toNewHampshire() );
5859 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
5860 p.setSource( p1_str );
5861 if ( !p.hasNext() ) {
5864 final Phylogeny p1_0 = p.next();
5865 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
5866 System.out.println( p1_0.toNewHampshire() );
5869 if ( !p.hasNext() ) {
5872 final Phylogeny p1_1 = p.next();
5873 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
5874 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
5877 if ( !p.hasNext() ) {
5880 final Phylogeny p1_2 = p.next();
5881 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
5882 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
5885 if ( !p.hasNext() ) {
5888 final Phylogeny p1_3 = p.next();
5889 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
5890 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
5893 if ( p.hasNext() ) {
5896 if ( p.next() != null ) {
5900 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
5901 p.setSource( p2_str );
5902 if ( !p.hasNext() ) {
5905 Phylogeny p2_0 = p.next();
5906 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
5907 System.out.println( p2_0.toNewHampshire() );
5910 if ( !p.hasNext() ) {
5913 Phylogeny p2_1 = p.next();
5914 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
5915 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
5918 if ( !p.hasNext() ) {
5921 Phylogeny p2_2 = p.next();
5922 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
5923 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
5926 if ( !p.hasNext() ) {
5929 Phylogeny p2_3 = p.next();
5930 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
5931 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
5934 if ( !p.hasNext() ) {
5937 Phylogeny p2_4 = p.next();
5938 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
5939 System.out.println( "(X) != " + p2_4.toNewHampshire() );
5942 if ( p.hasNext() ) {
5945 if ( p.next() != null ) {
5950 if ( !p.hasNext() ) {
5954 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
5955 System.out.println( p2_0.toNewHampshire() );
5958 if ( !p.hasNext() ) {
5962 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
5963 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
5966 if ( !p.hasNext() ) {
5970 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
5971 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
5974 if ( !p.hasNext() ) {
5978 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
5979 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
5982 if ( !p.hasNext() ) {
5986 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
5987 System.out.println( "(X) != " + p2_4.toNewHampshire() );
5990 if ( p.hasNext() ) {
5993 if ( p.next() != null ) {
5997 final String p3_str = "((A,B),C)abc";
5998 p.setSource( p3_str );
5999 if ( !p.hasNext() ) {
6002 final Phylogeny p3_0 = p.next();
6003 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
6006 if ( p.hasNext() ) {
6009 if ( p.next() != null ) {
6013 final String p4_str = "((A,B)ab,C)abc";
6014 p.setSource( p4_str );
6015 if ( !p.hasNext() ) {
6018 final Phylogeny p4_0 = p.next();
6019 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
6022 if ( p.hasNext() ) {
6025 if ( p.next() != null ) {
6029 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
6030 p.setSource( p5_str );
6031 if ( !p.hasNext() ) {
6034 final Phylogeny p5_0 = p.next();
6035 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
6038 if ( p.hasNext() ) {
6041 if ( p.next() != null ) {
6045 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6046 p.setSource( p6_str );
6047 if ( !p.hasNext() ) {
6050 Phylogeny p6_0 = p.next();
6051 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
6054 if ( p.hasNext() ) {
6057 if ( p.next() != null ) {
6061 if ( !p.hasNext() ) {
6065 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
6068 if ( p.hasNext() ) {
6071 if ( p.next() != null ) {
6075 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6076 p.setSource( p7_str );
6077 if ( !p.hasNext() ) {
6080 Phylogeny p7_0 = p.next();
6081 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
6084 if ( p.hasNext() ) {
6087 if ( p.next() != null ) {
6091 if ( !p.hasNext() ) {
6095 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
6098 if ( p.hasNext() ) {
6101 if ( p.next() != null ) {
6105 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
6106 p.setSource( p8_str );
6107 if ( !p.hasNext() ) {
6110 Phylogeny p8_0 = p.next();
6111 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
6114 if ( !p.hasNext() ) {
6117 if ( !p.hasNext() ) {
6120 Phylogeny p8_1 = p.next();
6121 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
6124 if ( p.hasNext() ) {
6127 if ( p.next() != null ) {
6131 if ( !p.hasNext() ) {
6135 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
6138 if ( !p.hasNext() ) {
6142 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
6145 if ( p.hasNext() ) {
6148 if ( p.next() != null ) {
6154 if ( p.hasNext() ) {
6158 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
6159 if ( !p.hasNext() ) {
6162 Phylogeny p_27 = p.next();
6163 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
6164 System.out.println( p_27.toNewHampshireX() );
6168 if ( p.hasNext() ) {
6171 if ( p.next() != null ) {
6175 if ( !p.hasNext() ) {
6179 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
6180 System.out.println( p_27.toNewHampshireX() );
6184 if ( p.hasNext() ) {
6187 if ( p.next() != null ) {
6191 catch ( final Exception e ) {
6192 e.printStackTrace( System.out );
6198 private static boolean testNHXconversion() {
6200 final PhylogenyNode n1 = new PhylogenyNode();
6201 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
6202 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
6203 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
6204 final PhylogenyNode n5 = PhylogenyNode
6205 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
6206 final PhylogenyNode n6 = PhylogenyNode
6207 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
6208 if ( !n1.toNewHampshireX().equals( "" ) ) {
6211 if ( !n2.toNewHampshireX().equals( "" ) ) {
6214 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
6217 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
6220 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
6223 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
6224 System.out.println( n6.toNewHampshireX() );
6228 catch ( final Exception e ) {
6229 e.printStackTrace( System.out );
6235 private static boolean testTaxonomyExtraction() {
6237 final PhylogenyNode n0 = PhylogenyNode
6238 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6239 if ( n0.getNodeData().isHasTaxonomy() ) {
6242 final PhylogenyNode n1 = PhylogenyNode
6243 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6244 if ( n1.getNodeData().isHasTaxonomy() ) {
6245 System.out.println( n1.toString() );
6248 final PhylogenyNode n2x = PhylogenyNode
6249 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6250 if ( n2x.getNodeData().isHasTaxonomy() ) {
6253 final PhylogenyNode n3 = PhylogenyNode
6254 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6255 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
6256 System.out.println( n3.toString() );
6259 final PhylogenyNode n4 = PhylogenyNode
6260 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6261 if ( n4.getNodeData().isHasTaxonomy() ) {
6262 System.out.println( n4.toString() );
6265 final PhylogenyNode n5 = PhylogenyNode
6266 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6267 if ( n5.getNodeData().isHasTaxonomy() ) {
6268 System.out.println( n5.toString() );
6271 final PhylogenyNode n6 = PhylogenyNode
6272 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6273 if ( n6.getNodeData().isHasTaxonomy() ) {
6274 System.out.println( n6.toString() );
6277 final PhylogenyNode n7 = PhylogenyNode
6278 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6279 if ( n7.getNodeData().isHasTaxonomy() ) {
6280 System.out.println( n7.toString() );
6283 final PhylogenyNode n8 = PhylogenyNode
6284 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6285 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
6286 System.out.println( n8.toString() );
6289 final PhylogenyNode n9 = PhylogenyNode
6290 .createInstanceFromNhxString( "blag_12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6291 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
6292 System.out.println( n9.toString() );
6295 final PhylogenyNode n10x = PhylogenyNode
6296 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6297 if ( n10x.getNodeData().isHasTaxonomy() ) {
6298 System.out.println( n10x.toString() );
6301 final PhylogenyNode n10xx = PhylogenyNode
6302 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6303 if ( n10xx.getNodeData().isHasTaxonomy() ) {
6304 System.out.println( n10xx.toString() );
6307 final PhylogenyNode n10 = PhylogenyNode
6308 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6309 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
6310 System.out.println( n10.toString() );
6313 final PhylogenyNode n11 = PhylogenyNode
6314 .createInstanceFromNhxString( "blag_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6315 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
6316 System.out.println( n11.toString() );
6319 final PhylogenyNode n12 = PhylogenyNode
6320 .createInstanceFromNhxString( "blag_Mus_musculus_musculus",
6321 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6322 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
6323 System.out.println( n12.toString() );
6326 final PhylogenyNode n13 = PhylogenyNode
6327 .createInstanceFromNhxString( "blag_Mus_musculus1",
6328 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6329 if ( n13.getNodeData().isHasTaxonomy() ) {
6330 System.out.println( n13.toString() );
6333 final PhylogenyNode n14 = PhylogenyNode
6334 .createInstanceFromNhxString( "blag_Mus_musculus_11",
6335 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6336 if ( n14.getNodeData().isHasTaxonomy() ) {
6337 System.out.println( n14.toString() );
6340 final PhylogenyNode n15 = PhylogenyNode
6341 .createInstanceFromNhxString( "blag_Mus_musculus_v11",
6342 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6343 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus v11" ) ) {
6344 System.out.println( n15.toString() );
6347 final PhylogenyNode n16 = PhylogenyNode
6348 .createInstanceFromNhxString( "blag_Mus_musculus_/11",
6349 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6350 if ( n16.getNodeData().isHasTaxonomy() ) {
6351 System.out.println( n16.toString() );
6354 final PhylogenyNode n17 = PhylogenyNode
6355 .createInstanceFromNhxString( "blag_Mus_musculus_v",
6356 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6357 if ( n17.getNodeData().isHasTaxonomy() ) {
6358 System.out.println( n17.toString() );
6362 catch ( final Exception e ) {
6363 e.printStackTrace( System.out );
6369 private static boolean testNHXNodeParsing() {
6371 final PhylogenyNode n1 = new PhylogenyNode();
6372 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
6373 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
6374 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
6375 final PhylogenyNode n5 = PhylogenyNode
6376 .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]" );
6377 if ( !n3.getName().equals( "n3" ) ) {
6380 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
6383 if ( n3.isDuplication() ) {
6386 if ( n3.isHasAssignedEvent() ) {
6389 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
6392 if ( !n4.getName().equals( "n4" ) ) {
6395 if ( n4.getDistanceToParent() != 0.01 ) {
6398 if ( !n5.getName().equals( "n5" ) ) {
6401 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
6404 if ( n5.getDistanceToParent() != 0.1 ) {
6407 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
6410 if ( !n5.isDuplication() ) {
6413 if ( !n5.isHasAssignedEvent() ) {
6416 final PhylogenyNode n8 = PhylogenyNode
6417 .createInstanceFromNhxString( "n8_ECOLI/12:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6418 if ( !n8.getName().equals( "n8_ECOLI/12" ) ) {
6421 if ( PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
6424 final PhylogenyNode n9 = PhylogenyNode
6425 .createInstanceFromNhxString( "n9_ECOLI/12=12:0.01",
6426 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6427 if ( !n9.getName().equals( "n9_ECOLI/12=12" ) ) {
6430 if ( PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
6433 final PhylogenyNode n10 = PhylogenyNode
6434 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6435 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
6438 final PhylogenyNode n20 = PhylogenyNode
6439 .createInstanceFromNhxString( "n20_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6440 if ( !n20.getName().equals( "n20_ECOLI/1-2" ) ) {
6443 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
6446 final PhylogenyNode n20x = PhylogenyNode
6447 .createInstanceFromNhxString( "n20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6448 if ( !n20x.getName().equals( "n20_ECOL1/1-2" ) ) {
6451 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
6454 final PhylogenyNode n20xx = PhylogenyNode
6455 .createInstanceFromNhxString( "n20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6456 if ( !n20xx.getName().equals( "n20_eCOL1/1-2" ) ) {
6459 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
6462 final PhylogenyNode n20xxx = PhylogenyNode
6463 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6464 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
6467 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
6470 final PhylogenyNode n20xxxx = PhylogenyNode
6471 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6472 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
6475 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
6478 final PhylogenyNode n21 = PhylogenyNode
6479 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6480 if ( !n21.getName().equals( "n21_PIG" ) ) {
6483 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
6486 final PhylogenyNode n21x = PhylogenyNode
6487 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6488 if ( !n21x.getName().equals( "n21_PIG" ) ) {
6491 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
6494 final PhylogenyNode n22 = PhylogenyNode
6495 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6496 if ( !n22.getName().equals( "n22/PIG" ) ) {
6499 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
6502 final PhylogenyNode n23 = PhylogenyNode
6503 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6504 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
6507 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
6510 final PhylogenyNode a = PhylogenyNode
6511 .createInstanceFromNhxString( "n10_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6512 if ( !a.getName().equals( "n10_ECOLI/1-2" ) ) {
6515 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
6518 final PhylogenyNode b = PhylogenyNode
6519 .createInstanceFromNhxString( "n10_ECOLI1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6520 if ( !b.getName().equals( "n10_ECOLI1/1-2" ) ) {
6523 if ( PhylogenyMethods.getSpecies( b ).equals( "ECOLI" ) ) {
6526 final PhylogenyNode c = PhylogenyNode
6527 .createInstanceFromNhxString( "n10_RATAF12/1000-2000",
6528 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6529 if ( !c.getName().equals( "n10_RATAF12/1000-2000" ) ) {
6532 if ( PhylogenyMethods.getSpecies( c ).equals( "RATAF" ) ) {
6535 final PhylogenyNode c1 = PhylogenyNode
6536 .createInstanceFromNhxString( "n10_BOVIN_1/1000-2000",
6537 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6538 if ( !c1.getName().equals( "n10_BOVIN_1/1000-2000" ) ) {
6541 if ( PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
6544 final PhylogenyNode c2 = PhylogenyNode
6545 .createInstanceFromNhxString( "n10_Bovin_1/1000-2000",
6546 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6547 if ( !c2.getName().equals( "n10_Bovin_1/1000-2000" ) ) {
6550 if ( !PhylogenyMethods.getSpecies( c2 ).equals( "" ) ) {
6553 final PhylogenyNode d = PhylogenyNode
6554 .createInstanceFromNhxString( "n10_RAT1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6555 if ( !d.getName().equals( "n10_RAT1/1-2" ) ) {
6558 if ( PhylogenyMethods.getSpecies( d ).equals( "RAT" ) ) {
6561 final PhylogenyNode e = PhylogenyNode
6562 .createInstanceFromNhxString( "n10_RAT1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6563 if ( !e.getName().equals( "n10_RAT1" ) ) {
6566 if ( !ForesterUtil.isEmpty( PhylogenyMethods.getSpecies( e ) ) ) {
6569 final PhylogenyNode e2 = PhylogenyNode
6570 .createInstanceFromNhxString( "n10_RAT1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6571 if ( !e2.getName().equals( "n10_RAT1" ) ) {
6574 if ( PhylogenyMethods.getSpecies( e2 ).equals( "RAT" ) ) {
6577 final PhylogenyNode e3 = PhylogenyNode
6578 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6579 if ( !e3.getName().equals( "n10_RAT~" ) ) {
6582 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
6585 final PhylogenyNode n11 = PhylogenyNode
6586 .createInstanceFromNhxString( "n111111_ECOLI/jdj:0.4",
6587 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6588 if ( !n11.getName().equals( "n111111_ECOLI/jdj" ) ) {
6591 if ( n11.getDistanceToParent() != 0.4 ) {
6594 if ( PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
6597 final PhylogenyNode n12 = PhylogenyNode
6598 .createInstanceFromNhxString( "n111111-ECOLI---/jdj:0.4",
6599 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6600 if ( !n12.getName().equals( "n111111-ECOLI---/jdj" ) ) {
6603 if ( n12.getDistanceToParent() != 0.4 ) {
6606 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
6609 final PhylogenyNode m = PhylogenyNode
6610 .createInstanceFromNhxString( "n10_MOUSEa", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6611 if ( !m.getName().equals( "n10_MOUSEa" ) ) {
6614 if ( PhylogenyMethods.getSpecies( m ).equals( "MOUSE" ) ) {
6617 final PhylogenyNode o = PhylogenyNode
6618 .createInstanceFromNhxString( "n10_MOUSE_", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6619 if ( !o.getName().equals( "n10_MOUSE_" ) ) {
6622 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
6625 if ( n1.getName().compareTo( "" ) != 0 ) {
6628 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
6631 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
6634 if ( n2.getName().compareTo( "" ) != 0 ) {
6637 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
6640 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
6643 final PhylogenyNode n00 = PhylogenyNode
6644 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
6645 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
6648 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
6651 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
6652 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
6655 final PhylogenyNode n13 = PhylogenyNode
6656 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6657 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
6660 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
6663 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
6666 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
6669 final PhylogenyNode n14 = PhylogenyNode
6670 .createInstanceFromNhxString( "blah_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6671 if ( !n14.getName().equals( "blah_9QX45/1-2" ) ) {
6674 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
6677 final PhylogenyNode n15 = PhylogenyNode
6678 .createInstanceFromNhxString( "something_wicked[123]",
6679 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6680 if ( !n15.getName().equals( "something_wicked" ) ) {
6683 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
6686 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
6689 final PhylogenyNode n16 = PhylogenyNode
6690 .createInstanceFromNhxString( "something_wicked2[9]",
6691 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6692 if ( !n16.getName().equals( "something_wicked2" ) ) {
6695 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
6698 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
6701 final PhylogenyNode n17 = PhylogenyNode
6702 .createInstanceFromNhxString( "something_wicked3[a]",
6703 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6704 if ( !n17.getName().equals( "something_wicked3" ) ) {
6707 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
6710 final PhylogenyNode n18 = PhylogenyNode
6711 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6712 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
6715 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
6718 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
6721 final PhylogenyNode n19 = PhylogenyNode
6722 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6723 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
6726 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
6729 final PhylogenyNode n30 = PhylogenyNode
6730 .createInstanceFromNhxString( "blah_1234567-roejojoej",
6731 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6732 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
6735 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
6738 final PhylogenyNode n31 = PhylogenyNode
6739 .createInstanceFromNhxString( "blah_12345678-roejojoej",
6740 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6741 if ( n31.getNodeData().isHasTaxonomy() ) {
6744 final PhylogenyNode n32 = PhylogenyNode
6745 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6746 if ( n32.getNodeData().isHasTaxonomy() ) {
6749 final PhylogenyNode n40 = PhylogenyNode
6750 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6751 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
6754 final PhylogenyNode n41 = PhylogenyNode
6755 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6756 if ( n41.getNodeData().isHasTaxonomy() ) {
6759 final PhylogenyNode n42 = PhylogenyNode
6760 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6761 if ( n42.getNodeData().isHasTaxonomy() ) {
6764 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
6765 NHXParser.TAXONOMY_EXTRACTION.NO );
6766 if ( n43.getNodeData().isHasTaxonomy() ) {
6769 final PhylogenyNode n44 = PhylogenyNode
6770 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6771 if ( n44.getNodeData().isHasTaxonomy() ) {
6775 catch ( final Exception e ) {
6776 e.printStackTrace( System.out );
6782 private static boolean testNHXParsing() {
6784 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6785 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
6786 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
6789 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]";
6790 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
6791 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
6794 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]";
6795 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
6796 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
6799 final Phylogeny[] p3 = factory
6800 .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]",
6802 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
6805 final Phylogeny[] p4 = factory
6806 .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(]",
6808 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
6811 final Phylogeny[] p5 = factory
6812 .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(((]",
6814 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
6817 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)";
6818 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)";
6819 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
6820 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
6823 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)))";
6824 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)))";
6825 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
6826 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
6829 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]) ))[,,, ])))))))";
6830 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
6831 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
6832 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
6835 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
6836 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
6839 final Phylogeny p10 = factory
6840 .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]",
6841 new NHXParser() )[ 0 ];
6842 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
6846 catch ( final Exception e ) {
6847 e.printStackTrace( System.out );
6853 private static boolean testNHXParsingQuotes() {
6855 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6856 final NHXParser p = new NHXParser();
6857 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
6858 if ( phylogenies_0.length != 5 ) {
6861 final Phylogeny phy = phylogenies_0[ 4 ];
6862 if ( phy.getNumberOfExternalNodes() != 7 ) {
6865 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
6868 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
6871 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
6872 .getScientificName().equals( "hsapiens" ) ) {
6875 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
6878 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
6881 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
6884 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
6887 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
6890 final NHXParser p1p = new NHXParser();
6891 p1p.setIgnoreQuotes( true );
6892 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
6893 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
6896 final NHXParser p2p = new NHXParser();
6897 p1p.setIgnoreQuotes( false );
6898 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
6899 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
6902 final NHXParser p3p = new NHXParser();
6903 p3p.setIgnoreQuotes( false );
6904 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
6905 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
6908 final NHXParser p4p = new NHXParser();
6909 p4p.setIgnoreQuotes( false );
6910 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
6911 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
6914 final Phylogeny p10 = factory
6915 .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]",
6916 new NHXParser() )[ 0 ];
6917 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]";
6918 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
6921 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
6922 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
6926 final Phylogeny p12 = factory
6927 .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]",
6928 new NHXParser() )[ 0 ];
6929 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]";
6930 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
6933 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
6934 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
6937 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;";
6938 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
6941 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
6942 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
6946 catch ( final Exception e ) {
6947 e.printStackTrace( System.out );
6953 private static boolean testNHXParsingMB() {
6955 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6956 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
6957 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
6958 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
6959 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
6960 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
6961 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
6962 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
6963 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
6964 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
6965 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
6968 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
6971 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
6972 0.1100000000000000e+00 ) ) {
6975 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
6978 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
6981 final Phylogeny p2 = factory
6982 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
6983 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
6984 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
6985 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
6986 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
6987 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
6988 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
6989 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
6990 + "7.369400000000000e-02}])",
6991 new NHXParser() )[ 0 ];
6992 if ( p2.getNode( "1" ) == null ) {
6995 if ( p2.getNode( "2" ) == null ) {
6999 catch ( final Exception e ) {
7000 e.printStackTrace( System.out );
7007 private static boolean testPhylogenyBranch() {
7009 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
7010 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
7011 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
7012 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
7013 if ( !a1b1.equals( a1b1 ) ) {
7016 if ( !a1b1.equals( b1a1 ) ) {
7019 if ( !b1a1.equals( a1b1 ) ) {
7022 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
7023 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
7024 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
7025 if ( a1_b1.equals( b1_a1 ) ) {
7028 if ( a1_b1.equals( a1_b1_ ) ) {
7031 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
7032 if ( !a1_b1.equals( b1_a1_ ) ) {
7035 if ( a1_b1_.equals( b1_a1_ ) ) {
7038 if ( !a1_b1_.equals( b1_a1 ) ) {
7042 catch ( final Exception e ) {
7043 e.printStackTrace( System.out );
7049 private static boolean testPhyloXMLparsingOfDistributionElement() {
7051 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7052 PhyloXmlParser xml_parser = null;
7054 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
7056 catch ( final Exception e ) {
7057 // Do nothing -- means were not running from jar.
7059 if ( xml_parser == null ) {
7060 xml_parser = new PhyloXmlParser();
7061 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
7062 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
7065 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
7068 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
7070 if ( xml_parser.getErrorCount() > 0 ) {
7071 System.out.println( xml_parser.getErrorMessages().toString() );
7074 if ( phylogenies_0.length != 1 ) {
7077 final Phylogeny t1 = phylogenies_0[ 0 ];
7078 PhylogenyNode n = null;
7079 Distribution d = null;
7080 n = t1.getNode( "root node" );
7081 if ( !n.getNodeData().isHasDistribution() ) {
7084 if ( n.getNodeData().getDistributions().size() != 1 ) {
7087 d = n.getNodeData().getDistribution();
7088 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
7091 if ( d.getPoints().size() != 1 ) {
7094 if ( d.getPolygons() != null ) {
7097 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
7100 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
7103 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
7106 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
7109 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
7112 n = t1.getNode( "node a" );
7113 if ( !n.getNodeData().isHasDistribution() ) {
7116 if ( n.getNodeData().getDistributions().size() != 2 ) {
7119 d = n.getNodeData().getDistribution( 1 );
7120 if ( !d.getDesc().equals( "San Diego" ) ) {
7123 if ( d.getPoints().size() != 1 ) {
7126 if ( d.getPolygons() != null ) {
7129 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
7132 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
7135 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
7138 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
7141 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
7144 n = t1.getNode( "node bb" );
7145 if ( !n.getNodeData().isHasDistribution() ) {
7148 if ( n.getNodeData().getDistributions().size() != 1 ) {
7151 d = n.getNodeData().getDistribution( 0 );
7152 if ( d.getPoints().size() != 3 ) {
7155 if ( d.getPolygons().size() != 2 ) {
7158 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
7161 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
7164 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
7167 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
7170 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
7173 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
7176 Polygon p = d.getPolygons().get( 0 );
7177 if ( p.getPoints().size() != 3 ) {
7180 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
7183 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
7186 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
7189 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
7192 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
7195 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
7198 p = d.getPolygons().get( 1 );
7199 if ( p.getPoints().size() != 3 ) {
7202 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
7205 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
7208 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
7212 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
7213 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
7214 if ( rt.length != 1 ) {
7217 final Phylogeny t1_rt = rt[ 0 ];
7218 n = t1_rt.getNode( "root node" );
7219 if ( !n.getNodeData().isHasDistribution() ) {
7222 if ( n.getNodeData().getDistributions().size() != 1 ) {
7225 d = n.getNodeData().getDistribution();
7226 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
7229 if ( d.getPoints().size() != 1 ) {
7232 if ( d.getPolygons() != null ) {
7235 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
7238 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
7241 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
7244 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
7247 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
7250 n = t1_rt.getNode( "node a" );
7251 if ( !n.getNodeData().isHasDistribution() ) {
7254 if ( n.getNodeData().getDistributions().size() != 2 ) {
7257 d = n.getNodeData().getDistribution( 1 );
7258 if ( !d.getDesc().equals( "San Diego" ) ) {
7261 if ( d.getPoints().size() != 1 ) {
7264 if ( d.getPolygons() != null ) {
7267 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
7270 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
7273 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
7276 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
7279 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
7282 n = t1_rt.getNode( "node bb" );
7283 if ( !n.getNodeData().isHasDistribution() ) {
7286 if ( n.getNodeData().getDistributions().size() != 1 ) {
7289 d = n.getNodeData().getDistribution( 0 );
7290 if ( d.getPoints().size() != 3 ) {
7293 if ( d.getPolygons().size() != 2 ) {
7296 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
7299 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
7302 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
7305 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
7308 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
7311 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
7314 p = d.getPolygons().get( 0 );
7315 if ( p.getPoints().size() != 3 ) {
7318 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
7321 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
7324 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
7327 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
7330 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
7333 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
7336 p = d.getPolygons().get( 1 );
7337 if ( p.getPoints().size() != 3 ) {
7340 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
7343 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
7346 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
7350 catch ( final Exception e ) {
7351 e.printStackTrace( System.out );
7357 private static boolean testPostOrderIterator() {
7359 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7360 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
7361 PhylogenyNodeIterator it0;
7362 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
7365 for( it0.reset(); it0.hasNext(); ) {
7368 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
7369 final PhylogenyNodeIterator it = t1.iteratorPostorder();
7370 if ( !it.next().getName().equals( "A" ) ) {
7373 if ( !it.next().getName().equals( "B" ) ) {
7376 if ( !it.next().getName().equals( "ab" ) ) {
7379 if ( !it.next().getName().equals( "C" ) ) {
7382 if ( !it.next().getName().equals( "D" ) ) {
7385 if ( !it.next().getName().equals( "cd" ) ) {
7388 if ( !it.next().getName().equals( "abcd" ) ) {
7391 if ( !it.next().getName().equals( "E" ) ) {
7394 if ( !it.next().getName().equals( "F" ) ) {
7397 if ( !it.next().getName().equals( "ef" ) ) {
7400 if ( !it.next().getName().equals( "G" ) ) {
7403 if ( !it.next().getName().equals( "H" ) ) {
7406 if ( !it.next().getName().equals( "gh" ) ) {
7409 if ( !it.next().getName().equals( "efgh" ) ) {
7412 if ( !it.next().getName().equals( "r" ) ) {
7415 if ( it.hasNext() ) {
7419 catch ( final Exception e ) {
7420 e.printStackTrace( System.out );
7426 private static boolean testPreOrderIterator() {
7428 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7429 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
7430 PhylogenyNodeIterator it0;
7431 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
7434 for( it0.reset(); it0.hasNext(); ) {
7437 PhylogenyNodeIterator it = t0.iteratorPreorder();
7438 if ( !it.next().getName().equals( "r" ) ) {
7441 if ( !it.next().getName().equals( "ab" ) ) {
7444 if ( !it.next().getName().equals( "A" ) ) {
7447 if ( !it.next().getName().equals( "B" ) ) {
7450 if ( !it.next().getName().equals( "cd" ) ) {
7453 if ( !it.next().getName().equals( "C" ) ) {
7456 if ( !it.next().getName().equals( "D" ) ) {
7459 if ( it.hasNext() ) {
7462 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
7463 it = t1.iteratorPreorder();
7464 if ( !it.next().getName().equals( "r" ) ) {
7467 if ( !it.next().getName().equals( "abcd" ) ) {
7470 if ( !it.next().getName().equals( "ab" ) ) {
7473 if ( !it.next().getName().equals( "A" ) ) {
7476 if ( !it.next().getName().equals( "B" ) ) {
7479 if ( !it.next().getName().equals( "cd" ) ) {
7482 if ( !it.next().getName().equals( "C" ) ) {
7485 if ( !it.next().getName().equals( "D" ) ) {
7488 if ( !it.next().getName().equals( "efgh" ) ) {
7491 if ( !it.next().getName().equals( "ef" ) ) {
7494 if ( !it.next().getName().equals( "E" ) ) {
7497 if ( !it.next().getName().equals( "F" ) ) {
7500 if ( !it.next().getName().equals( "gh" ) ) {
7503 if ( !it.next().getName().equals( "G" ) ) {
7506 if ( !it.next().getName().equals( "H" ) ) {
7509 if ( it.hasNext() ) {
7513 catch ( final Exception e ) {
7514 e.printStackTrace( System.out );
7520 private static boolean testPropertiesMap() {
7522 final PropertiesMap pm = new PropertiesMap();
7523 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
7524 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
7525 final Property p2 = new Property( "something:else",
7527 "improbable:research",
7530 pm.addProperty( p0 );
7531 pm.addProperty( p1 );
7532 pm.addProperty( p2 );
7533 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
7536 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
7539 if ( pm.getProperties().size() != 3 ) {
7542 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
7545 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
7548 if ( pm.getProperties().size() != 3 ) {
7551 pm.removeProperty( "dimensions:diameter" );
7552 if ( pm.getProperties().size() != 2 ) {
7555 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
7558 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
7562 catch ( final Exception e ) {
7563 e.printStackTrace( System.out );
7569 private static boolean testReIdMethods() {
7571 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7572 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
7573 final long count = PhylogenyNode.getNodeCount();
7575 if ( p.getNode( "r" ).getId() != count ) {
7578 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
7581 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
7584 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
7587 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
7590 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
7593 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
7596 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
7599 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
7602 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
7605 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
7608 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
7611 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
7614 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
7617 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
7621 catch ( final Exception e ) {
7622 e.printStackTrace( System.out );
7628 private static boolean testRerooting() {
7630 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7631 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",
7632 new NHXParser() )[ 0 ];
7633 if ( !t1.isRooted() ) {
7636 t1.reRoot( t1.getNode( "D" ) );
7637 t1.reRoot( t1.getNode( "CD" ) );
7638 t1.reRoot( t1.getNode( "A" ) );
7639 t1.reRoot( t1.getNode( "B" ) );
7640 t1.reRoot( t1.getNode( "AB" ) );
7641 t1.reRoot( t1.getNode( "D" ) );
7642 t1.reRoot( t1.getNode( "C" ) );
7643 t1.reRoot( t1.getNode( "CD" ) );
7644 t1.reRoot( t1.getNode( "A" ) );
7645 t1.reRoot( t1.getNode( "B" ) );
7646 t1.reRoot( t1.getNode( "AB" ) );
7647 t1.reRoot( t1.getNode( "D" ) );
7648 t1.reRoot( t1.getNode( "D" ) );
7649 t1.reRoot( t1.getNode( "C" ) );
7650 t1.reRoot( t1.getNode( "A" ) );
7651 t1.reRoot( t1.getNode( "B" ) );
7652 t1.reRoot( t1.getNode( "AB" ) );
7653 t1.reRoot( t1.getNode( "C" ) );
7654 t1.reRoot( t1.getNode( "D" ) );
7655 t1.reRoot( t1.getNode( "CD" ) );
7656 t1.reRoot( t1.getNode( "D" ) );
7657 t1.reRoot( t1.getNode( "A" ) );
7658 t1.reRoot( t1.getNode( "B" ) );
7659 t1.reRoot( t1.getNode( "AB" ) );
7660 t1.reRoot( t1.getNode( "C" ) );
7661 t1.reRoot( t1.getNode( "D" ) );
7662 t1.reRoot( t1.getNode( "CD" ) );
7663 t1.reRoot( t1.getNode( "D" ) );
7664 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
7667 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
7670 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
7673 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
7676 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
7679 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
7682 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",
7683 new NHXParser() )[ 0 ];
7684 t2.reRoot( t2.getNode( "A" ) );
7685 t2.reRoot( t2.getNode( "D" ) );
7686 t2.reRoot( t2.getNode( "ABC" ) );
7687 t2.reRoot( t2.getNode( "A" ) );
7688 t2.reRoot( t2.getNode( "B" ) );
7689 t2.reRoot( t2.getNode( "D" ) );
7690 t2.reRoot( t2.getNode( "C" ) );
7691 t2.reRoot( t2.getNode( "ABC" ) );
7692 t2.reRoot( t2.getNode( "A" ) );
7693 t2.reRoot( t2.getNode( "B" ) );
7694 t2.reRoot( t2.getNode( "AB" ) );
7695 t2.reRoot( t2.getNode( "AB" ) );
7696 t2.reRoot( t2.getNode( "D" ) );
7697 t2.reRoot( t2.getNode( "C" ) );
7698 t2.reRoot( t2.getNode( "B" ) );
7699 t2.reRoot( t2.getNode( "AB" ) );
7700 t2.reRoot( t2.getNode( "D" ) );
7701 t2.reRoot( t2.getNode( "D" ) );
7702 t2.reRoot( t2.getNode( "ABC" ) );
7703 t2.reRoot( t2.getNode( "A" ) );
7704 t2.reRoot( t2.getNode( "B" ) );
7705 t2.reRoot( t2.getNode( "AB" ) );
7706 t2.reRoot( t2.getNode( "D" ) );
7707 t2.reRoot( t2.getNode( "C" ) );
7708 t2.reRoot( t2.getNode( "ABC" ) );
7709 t2.reRoot( t2.getNode( "A" ) );
7710 t2.reRoot( t2.getNode( "B" ) );
7711 t2.reRoot( t2.getNode( "AB" ) );
7712 t2.reRoot( t2.getNode( "D" ) );
7713 t2.reRoot( t2.getNode( "D" ) );
7714 t2.reRoot( t2.getNode( "C" ) );
7715 t2.reRoot( t2.getNode( "A" ) );
7716 t2.reRoot( t2.getNode( "B" ) );
7717 t2.reRoot( t2.getNode( "AB" ) );
7718 t2.reRoot( t2.getNode( "C" ) );
7719 t2.reRoot( t2.getNode( "D" ) );
7720 t2.reRoot( t2.getNode( "ABC" ) );
7721 t2.reRoot( t2.getNode( "D" ) );
7722 t2.reRoot( t2.getNode( "A" ) );
7723 t2.reRoot( t2.getNode( "B" ) );
7724 t2.reRoot( t2.getNode( "AB" ) );
7725 t2.reRoot( t2.getNode( "C" ) );
7726 t2.reRoot( t2.getNode( "D" ) );
7727 t2.reRoot( t2.getNode( "ABC" ) );
7728 t2.reRoot( t2.getNode( "D" ) );
7729 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7732 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7735 t2.reRoot( t2.getNode( "ABC" ) );
7736 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7739 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7742 t2.reRoot( t2.getNode( "AB" ) );
7743 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7746 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7749 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7752 t2.reRoot( t2.getNode( "AB" ) );
7753 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7756 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7759 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7762 t2.reRoot( t2.getNode( "D" ) );
7763 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7766 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7769 t2.reRoot( t2.getNode( "ABC" ) );
7770 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7773 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7776 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
7777 new NHXParser() )[ 0 ];
7778 t3.reRoot( t3.getNode( "B" ) );
7779 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7782 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7785 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
7788 t3.reRoot( t3.getNode( "B" ) );
7789 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7792 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7795 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
7798 t3.reRoot( t3.getRoot() );
7799 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7802 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7805 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
7809 catch ( final Exception e ) {
7810 e.printStackTrace( System.out );
7816 private static boolean testSDIse() {
7818 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7819 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
7820 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
7821 gene1.setRooted( true );
7822 species1.setRooted( true );
7823 final SDI sdi = new SDI( gene1, species1 );
7824 if ( !gene1.getRoot().isDuplication() ) {
7827 final Phylogeny species2 = factory
7828 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
7829 new NHXParser() )[ 0 ];
7830 final Phylogeny gene2 = factory
7831 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
7832 new NHXParser() )[ 0 ];
7833 species2.setRooted( true );
7834 gene2.setRooted( true );
7835 final SDI sdi2 = new SDI( gene2, species2 );
7836 if ( sdi2.getDuplicationsSum() != 0 ) {
7839 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
7842 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
7845 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
7848 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
7851 if ( !gene2.getNode( "r" ).isSpeciation() ) {
7854 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
7857 final Phylogeny species3 = factory
7858 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
7859 new NHXParser() )[ 0 ];
7860 final Phylogeny gene3 = factory
7861 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
7862 new NHXParser() )[ 0 ];
7863 species3.setRooted( true );
7864 gene3.setRooted( true );
7865 final SDI sdi3 = new SDI( gene3, species3 );
7866 if ( sdi3.getDuplicationsSum() != 1 ) {
7869 if ( !gene3.getNode( "aa" ).isDuplication() ) {
7872 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
7875 final Phylogeny species4 = factory
7876 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
7877 new NHXParser() )[ 0 ];
7878 final Phylogeny gene4 = factory
7879 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
7880 new NHXParser() )[ 0 ];
7881 species4.setRooted( true );
7882 gene4.setRooted( true );
7883 final SDI sdi4 = new SDI( gene4, species4 );
7884 if ( sdi4.getDuplicationsSum() != 1 ) {
7887 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
7890 if ( !gene4.getNode( "abc" ).isDuplication() ) {
7893 if ( gene4.getNode( "abcd" ).isDuplication() ) {
7896 if ( species4.getNumberOfExternalNodes() != 6 ) {
7899 if ( gene4.getNumberOfExternalNodes() != 6 ) {
7902 final Phylogeny species5 = factory
7903 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
7904 new NHXParser() )[ 0 ];
7905 final Phylogeny gene5 = factory
7906 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
7907 new NHXParser() )[ 0 ];
7908 species5.setRooted( true );
7909 gene5.setRooted( true );
7910 final SDI sdi5 = new SDI( gene5, species5 );
7911 if ( sdi5.getDuplicationsSum() != 2 ) {
7914 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
7917 if ( !gene5.getNode( "adc" ).isDuplication() ) {
7920 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
7923 if ( species5.getNumberOfExternalNodes() != 6 ) {
7926 if ( gene5.getNumberOfExternalNodes() != 6 ) {
7929 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
7930 // Conjecture for Comparing Molecular Phylogenies"
7931 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
7932 final Phylogeny species6 = factory
7933 .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,"
7934 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
7935 new NHXParser() )[ 0 ];
7936 final Phylogeny gene6 = factory
7937 .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,"
7938 + "((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,"
7939 + "(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;",
7940 new NHXParser() )[ 0 ];
7941 species6.setRooted( true );
7942 gene6.setRooted( true );
7943 final SDI sdi6 = new SDI( gene6, species6 );
7944 if ( sdi6.getDuplicationsSum() != 3 ) {
7947 if ( !gene6.getNode( "r" ).isDuplication() ) {
7950 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
7953 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
7956 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
7959 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
7962 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
7965 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
7968 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
7971 sdi6.computeMappingCostL();
7972 if ( sdi6.computeMappingCostL() != 17 ) {
7975 if ( species6.getNumberOfExternalNodes() != 9 ) {
7978 if ( gene6.getNumberOfExternalNodes() != 9 ) {
7981 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
7982 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
7983 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
7984 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
7985 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
7986 species7.setRooted( true );
7987 final Phylogeny gene7_1 = Test
7988 .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])" );
7989 gene7_1.setRooted( true );
7990 final SDI sdi7 = new SDI( gene7_1, species7 );
7991 if ( sdi7.getDuplicationsSum() != 0 ) {
7994 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
7997 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
8000 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
8003 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
8006 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
8009 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
8012 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
8015 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
8018 final Phylogeny gene7_2 = Test
8019 .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])" );
8020 gene7_2.setRooted( true );
8021 final SDI sdi7_2 = new SDI( gene7_2, species7 );
8022 if ( sdi7_2.getDuplicationsSum() != 1 ) {
8025 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
8028 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
8031 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
8034 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
8037 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
8040 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
8043 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
8046 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
8049 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
8053 catch ( final Exception e ) {
8059 private static boolean testSDIunrooted() {
8061 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8062 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
8063 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
8064 final Iterator<PhylogenyBranch> iter = l.iterator();
8065 PhylogenyBranch br = iter.next();
8066 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
8069 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
8073 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
8076 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
8080 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
8083 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
8087 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
8090 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
8094 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
8097 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
8101 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
8104 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
8108 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
8111 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
8115 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
8118 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
8122 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
8125 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
8129 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
8132 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
8136 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
8139 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
8143 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
8146 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
8150 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
8153 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
8157 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
8160 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
8164 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
8167 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
8170 if ( iter.hasNext() ) {
8173 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
8174 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
8175 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
8177 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
8180 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
8184 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
8187 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
8191 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
8194 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
8197 if ( iter1.hasNext() ) {
8200 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
8201 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
8202 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
8204 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
8207 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
8211 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
8214 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
8218 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
8221 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
8224 if ( iter2.hasNext() ) {
8227 final Phylogeny species0 = factory
8228 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
8229 new NHXParser() )[ 0 ];
8230 final Phylogeny gene1 = factory
8231 .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])",
8232 new NHXParser() )[ 0 ];
8233 species0.setRooted( true );
8234 gene1.setRooted( true );
8235 final SDIR sdi_unrooted = new SDIR();
8236 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
8237 if ( sdi_unrooted.getCount() != 1 ) {
8240 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
8243 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
8246 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
8249 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
8252 final Phylogeny gene2 = factory
8253 .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])",
8254 new NHXParser() )[ 0 ];
8255 gene2.setRooted( true );
8256 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
8257 if ( sdi_unrooted.getCount() != 1 ) {
8260 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
8263 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
8266 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
8269 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
8272 final Phylogeny species6 = factory
8273 .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,"
8274 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
8275 new NHXParser() )[ 0 ];
8276 final Phylogeny gene6 = factory
8277 .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],"
8278 + "(((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],"
8279 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
8280 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
8281 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
8282 new NHXParser() )[ 0 ];
8283 species6.setRooted( true );
8284 gene6.setRooted( true );
8285 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
8286 if ( sdi_unrooted.getCount() != 1 ) {
8289 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
8292 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
8295 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
8298 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
8301 if ( !p6[ 0 ].getRoot().isDuplication() ) {
8304 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
8307 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
8310 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
8313 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
8316 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
8319 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
8322 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
8326 final Phylogeny species7 = factory
8327 .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,"
8328 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
8329 new NHXParser() )[ 0 ];
8330 final Phylogeny gene7 = factory
8331 .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],"
8332 + "(((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],"
8333 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
8334 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
8335 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
8336 new NHXParser() )[ 0 ];
8337 species7.setRooted( true );
8338 gene7.setRooted( true );
8339 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
8340 if ( sdi_unrooted.getCount() != 1 ) {
8343 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
8346 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
8349 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
8352 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
8355 if ( !p7[ 0 ].getRoot().isDuplication() ) {
8358 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
8361 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
8364 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
8367 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
8370 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
8373 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
8376 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
8380 final Phylogeny species8 = factory
8381 .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,"
8382 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
8383 new NHXParser() )[ 0 ];
8384 final Phylogeny gene8 = factory
8385 .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],"
8386 + "(((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],"
8387 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
8388 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
8389 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
8390 new NHXParser() )[ 0 ];
8391 species8.setRooted( true );
8392 gene8.setRooted( true );
8393 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
8394 if ( sdi_unrooted.getCount() != 1 ) {
8397 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
8400 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
8403 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
8406 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
8409 if ( !p8[ 0 ].getRoot().isDuplication() ) {
8412 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
8415 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
8418 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
8421 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
8424 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
8427 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
8430 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
8435 catch ( final Exception e ) {
8436 e.printStackTrace( System.out );
8442 private static boolean testSplit() {
8444 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8445 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
8446 //Archaeopteryx.createApplication( p0 );
8447 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
8448 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8449 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8450 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8451 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8452 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8453 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8454 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8455 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8456 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8457 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
8458 // System.out.println( s0.toString() );
8460 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
8461 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8462 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8463 if ( s0.match( query_nodes ) ) {
8466 query_nodes = new HashSet<PhylogenyNode>();
8467 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8468 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8469 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8470 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8471 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8472 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8473 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8474 if ( !s0.match( query_nodes ) ) {
8478 query_nodes = new HashSet<PhylogenyNode>();
8479 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8480 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8481 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8482 if ( !s0.match( query_nodes ) ) {
8486 query_nodes = new HashSet<PhylogenyNode>();
8487 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8488 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8489 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8490 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8491 if ( !s0.match( query_nodes ) ) {
8495 query_nodes = new HashSet<PhylogenyNode>();
8496 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8497 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8498 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8499 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8500 if ( !s0.match( query_nodes ) ) {
8504 query_nodes = new HashSet<PhylogenyNode>();
8505 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8506 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8507 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8508 if ( !s0.match( query_nodes ) ) {
8512 query_nodes = new HashSet<PhylogenyNode>();
8513 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8514 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8515 if ( !s0.match( query_nodes ) ) {
8519 query_nodes = new HashSet<PhylogenyNode>();
8520 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8521 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8522 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8523 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8524 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8525 if ( !s0.match( query_nodes ) ) {
8529 query_nodes = new HashSet<PhylogenyNode>();
8530 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8531 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8532 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8533 if ( !s0.match( query_nodes ) ) {
8537 query_nodes = new HashSet<PhylogenyNode>();
8538 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8539 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8540 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8541 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8542 if ( !s0.match( query_nodes ) ) {
8546 query_nodes = new HashSet<PhylogenyNode>();
8547 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8548 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8549 if ( s0.match( query_nodes ) ) {
8553 query_nodes = new HashSet<PhylogenyNode>();
8554 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8555 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8556 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8557 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8558 if ( s0.match( query_nodes ) ) {
8562 query_nodes = new HashSet<PhylogenyNode>();
8563 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8564 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8565 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8566 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8567 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8568 if ( s0.match( query_nodes ) ) {
8572 query_nodes = new HashSet<PhylogenyNode>();
8573 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8574 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8575 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8576 if ( s0.match( query_nodes ) ) {
8580 query_nodes = new HashSet<PhylogenyNode>();
8581 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8582 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8583 if ( s0.match( query_nodes ) ) {
8587 query_nodes = new HashSet<PhylogenyNode>();
8588 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8589 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8590 if ( s0.match( query_nodes ) ) {
8594 query_nodes = new HashSet<PhylogenyNode>();
8595 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8596 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8597 if ( s0.match( query_nodes ) ) {
8601 query_nodes = new HashSet<PhylogenyNode>();
8602 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8603 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8604 if ( s0.match( query_nodes ) ) {
8608 query_nodes = new HashSet<PhylogenyNode>();
8609 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8610 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8611 if ( s0.match( query_nodes ) ) {
8615 query_nodes = new HashSet<PhylogenyNode>();
8616 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8617 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8618 if ( s0.match( query_nodes ) ) {
8622 query_nodes = new HashSet<PhylogenyNode>();
8623 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8624 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8625 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8626 if ( s0.match( query_nodes ) ) {
8630 query_nodes = new HashSet<PhylogenyNode>();
8631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8632 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8633 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8634 if ( s0.match( query_nodes ) ) {
8638 query_nodes = new HashSet<PhylogenyNode>();
8639 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8640 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8641 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8642 if ( s0.match( query_nodes ) ) {
8646 query_nodes = new HashSet<PhylogenyNode>();
8647 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8648 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8649 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8650 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8651 if ( s0.match( query_nodes ) ) {
8655 // query_nodes = new HashSet<PhylogenyNode>();
8656 // query_nodes.add( new PhylogenyNode( "X" ) );
8657 // query_nodes.add( new PhylogenyNode( "Y" ) );
8658 // query_nodes.add( new PhylogenyNode( "A" ) );
8659 // query_nodes.add( new PhylogenyNode( "B" ) );
8660 // query_nodes.add( new PhylogenyNode( "C" ) );
8661 // query_nodes.add( new PhylogenyNode( "D" ) );
8662 // query_nodes.add( new PhylogenyNode( "E" ) );
8663 // query_nodes.add( new PhylogenyNode( "F" ) );
8664 // query_nodes.add( new PhylogenyNode( "G" ) );
8665 // if ( !s0.match( query_nodes ) ) {
8668 // query_nodes = new HashSet<PhylogenyNode>();
8669 // query_nodes.add( new PhylogenyNode( "X" ) );
8670 // query_nodes.add( new PhylogenyNode( "Y" ) );
8671 // query_nodes.add( new PhylogenyNode( "A" ) );
8672 // query_nodes.add( new PhylogenyNode( "B" ) );
8673 // query_nodes.add( new PhylogenyNode( "C" ) );
8674 // if ( !s0.match( query_nodes ) ) {
8678 // query_nodes = new HashSet<PhylogenyNode>();
8679 // query_nodes.add( new PhylogenyNode( "X" ) );
8680 // query_nodes.add( new PhylogenyNode( "Y" ) );
8681 // query_nodes.add( new PhylogenyNode( "D" ) );
8682 // query_nodes.add( new PhylogenyNode( "E" ) );
8683 // query_nodes.add( new PhylogenyNode( "F" ) );
8684 // query_nodes.add( new PhylogenyNode( "G" ) );
8685 // if ( !s0.match( query_nodes ) ) {
8689 // query_nodes = new HashSet<PhylogenyNode>();
8690 // query_nodes.add( new PhylogenyNode( "X" ) );
8691 // query_nodes.add( new PhylogenyNode( "Y" ) );
8692 // query_nodes.add( new PhylogenyNode( "A" ) );
8693 // query_nodes.add( new PhylogenyNode( "B" ) );
8694 // query_nodes.add( new PhylogenyNode( "C" ) );
8695 // query_nodes.add( new PhylogenyNode( "D" ) );
8696 // if ( !s0.match( query_nodes ) ) {
8700 // query_nodes = new HashSet<PhylogenyNode>();
8701 // query_nodes.add( new PhylogenyNode( "X" ) );
8702 // query_nodes.add( new PhylogenyNode( "Y" ) );
8703 // query_nodes.add( new PhylogenyNode( "E" ) );
8704 // query_nodes.add( new PhylogenyNode( "F" ) );
8705 // query_nodes.add( new PhylogenyNode( "G" ) );
8706 // if ( !s0.match( query_nodes ) ) {
8710 // query_nodes = new HashSet<PhylogenyNode>();
8711 // query_nodes.add( new PhylogenyNode( "X" ) );
8712 // query_nodes.add( new PhylogenyNode( "Y" ) );
8713 // query_nodes.add( new PhylogenyNode( "F" ) );
8714 // query_nodes.add( new PhylogenyNode( "G" ) );
8715 // if ( !s0.match( query_nodes ) ) {
8719 query_nodes = new HashSet<PhylogenyNode>();
8720 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8721 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8722 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8723 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8724 if ( s0.match( query_nodes ) ) {
8728 query_nodes = new HashSet<PhylogenyNode>();
8729 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8730 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8731 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8732 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8733 if ( s0.match( query_nodes ) ) {
8736 ///////////////////////////
8738 query_nodes = new HashSet<PhylogenyNode>();
8739 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8740 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8741 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8742 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8743 if ( s0.match( query_nodes ) ) {
8747 query_nodes = new HashSet<PhylogenyNode>();
8748 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8749 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8750 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8751 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8752 if ( s0.match( query_nodes ) ) {
8756 query_nodes = new HashSet<PhylogenyNode>();
8757 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8758 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8759 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8760 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8761 if ( s0.match( query_nodes ) ) {
8765 query_nodes = new HashSet<PhylogenyNode>();
8766 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8767 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8768 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8769 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8770 if ( s0.match( query_nodes ) ) {
8774 query_nodes = new HashSet<PhylogenyNode>();
8775 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8776 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8777 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8778 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8779 if ( s0.match( query_nodes ) ) {
8783 query_nodes = new HashSet<PhylogenyNode>();
8784 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8785 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8786 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8787 if ( s0.match( query_nodes ) ) {
8791 query_nodes = new HashSet<PhylogenyNode>();
8792 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8793 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8794 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8795 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8796 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8797 if ( s0.match( query_nodes ) ) {
8801 query_nodes = new HashSet<PhylogenyNode>();
8802 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8803 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8804 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8805 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8807 if ( s0.match( query_nodes ) ) {
8811 query_nodes = new HashSet<PhylogenyNode>();
8812 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8813 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8814 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8815 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8816 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8817 if ( s0.match( query_nodes ) ) {
8821 query_nodes = new HashSet<PhylogenyNode>();
8822 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8823 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8824 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8825 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8826 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8827 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8828 if ( s0.match( query_nodes ) ) {
8832 catch ( final Exception e ) {
8833 e.printStackTrace();
8839 private static boolean testSplitStrict() {
8841 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8842 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
8843 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
8844 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8845 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8846 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8847 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8848 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8849 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8850 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8851 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
8852 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
8853 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8854 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8855 if ( s0.match( query_nodes ) ) {
8858 query_nodes = new HashSet<PhylogenyNode>();
8859 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8860 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8861 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8862 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8864 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8865 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8866 if ( !s0.match( query_nodes ) ) {
8870 query_nodes = new HashSet<PhylogenyNode>();
8871 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8873 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8874 if ( !s0.match( query_nodes ) ) {
8878 query_nodes = new HashSet<PhylogenyNode>();
8879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8880 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8882 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8883 if ( !s0.match( query_nodes ) ) {
8887 query_nodes = new HashSet<PhylogenyNode>();
8888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8891 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8892 if ( !s0.match( query_nodes ) ) {
8896 query_nodes = new HashSet<PhylogenyNode>();
8897 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8900 if ( !s0.match( query_nodes ) ) {
8904 query_nodes = new HashSet<PhylogenyNode>();
8905 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8906 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8907 if ( !s0.match( query_nodes ) ) {
8911 query_nodes = new HashSet<PhylogenyNode>();
8912 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8913 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8914 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8915 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8916 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8917 if ( !s0.match( query_nodes ) ) {
8921 query_nodes = new HashSet<PhylogenyNode>();
8922 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8923 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8924 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8925 if ( !s0.match( query_nodes ) ) {
8929 query_nodes = new HashSet<PhylogenyNode>();
8930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8931 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8932 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8933 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8934 if ( !s0.match( query_nodes ) ) {
8938 query_nodes = new HashSet<PhylogenyNode>();
8939 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8940 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8941 if ( s0.match( query_nodes ) ) {
8945 query_nodes = new HashSet<PhylogenyNode>();
8946 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8947 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8948 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8949 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8950 if ( s0.match( query_nodes ) ) {
8954 query_nodes = new HashSet<PhylogenyNode>();
8955 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8956 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8957 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8958 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8959 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8960 if ( s0.match( query_nodes ) ) {
8964 query_nodes = new HashSet<PhylogenyNode>();
8965 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8966 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8968 if ( s0.match( query_nodes ) ) {
8972 query_nodes = new HashSet<PhylogenyNode>();
8973 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8974 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8975 if ( s0.match( query_nodes ) ) {
8979 query_nodes = new HashSet<PhylogenyNode>();
8980 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8981 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8982 if ( s0.match( query_nodes ) ) {
8986 query_nodes = new HashSet<PhylogenyNode>();
8987 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8988 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8989 if ( s0.match( query_nodes ) ) {
8993 query_nodes = new HashSet<PhylogenyNode>();
8994 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8995 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8996 if ( s0.match( query_nodes ) ) {
9000 query_nodes = new HashSet<PhylogenyNode>();
9001 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9002 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9003 if ( s0.match( query_nodes ) ) {
9007 query_nodes = new HashSet<PhylogenyNode>();
9008 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9009 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9010 if ( s0.match( query_nodes ) ) {
9014 query_nodes = new HashSet<PhylogenyNode>();
9015 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9016 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9017 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9018 if ( s0.match( query_nodes ) ) {
9022 query_nodes = new HashSet<PhylogenyNode>();
9023 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9024 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9025 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9026 if ( s0.match( query_nodes ) ) {
9030 query_nodes = new HashSet<PhylogenyNode>();
9031 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9032 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9033 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9034 if ( s0.match( query_nodes ) ) {
9038 query_nodes = new HashSet<PhylogenyNode>();
9039 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9040 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9041 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9042 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9043 if ( s0.match( query_nodes ) ) {
9047 catch ( final Exception e ) {
9048 e.printStackTrace();
9054 private static boolean testSubtreeDeletion() {
9056 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9057 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
9058 t1.deleteSubtree( t1.getNode( "A" ), false );
9059 if ( t1.getNumberOfExternalNodes() != 5 ) {
9062 t1.toNewHampshireX();
9063 t1.deleteSubtree( t1.getNode( "E" ), false );
9064 if ( t1.getNumberOfExternalNodes() != 4 ) {
9067 t1.toNewHampshireX();
9068 t1.deleteSubtree( t1.getNode( "F" ), false );
9069 if ( t1.getNumberOfExternalNodes() != 3 ) {
9072 t1.toNewHampshireX();
9073 t1.deleteSubtree( t1.getNode( "D" ), false );
9074 t1.toNewHampshireX();
9075 if ( t1.getNumberOfExternalNodes() != 3 ) {
9078 t1.deleteSubtree( t1.getNode( "def" ), false );
9079 t1.toNewHampshireX();
9080 if ( t1.getNumberOfExternalNodes() != 2 ) {
9083 t1.deleteSubtree( t1.getNode( "B" ), false );
9084 t1.toNewHampshireX();
9085 if ( t1.getNumberOfExternalNodes() != 1 ) {
9088 t1.deleteSubtree( t1.getNode( "C" ), false );
9089 t1.toNewHampshireX();
9090 if ( t1.getNumberOfExternalNodes() != 1 ) {
9093 t1.deleteSubtree( t1.getNode( "abc" ), false );
9094 t1.toNewHampshireX();
9095 if ( t1.getNumberOfExternalNodes() != 1 ) {
9098 t1.deleteSubtree( t1.getNode( "r" ), false );
9099 if ( t1.getNumberOfExternalNodes() != 0 ) {
9102 if ( !t1.isEmpty() ) {
9105 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
9106 t2.deleteSubtree( t2.getNode( "A" ), false );
9107 t2.toNewHampshireX();
9108 if ( t2.getNumberOfExternalNodes() != 5 ) {
9111 t2.deleteSubtree( t2.getNode( "abc" ), false );
9112 t2.toNewHampshireX();
9113 if ( t2.getNumberOfExternalNodes() != 3 ) {
9116 t2.deleteSubtree( t2.getNode( "def" ), false );
9117 t2.toNewHampshireX();
9118 if ( t2.getNumberOfExternalNodes() != 1 ) {
9122 catch ( final Exception e ) {
9123 e.printStackTrace( System.out );
9129 private static boolean testSupportCount() {
9131 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9132 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
9133 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
9134 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
9135 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
9136 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
9137 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
9139 SupportCount.count( t0_1, phylogenies_1, true, false );
9140 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
9141 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
9142 + "(((((A,B),C),D),E),((F,G),X))"
9143 + "(((((A,Y),B),C),D),((F,G),E))"
9144 + "(((((A,B),C),D),E),(F,G))"
9145 + "(((((A,B),C),D),E),(F,G))"
9146 + "(((((A,B),C),D),E),(F,G))"
9147 + "(((((A,B),C),D),E),(F,G),Z)"
9148 + "(((((A,B),C),D),E),(F,G))"
9149 + "((((((A,B),C),D),E),F),G)"
9150 + "(((((X,Y),F,G),E),((A,B),C)),D)",
9152 SupportCount.count( t0_2, phylogenies_2, true, false );
9153 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
9154 while ( it.hasNext() ) {
9155 final PhylogenyNode n = it.next();
9156 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
9160 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
9161 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
9162 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
9163 SupportCount.count( t0_3, phylogenies_3, true, false );
9164 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
9165 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
9168 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
9171 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
9174 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
9177 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
9180 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
9183 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
9186 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
9189 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
9192 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
9195 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9196 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
9197 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
9198 SupportCount.count( t0_4, phylogenies_4, true, false );
9199 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
9200 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
9203 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
9206 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
9209 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
9212 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
9215 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
9218 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
9221 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
9224 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
9227 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
9230 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9231 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9232 double d = SupportCount.compare( b1, a, true, true, true );
9233 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
9236 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9237 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9238 d = SupportCount.compare( b2, a, true, true, true );
9239 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
9242 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9243 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
9244 d = SupportCount.compare( b3, a, true, true, true );
9245 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
9248 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
9249 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
9250 d = SupportCount.compare( b4, a, true, true, false );
9251 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
9255 catch ( final Exception e ) {
9256 e.printStackTrace( System.out );
9262 private static boolean testSupportTransfer() {
9264 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9265 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)",
9266 new NHXParser() )[ 0 ];
9267 final Phylogeny p2 = factory
9268 .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 ];
9269 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
9272 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
9275 support_transfer.moveBranchLengthsToBootstrap( p1 );
9276 support_transfer.transferSupportValues( p1, p2 );
9277 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
9280 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
9283 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
9286 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
9289 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
9292 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
9295 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
9298 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
9302 catch ( final Exception e ) {
9303 e.printStackTrace( System.out );
9309 private static boolean testUniprotTaxonomySearch() {
9311 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
9313 if ( results.size() != 1 ) {
9316 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
9319 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
9322 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
9325 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
9328 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
9332 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
9333 if ( results.size() != 1 ) {
9336 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
9339 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
9342 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
9345 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
9348 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
9352 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
9353 if ( results.size() != 1 ) {
9356 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
9359 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
9362 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
9365 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
9368 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
9372 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
9373 if ( results.size() != 1 ) {
9376 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
9379 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
9382 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
9385 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
9388 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
9391 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
9394 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
9397 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
9398 .equals( "Nematostella vectensis" ) ) {
9399 System.out.println( results.get( 0 ).getLineage() );
9403 catch ( final IOException e ) {
9404 System.out.println();
9405 System.out.println( "the following might be due to absence internet connection:" );
9406 e.printStackTrace( System.out );
9409 catch ( final Exception e ) {
9415 private static boolean testEmblEntryRetrieval() {
9416 //The format for GenBank Accession numbers are:
9417 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
9418 //Protein: 3 letters + 5 numerals
9419 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
9420 if ( !SequenceIdParser.parseGenbankAccessor( "AY423861" ).equals( "AY423861" ) ) {
9423 if ( !SequenceIdParser.parseGenbankAccessor( ".AY423861.2" ).equals( "AY423861.2" ) ) {
9426 if ( !SequenceIdParser.parseGenbankAccessor( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
9429 if ( SequenceIdParser.parseGenbankAccessor( "AAY423861" ) != null ) {
9432 if ( SequenceIdParser.parseGenbankAccessor( "AY4238612" ) != null ) {
9435 if ( SequenceIdParser.parseGenbankAccessor( "AAY4238612" ) != null ) {
9438 if ( SequenceIdParser.parseGenbankAccessor( "Y423861" ) != null ) {
9441 if ( !SequenceIdParser.parseGenbankAccessor( "S12345" ).equals( "S12345" ) ) {
9444 if ( !SequenceIdParser.parseGenbankAccessor( "|S12345|" ).equals( "S12345" ) ) {
9447 if ( SequenceIdParser.parseGenbankAccessor( "|S123456" ) != null ) {
9450 if ( SequenceIdParser.parseGenbankAccessor( "ABC123456" ) != null ) {
9453 if ( !SequenceIdParser.parseGenbankAccessor( "ABC12345" ).equals( "ABC12345" ) ) {
9456 if ( !SequenceIdParser.parseGenbankAccessor( "&ABC12345&" ).equals( "ABC12345" ) ) {
9459 if ( SequenceIdParser.parseGenbankAccessor( "ABCD12345" ) != null ) {
9465 private static boolean testUniprotEntryRetrieval() {
9467 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
9468 if ( !entry.getAccession().equals( "P12345" ) ) {
9471 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
9474 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
9477 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
9481 catch ( final IOException e ) {
9482 System.out.println();
9483 System.out.println( "the following might be due to absence internet connection:" );
9484 e.printStackTrace( System.out );
9487 catch ( final Exception e ) {
9493 private static boolean testWabiTxSearch() {
9496 result = TxSearch.searchSimple( "nematostella" );
9497 result = TxSearch.getTxId( "nematostella" );
9498 if ( !result.equals( "45350" ) ) {
9501 result = TxSearch.getTxName( "45350" );
9502 if ( !result.equals( "Nematostella" ) ) {
9505 result = TxSearch.getTxId( "nematostella vectensis" );
9506 if ( !result.equals( "45351" ) ) {
9509 result = TxSearch.getTxName( "45351" );
9510 if ( !result.equals( "Nematostella vectensis" ) ) {
9513 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
9514 if ( !result.equals( "536089" ) ) {
9517 result = TxSearch.getTxName( "536089" );
9518 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
9521 final List<String> queries = new ArrayList<String>();
9522 queries.add( "Campylobacter coli" );
9523 queries.add( "Escherichia coli" );
9524 queries.add( "Arabidopsis" );
9525 queries.add( "Trichoplax" );
9526 queries.add( "Samanea saman" );
9527 queries.add( "Kluyveromyces marxianus" );
9528 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
9529 queries.add( "Bornavirus parrot/PDD/2008" );
9530 final List<RANKS> ranks = new ArrayList<RANKS>();
9531 ranks.add( RANKS.SUPERKINGDOM );
9532 ranks.add( RANKS.KINGDOM );
9533 ranks.add( RANKS.FAMILY );
9534 ranks.add( RANKS.GENUS );
9535 ranks.add( RANKS.TRIBE );
9536 result = TxSearch.searchLineage( queries, ranks );
9537 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
9538 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
9540 catch ( final Exception e ) {
9541 System.out.println();
9542 System.out.println( "the following might be due to absence internet connection:" );
9543 e.printStackTrace( System.out );
9549 private static boolean testAminoAcidSequence() {
9551 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
9552 if ( aa1.getLength() != 13 ) {
9555 if ( aa1.getResidueAt( 0 ) != 'A' ) {
9558 if ( aa1.getResidueAt( 2 ) != 'K' ) {
9561 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
9564 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
9565 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
9568 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
9569 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
9572 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
9573 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
9577 catch ( final Exception e ) {
9578 e.printStackTrace();
9584 private static boolean testSequenceWriter() {
9586 final String n = ForesterUtil.LINE_SEPARATOR;
9587 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
9590 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
9593 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
9596 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
9599 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
9600 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
9603 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
9604 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
9608 catch ( final Exception e ) {
9609 e.printStackTrace();
9615 private static boolean testCreateBalancedPhylogeny() {
9617 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
9618 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
9621 if ( p0.getNumberOfExternalNodes() != 15625 ) {
9624 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
9625 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
9628 if ( p1.getNumberOfExternalNodes() != 100 ) {
9632 catch ( final Exception e ) {
9633 e.printStackTrace();
9639 private static boolean testFastaParser() {
9641 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
9644 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
9647 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
9648 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
9651 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
9654 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
9657 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
9660 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
9663 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
9667 catch ( final Exception e ) {
9668 e.printStackTrace();
9674 private static boolean testGeneralMsaParser() {
9676 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
9677 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
9678 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
9679 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
9680 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
9681 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
9682 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
9683 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
9684 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
9687 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
9690 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
9693 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
9696 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
9699 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
9702 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
9705 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
9708 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
9711 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
9714 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
9717 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
9720 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
9721 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
9724 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
9727 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
9730 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
9731 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
9734 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
9737 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
9740 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
9741 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
9744 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
9747 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
9751 catch ( final Exception e ) {
9752 e.printStackTrace();
9758 private static boolean testMafft( final String path ) {
9760 final List<String> opts = new ArrayList<String>();
9761 opts.add( "--maxiterate" );
9763 opts.add( "--localpair" );
9764 opts.add( "--quiet" );
9766 final MsaInferrer mafft = Mafft.createInstance( path );
9767 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
9768 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
9771 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
9775 catch ( final Exception e ) {
9776 e.printStackTrace( System.out );
9782 private static boolean testNextNodeWithCollapsing() {
9784 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9786 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
9787 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
9788 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
9789 t0.getNode( "cd" ).setCollapse( true );
9790 t0.getNode( "cde" ).setCollapse( true );
9791 n = t0.getFirstExternalNode();
9792 while ( n != null ) {
9794 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
9796 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
9799 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
9802 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
9805 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
9808 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
9811 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
9815 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
9816 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
9817 t1.getNode( "ab" ).setCollapse( true );
9818 t1.getNode( "cd" ).setCollapse( true );
9819 t1.getNode( "cde" ).setCollapse( true );
9820 n = t1.getNode( "ab" );
9821 ext = new ArrayList<PhylogenyNode>();
9822 while ( n != null ) {
9824 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
9826 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
9829 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
9832 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
9835 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
9838 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
9844 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
9845 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
9846 t2.getNode( "ab" ).setCollapse( true );
9847 t2.getNode( "cd" ).setCollapse( true );
9848 t2.getNode( "cde" ).setCollapse( true );
9849 t2.getNode( "c" ).setCollapse( true );
9850 t2.getNode( "d" ).setCollapse( true );
9851 t2.getNode( "e" ).setCollapse( true );
9852 t2.getNode( "gh" ).setCollapse( true );
9853 n = t2.getNode( "ab" );
9854 ext = new ArrayList<PhylogenyNode>();
9855 while ( n != null ) {
9857 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
9859 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
9862 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
9865 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
9868 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
9874 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
9875 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
9876 t3.getNode( "ab" ).setCollapse( true );
9877 t3.getNode( "cd" ).setCollapse( true );
9878 t3.getNode( "cde" ).setCollapse( true );
9879 t3.getNode( "c" ).setCollapse( true );
9880 t3.getNode( "d" ).setCollapse( true );
9881 t3.getNode( "e" ).setCollapse( true );
9882 t3.getNode( "gh" ).setCollapse( true );
9883 t3.getNode( "fgh" ).setCollapse( true );
9884 n = t3.getNode( "ab" );
9885 ext = new ArrayList<PhylogenyNode>();
9886 while ( n != null ) {
9888 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
9890 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
9893 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
9896 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
9902 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
9903 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
9904 t4.getNode( "ab" ).setCollapse( true );
9905 t4.getNode( "cd" ).setCollapse( true );
9906 t4.getNode( "cde" ).setCollapse( true );
9907 t4.getNode( "c" ).setCollapse( true );
9908 t4.getNode( "d" ).setCollapse( true );
9909 t4.getNode( "e" ).setCollapse( true );
9910 t4.getNode( "gh" ).setCollapse( true );
9911 t4.getNode( "fgh" ).setCollapse( true );
9912 t4.getNode( "abcdefgh" ).setCollapse( true );
9913 n = t4.getNode( "abcdefgh" );
9914 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
9919 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
9920 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
9922 n = t5.getFirstExternalNode();
9923 while ( n != null ) {
9925 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
9927 if ( ext.size() != 8 ) {
9930 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
9933 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
9936 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
9939 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
9942 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
9945 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
9948 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
9951 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
9956 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
9957 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
9959 t6.getNode( "ab" ).setCollapse( true );
9960 n = t6.getNode( "ab" );
9961 while ( n != null ) {
9963 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
9965 if ( ext.size() != 7 ) {
9968 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
9971 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
9974 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
9977 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
9980 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
9983 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
9986 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
9991 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
9992 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
9994 t7.getNode( "cd" ).setCollapse( true );
9995 n = t7.getNode( "a" );
9996 while ( n != null ) {
9998 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10000 if ( ext.size() != 7 ) {
10003 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10006 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10009 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
10012 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
10015 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
10018 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
10021 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
10026 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
10027 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
10029 t8.getNode( "cd" ).setCollapse( true );
10030 t8.getNode( "c" ).setCollapse( true );
10031 t8.getNode( "d" ).setCollapse( true );
10032 n = t8.getNode( "a" );
10033 while ( n != null ) {
10035 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10037 if ( ext.size() != 7 ) {
10040 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10043 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10046 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
10047 System.out.println( "2 fail" );
10050 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
10053 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
10056 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
10059 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
10064 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
10065 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
10067 t9.getNode( "gh" ).setCollapse( true );
10068 n = t9.getNode( "a" );
10069 while ( n != null ) {
10071 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10073 if ( ext.size() != 7 ) {
10076 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10079 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10082 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
10085 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
10088 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
10091 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
10094 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
10099 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
10100 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
10102 t10.getNode( "gh" ).setCollapse( true );
10103 t10.getNode( "g" ).setCollapse( true );
10104 t10.getNode( "h" ).setCollapse( true );
10105 n = t10.getNode( "a" );
10106 while ( n != null ) {
10108 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10110 if ( ext.size() != 7 ) {
10113 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10116 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10119 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
10122 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
10125 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
10128 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
10131 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
10136 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
10137 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
10139 t11.getNode( "gh" ).setCollapse( true );
10140 t11.getNode( "fgh" ).setCollapse( true );
10141 n = t11.getNode( "a" );
10142 while ( n != null ) {
10144 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10146 if ( ext.size() != 6 ) {
10149 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10152 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10155 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
10158 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
10161 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
10164 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
10169 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
10170 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
10172 t12.getNode( "gh" ).setCollapse( true );
10173 t12.getNode( "fgh" ).setCollapse( true );
10174 t12.getNode( "g" ).setCollapse( true );
10175 t12.getNode( "h" ).setCollapse( true );
10176 t12.getNode( "f" ).setCollapse( true );
10177 n = t12.getNode( "a" );
10178 while ( n != null ) {
10180 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10182 if ( ext.size() != 6 ) {
10185 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10188 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10191 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
10194 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
10197 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
10200 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
10205 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
10206 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
10208 t13.getNode( "ab" ).setCollapse( true );
10209 t13.getNode( "b" ).setCollapse( true );
10210 t13.getNode( "fgh" ).setCollapse( true );
10211 t13.getNode( "gh" ).setCollapse( true );
10212 n = t13.getNode( "ab" );
10213 while ( n != null ) {
10215 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10217 if ( ext.size() != 5 ) {
10220 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
10223 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
10226 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
10229 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
10232 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
10237 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
10238 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
10240 t14.getNode( "ab" ).setCollapse( true );
10241 t14.getNode( "a" ).setCollapse( true );
10242 t14.getNode( "fgh" ).setCollapse( true );
10243 t14.getNode( "gh" ).setCollapse( true );
10244 n = t14.getNode( "ab" );
10245 while ( n != null ) {
10247 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10249 if ( ext.size() != 5 ) {
10252 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
10255 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
10258 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
10261 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
10264 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
10269 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" );
10270 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
10272 t15.getNode( "ab" ).setCollapse( true );
10273 t15.getNode( "a" ).setCollapse( true );
10274 t15.getNode( "fgh" ).setCollapse( true );
10275 t15.getNode( "gh" ).setCollapse( true );
10276 n = t15.getNode( "ab" );
10277 while ( n != null ) {
10279 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10281 if ( ext.size() != 6 ) {
10284 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
10287 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
10290 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
10293 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
10296 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
10299 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
10304 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" );
10305 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
10307 t16.getNode( "ab" ).setCollapse( true );
10308 t16.getNode( "a" ).setCollapse( true );
10309 t16.getNode( "fgh" ).setCollapse( true );
10310 t16.getNode( "gh" ).setCollapse( true );
10311 t16.getNode( "cd" ).setCollapse( true );
10312 t16.getNode( "cde" ).setCollapse( true );
10313 t16.getNode( "d" ).setCollapse( true );
10314 t16.getNode( "x" ).setCollapse( true );
10315 n = t16.getNode( "ab" );
10316 while ( n != null ) {
10318 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10320 if ( ext.size() != 4 ) {
10323 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
10326 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
10329 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
10332 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
10336 catch ( final Exception e ) {
10337 e.printStackTrace( System.out );
10343 private static boolean testMsaQualityMethod() {
10345 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
10346 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
10347 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
10348 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
10349 final List<Sequence> l = new ArrayList<Sequence>();
10354 final Msa msa = BasicMsa.createInstance( l );
10355 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
10358 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
10361 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
10364 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
10368 catch ( final Exception e ) {
10369 e.printStackTrace( System.out );
10375 private static boolean testSequenceIdParsing() {
10377 Identifier id = SequenceIdParser.parse( "gb_ADF31344_segmented_worms_" );
10378 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10379 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
10380 if ( id != null ) {
10381 System.out.println( "value =" + id.getValue() );
10382 System.out.println( "provider=" + id.getProvider() );
10387 id = SequenceIdParser.parse( "segmented worms|gb_ADF31344" );
10388 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10389 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
10390 if ( id != null ) {
10391 System.out.println( "value =" + id.getValue() );
10392 System.out.println( "provider=" + id.getProvider() );
10397 id = SequenceIdParser.parse( "segmented worms gb_ADF31344 and more" );
10398 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10399 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
10400 if ( id != null ) {
10401 System.out.println( "value =" + id.getValue() );
10402 System.out.println( "provider=" + id.getProvider() );
10407 id = SequenceIdParser.parse( "gb_AAA96518_1" );
10408 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10409 || !id.getValue().equals( "AAA96518" ) || !id.getProvider().equals( "ncbi" ) ) {
10410 if ( id != null ) {
10411 System.out.println( "value =" + id.getValue() );
10412 System.out.println( "provider=" + id.getProvider() );
10417 id = SequenceIdParser.parse( "gb_EHB07727_1_rodents_" );
10418 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10419 || !id.getValue().equals( "EHB07727" ) || !id.getProvider().equals( "ncbi" ) ) {
10420 if ( id != null ) {
10421 System.out.println( "value =" + id.getValue() );
10422 System.out.println( "provider=" + id.getProvider() );
10427 id = SequenceIdParser.parse( "dbj_BAF37827_1_turtles_" );
10428 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10429 || !id.getValue().equals( "BAF37827" ) || !id.getProvider().equals( "ncbi" ) ) {
10430 if ( id != null ) {
10431 System.out.println( "value =" + id.getValue() );
10432 System.out.println( "provider=" + id.getProvider() );
10437 id = SequenceIdParser.parse( "emb_CAA73223_1_primates_" );
10438 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10439 || !id.getValue().equals( "CAA73223" ) || !id.getProvider().equals( "ncbi" ) ) {
10440 if ( id != null ) {
10441 System.out.println( "value =" + id.getValue() );
10442 System.out.println( "provider=" + id.getProvider() );
10447 id = SequenceIdParser.parse( "mites|ref_XP_002434188_1" );
10448 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10449 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
10450 if ( id != null ) {
10451 System.out.println( "value =" + id.getValue() );
10452 System.out.println( "provider=" + id.getProvider() );
10457 id = SequenceIdParser.parse( "mites_ref_XP_002434188_1_bla_XP_12345" );
10458 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10459 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
10460 if ( id != null ) {
10461 System.out.println( "value =" + id.getValue() );
10462 System.out.println( "provider=" + id.getProvider() );
10467 id = SequenceIdParser.parse( "P4A123" );
10468 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10469 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
10470 if ( id != null ) {
10471 System.out.println( "value =" + id.getValue() );
10472 System.out.println( "provider=" + id.getProvider() );
10477 id = SequenceIdParser.parse( "pllf[pok P4A123_osdjfosnqo035-9233332904i000490 vf tmv x45" );
10478 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10479 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
10480 if ( id != null ) {
10481 System.out.println( "value =" + id.getValue() );
10482 System.out.println( "provider=" + id.getProvider() );
10487 id = SequenceIdParser.parse( "XP_12345" );
10488 if ( id != null ) {
10489 System.out.println( "value =" + id.getValue() );
10490 System.out.println( "provider=" + id.getProvider() );
10493 // lcl_91970_unknown_
10495 catch ( final Exception e ) {
10496 e.printStackTrace( System.out );