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: www.phylosoft.org/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.datastructures.IntMatrix;
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.phyloxml.PhyloXmlParser;
56 import org.forester.io.parsers.tol.TolParser;
57 import org.forester.io.writers.PhylogenyWriter;
58 import org.forester.msa.BasicMsa;
59 import org.forester.msa.Mafft;
60 import org.forester.msa.Msa;
61 import org.forester.msa.MsaInferrer;
62 import org.forester.msa.MsaMethods;
63 import org.forester.pccx.TestPccx;
64 import org.forester.phylogeny.Phylogeny;
65 import org.forester.phylogeny.PhylogenyBranch;
66 import org.forester.phylogeny.PhylogenyMethods;
67 import org.forester.phylogeny.PhylogenyMethods.TAXONOMY_EXTRACTION;
68 import org.forester.phylogeny.PhylogenyNode;
69 import org.forester.phylogeny.PhylogenyNodeI.NH_CONVERSION_SUPPORT_VALUE_STYLE;
70 import org.forester.phylogeny.data.BinaryCharacters;
71 import org.forester.phylogeny.data.BranchWidth;
72 import org.forester.phylogeny.data.Confidence;
73 import org.forester.phylogeny.data.Distribution;
74 import org.forester.phylogeny.data.DomainArchitecture;
75 import org.forester.phylogeny.data.Event;
76 import org.forester.phylogeny.data.Identifier;
77 import org.forester.phylogeny.data.PhylogenyData;
78 import org.forester.phylogeny.data.PhylogenyDataUtil;
79 import org.forester.phylogeny.data.Polygon;
80 import org.forester.phylogeny.data.PropertiesMap;
81 import org.forester.phylogeny.data.Property;
82 import org.forester.phylogeny.data.Property.AppliesTo;
83 import org.forester.phylogeny.data.ProteinDomain;
84 import org.forester.phylogeny.data.Taxonomy;
85 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
86 import org.forester.phylogeny.factories.PhylogenyFactory;
87 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
88 import org.forester.protein.Protein;
89 import org.forester.sdi.GSDI;
90 import org.forester.sdi.RIO;
91 import org.forester.sdi.SDI;
92 import org.forester.sdi.SDIR;
93 import org.forester.sdi.SDIse;
94 import org.forester.sdi.TestGSDI;
95 import org.forester.sequence.BasicSequence;
96 import org.forester.sequence.Sequence;
97 import org.forester.surfacing.TestSurfacing;
98 import org.forester.tools.ConfidenceAssessor;
99 import org.forester.tools.SupportCount;
100 import org.forester.tools.TreeSplitMatrix;
101 import org.forester.util.AsciiHistogram;
102 import org.forester.util.BasicDescriptiveStatistics;
103 import org.forester.util.BasicTable;
104 import org.forester.util.BasicTableParser;
105 import org.forester.util.DescriptiveStatistics;
106 import org.forester.util.ForesterConstants;
107 import org.forester.util.ForesterUtil;
108 import org.forester.util.GeneralTable;
109 import org.forester.util.SequenceIdParser;
110 import org.forester.ws.seqdb.SequenceDatabaseEntry;
111 import org.forester.ws.seqdb.SequenceDbWsTools;
112 import org.forester.ws.seqdb.UniProtTaxonomy;
113 import org.forester.ws.wabi.TxSearch;
114 import org.forester.ws.wabi.TxSearch.RANKS;
115 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
116 import org.forester.ws.wabi.TxSearch.TAX_RANK;
118 @SuppressWarnings( "unused")
119 public final class Test {
121 private final static double ZERO_DIFF = 1.0E-9;
122 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
123 + ForesterUtil.getFileSeparator() + "test_data"
124 + ForesterUtil.getFileSeparator();
125 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
126 + ForesterUtil.getFileSeparator() + "resources"
127 + ForesterUtil.getFileSeparator();
128 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
129 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
130 + ForesterConstants.PHYLO_XML_VERSION + "/"
131 + ForesterConstants.PHYLO_XML_XSD;
132 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
133 + ForesterConstants.PHYLO_XML_VERSION + "/"
134 + ForesterConstants.PHYLO_XML_XSD;
136 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
137 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
141 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
142 final PhylogenyMethods pm = PhylogenyMethods.getInstance();
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 id parsing: " );
178 if ( testSequenceIdParsing() ) {
179 System.out.println( "OK." );
183 System.out.println( "failed." );
184 System.exit( -1 ); //TODO FIXME remove me!! ~
187 System.out.print( "Hmmscan output parser: " );
188 if ( testHmmscanOutputParser() ) {
189 System.out.println( "OK." );
193 System.out.println( "failed." );
196 System.out.print( "Basic node methods: " );
197 if ( Test.testBasicNodeMethods() ) {
198 System.out.println( "OK." );
202 System.out.println( "failed." );
205 System.out.print( "Basic node construction and parsing of NHX (node level): " );
206 if ( Test.testNHXNodeParsing() ) {
207 System.out.println( "OK." );
211 System.out.println( "failed." );
214 System.out.print( "NH parsing: " );
215 if ( Test.testNHParsing() ) {
216 System.out.println( "OK." );
220 System.out.println( "failed." );
223 System.out.print( "Conversion to NHX (node level): " );
224 if ( Test.testNHXconversion() ) {
225 System.out.println( "OK." );
229 System.out.println( "failed." );
232 System.out.print( "NHX parsing: " );
233 if ( Test.testNHXParsing() ) {
234 System.out.println( "OK." );
238 System.out.println( "failed." );
241 System.out.print( "NHX parsing with quotes: " );
242 if ( Test.testNHXParsingQuotes() ) {
243 System.out.println( "OK." );
247 System.out.println( "failed." );
250 System.out.print( "NHX parsing (MrBayes): " );
251 if ( Test.testNHXParsingMB() ) {
252 System.out.println( "OK." );
256 System.out.println( "failed." );
259 System.out.print( "Nexus characters parsing: " );
260 if ( Test.testNexusCharactersParsing() ) {
261 System.out.println( "OK." );
265 System.out.println( "failed." );
268 System.out.print( "Nexus tree parsing: " );
269 if ( Test.testNexusTreeParsing() ) {
270 System.out.println( "OK." );
274 System.out.println( "failed." );
277 System.out.print( "Nexus tree parsing (translating): " );
278 if ( Test.testNexusTreeParsingTranslating() ) {
279 System.out.println( "OK." );
283 System.out.println( "failed." );
286 System.out.print( "Nexus matrix parsing: " );
287 if ( Test.testNexusMatrixParsing() ) {
288 System.out.println( "OK." );
292 System.out.println( "failed." );
295 System.out.print( "Basic phyloXML parsing: " );
296 if ( Test.testBasicPhyloXMLparsing() ) {
297 System.out.println( "OK." );
301 System.out.println( "failed." );
304 System.out.print( "Basic phyloXML parsing (validating against schema): " );
305 if ( testBasicPhyloXMLparsingValidating() ) {
306 System.out.println( "OK." );
310 System.out.println( "failed." );
313 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
314 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
315 System.out.println( "OK." );
319 System.out.println( "failed." );
322 System.out.print( "phyloXML Distribution Element: " );
323 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
324 System.out.println( "OK." );
328 System.out.println( "failed." );
331 System.out.print( "Tol XML parsing: " );
332 if ( Test.testBasicTolXMLparsing() ) {
333 System.out.println( "OK." );
337 System.out.println( "failed." );
340 System.out.print( "Copying of node data: " );
341 if ( Test.testCopyOfNodeData() ) {
342 System.out.println( "OK." );
346 System.out.println( "failed." );
349 System.out.print( "Basic tree methods: " );
350 if ( Test.testBasicTreeMethods() ) {
351 System.out.println( "OK." );
355 System.out.println( "failed." );
358 System.out.print( "Postorder Iterator: " );
359 if ( Test.testPostOrderIterator() ) {
360 System.out.println( "OK." );
364 System.out.println( "failed." );
367 System.out.print( "Preorder Iterator: " );
368 if ( Test.testPreOrderIterator() ) {
369 System.out.println( "OK." );
373 System.out.println( "failed." );
376 System.out.print( "Levelorder Iterator: " );
377 if ( Test.testLevelOrderIterator() ) {
378 System.out.println( "OK." );
382 System.out.println( "failed." );
385 System.out.print( "Re-id methods: " );
386 if ( Test.testReIdMethods() ) {
387 System.out.println( "OK." );
391 System.out.println( "failed." );
394 System.out.print( "Methods on last external nodes: " );
395 if ( Test.testLastExternalNodeMethods() ) {
396 System.out.println( "OK." );
400 System.out.println( "failed." );
403 System.out.print( "Methods on external nodes: " );
404 if ( Test.testExternalNodeRelatedMethods() ) {
405 System.out.println( "OK." );
409 System.out.println( "failed." );
412 System.out.print( "Deletion of external nodes: " );
413 if ( Test.testDeletionOfExternalNodes() ) {
414 System.out.println( "OK." );
418 System.out.println( "failed." );
421 System.out.print( "Subtree deletion: " );
422 if ( Test.testSubtreeDeletion() ) {
423 System.out.println( "OK." );
427 System.out.println( "failed." );
430 System.out.print( "Phylogeny branch: " );
431 if ( Test.testPhylogenyBranch() ) {
432 System.out.println( "OK." );
436 System.out.println( "failed." );
439 System.out.print( "Rerooting: " );
440 if ( Test.testRerooting() ) {
441 System.out.println( "OK." );
445 System.out.println( "failed." );
448 System.out.print( "Mipoint rooting: " );
449 if ( Test.testMidpointrooting() ) {
450 System.out.println( "OK." );
454 System.out.println( "failed." );
457 System.out.print( "Support count: " );
458 if ( Test.testSupportCount() ) {
459 System.out.println( "OK." );
463 System.out.println( "failed." );
466 System.out.print( "Support transfer: " );
467 if ( Test.testSupportTransfer() ) {
468 System.out.println( "OK." );
472 System.out.println( "failed." );
475 System.out.print( "Finding of LCA: " );
476 if ( Test.testGetLCA() ) {
477 System.out.println( "OK." );
481 System.out.println( "failed." );
484 System.out.print( "Finding of LCA 2: " );
485 if ( Test.testGetLCA2() ) {
486 System.out.println( "OK." );
490 System.out.println( "failed." );
493 System.out.print( "Calculation of distance between nodes: " );
494 if ( Test.testGetDistance() ) {
495 System.out.println( "OK." );
499 System.out.println( "failed." );
502 System.out.print( "SDIse: " );
503 if ( Test.testSDIse() ) {
504 System.out.println( "OK." );
508 System.out.println( "failed." );
511 System.out.print( "SDIunrooted: " );
512 if ( Test.testSDIunrooted() ) {
513 System.out.println( "OK." );
517 System.out.println( "failed." );
520 System.out.print( "GSDI: " );
521 if ( TestGSDI.test() ) {
522 System.out.println( "OK." );
526 System.out.println( "failed." );
529 System.out.print( "Ortholog table: " );
530 if ( Test.testOrthologTable() ) {
531 System.out.println( "OK." );
535 System.out.println( "failed." );
538 System.out.print( "Descriptive statistics: " );
539 if ( Test.testDescriptiveStatistics() ) {
540 System.out.println( "OK." );
544 System.out.println( "failed." );
547 System.out.print( "Data objects and methods: " );
548 if ( Test.testDataObjects() ) {
549 System.out.println( "OK." );
553 System.out.println( "failed." );
556 System.out.print( "Properties map: " );
557 if ( Test.testPropertiesMap() ) {
558 System.out.println( "OK." );
562 System.out.println( "failed." );
565 System.out.print( "Phylogeny reconstruction:" );
566 System.out.println();
567 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
568 System.out.println( "OK." );
572 System.out.println( "failed." );
575 System.out.print( "Analysis of domain architectures: " );
576 System.out.println();
577 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
578 System.out.println( "OK." );
582 System.out.println( "failed." );
585 System.out.print( "GO: " );
586 System.out.println();
587 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
588 System.out.println( "OK." );
592 System.out.println( "failed." );
595 System.out.print( "Modeling tools: " );
596 if ( TestPccx.test() ) {
597 System.out.println( "OK." );
601 System.out.println( "failed." );
604 System.out.print( "Split Matrix strict: " );
605 if ( Test.testSplitStrict() ) {
606 System.out.println( "OK." );
610 System.out.println( "failed." );
613 System.out.print( "Split Matrix: " );
614 if ( Test.testSplit() ) {
615 System.out.println( "OK." );
619 System.out.println( "failed." );
622 System.out.print( "Confidence Assessor: " );
623 if ( Test.testConfidenceAssessor() ) {
624 System.out.println( "OK." );
628 System.out.println( "failed." );
631 System.out.print( "Basic table: " );
632 if ( Test.testBasicTable() ) {
633 System.out.println( "OK." );
637 System.out.println( "failed." );
640 System.out.print( "General table: " );
641 if ( Test.testGeneralTable() ) {
642 System.out.println( "OK." );
646 System.out.println( "failed." );
649 System.out.print( "Amino acid sequence: " );
650 if ( Test.testAminoAcidSequence() ) {
651 System.out.println( "OK." );
655 System.out.println( "failed." );
658 System.out.print( "General MSA parser: " );
659 if ( Test.testGeneralMsaParser() ) {
660 System.out.println( "OK." );
664 System.out.println( "failed." );
667 System.out.print( "Fasta parser for msa: " );
668 if ( Test.testFastaParser() ) {
669 System.out.println( "OK." );
673 System.out.println( "failed." );
676 System.out.print( "Creation of balanced phylogeny: " );
677 if ( Test.testCreateBalancedPhylogeny() ) {
678 System.out.println( "OK." );
682 System.out.println( "failed." );
685 System.out.print( "EMBL Entry Retrieval: " );
686 if ( Test.testEmblEntryRetrieval() ) {
687 System.out.println( "OK." );
691 System.out.println( "failed." );
694 System.out.print( "Uniprot Entry Retrieval: " );
695 if ( Test.testUniprotEntryRetrieval() ) {
696 System.out.println( "OK." );
700 System.out.println( "failed." );
703 System.out.print( "Uniprot Taxonomy Search: " );
704 if ( Test.testUniprotTaxonomySearch() ) {
705 System.out.println( "OK." );
709 System.out.println( "failed." );
714 final String os = ForesterUtil.OS_NAME.toLowerCase();
715 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
716 path = "/usr/local/bin/mafft";
718 else if ( os.indexOf( "win" ) >= 0 ) {
719 path = "C:\\Program Files\\mafft-win\\mafft.bat";
722 path = "/home/czmasek/bin/mafft";
724 if ( !MsaInferrer.isInstalled( path ) ) {
727 if ( !MsaInferrer.isInstalled( path ) ) {
728 path = "/usr/local/bin/mafft";
730 if ( MsaInferrer.isInstalled( path ) ) {
731 System.out.print( "MAFFT (external program): " );
732 if ( Test.testMafft( path ) ) {
733 System.out.println( "OK." );
737 System.out.println( "failed [will not count towards failed tests]" );
741 System.out.print( "Next nodes with collapsed: " );
742 if ( Test.testNextNodeWithCollapsing() ) {
743 System.out.println( "OK." );
747 System.out.println( "failed." );
750 System.out.print( "Simple MSA quality: " );
751 if ( Test.testMsaQualityMethod() ) {
752 System.out.println( "OK." );
756 System.out.println( "failed." );
759 // System.out.print( "WABI TxSearch: " );
760 // if ( Test.testWabiTxSearch() ) {
761 // System.out.println( "OK." );
766 // .println( "failed [will not count towards failed tests since it might be due to absence internet connection]" );
768 System.out.println();
769 final Runtime rt = java.lang.Runtime.getRuntime();
770 final long free_memory = rt.freeMemory() / 1000000;
771 final long total_memory = rt.totalMemory() / 1000000;
772 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
773 + free_memory + "MB, total memory: " + total_memory + "MB)" );
774 System.out.println();
775 System.out.println( "Successful tests: " + succeeded );
776 System.out.println( "Failed tests: " + failed );
777 System.out.println();
779 System.out.println( "OK." );
782 System.out.println( "Not OK." );
784 // System.out.println();
785 // Development.setTime( true );
787 // final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
788 // final String clc = System.getProperty( "user.dir" ) + ForesterUtil.getFileSeparator()
789 // + "examples" + ForesterUtil.getFileSeparator() + "CLC.nhx";
790 // final String multi = Test.PATH_TO_EXAMPLE_FILES +
791 // "multifurcations_ex_1.nhx";
792 // final String domains = Test.PATH_TO_EXAMPLE_FILES + "domains1.nhx";
793 // final Phylogeny t1 = factory.create( new File( domains ), new
794 // NHXParser() )[ 0 ];
795 // final Phylogeny t2 = factory.create( new File( clc ), new NHXParser() )[ 0 ];
797 // catch ( final Exception e ) {
798 // e.printStackTrace();
800 // t1.getRoot().preorderPrint();
801 // final PhylogenyFactory factory = ParserBasedPhylogenyFactory
805 // Helper.readNHtree( new File( PATH_TO_EXAMPLE_FILES
806 // + "\\AtNBSpos.nhx" ) );
808 // new File( PATH_TO_EXAMPLE_FILES + "\\AtNBSpos.nhx" ),
809 // new NHXParser() );
810 // Helper.readNHtree( new File( PATH_TO_EXAMPLE_FILES
811 // + "\\AtNBSpos.nhx" ) );
813 // new File( PATH_TO_EXAMPLE_FILES + "\\AtNBSpos.nhx" ),
814 // new NHXParser() );
817 // Helper.readNHtree( new File( PATH_TO_EXAMPLE_FILES
818 // + "\\big_tree.nhx" ) );
819 // Helper.readNHtree( new File( PATH_TO_EXAMPLE_FILES
820 // + "\\big_tree.nhx" ) );
822 // new File( PATH_TO_EXAMPLE_FILES + "\\big_tree.nhx" ),
823 // new NHXParser() );
825 // new File( PATH_TO_EXAMPLE_FILES + "\\big_tree.nhx" ),
826 // new NHXParser() );
828 // Helper.readNHtree( new File( PATH_TO_EXAMPLE_FILES
829 // + "\\big_tree.nhx" ) );
830 // Helper.readNHtree( new File( PATH_TO_EXAMPLE_FILES
831 // + "\\big_tree.nhx" ) );
834 // new File( PATH_TO_EXAMPLE_FILES + "\\big_tree.nhx" ),
835 // new NHXParser() );
837 // new File( PATH_TO_EXAMPLE_FILES + "\\big_tree.nhx" ),
838 // new NHXParser() );
840 // Helper.readNHtree( new File( PATH_TO_EXAMPLE_FILES
841 // + "\\AtNBSpos.nhx" ) );
843 // new File( PATH_TO_EXAMPLE_FILES + "\\AtNBSpos.nhx" ),
844 // new NHXParser() );
847 // catch ( IOException e ) {
848 // // TODO Auto-generated catch block
849 // e.printStackTrace();
853 private static boolean testBasicNodeMethods() {
855 if ( PhylogenyNode.getNodeCount() != 0 ) {
858 final PhylogenyNode n1 = new PhylogenyNode();
859 final PhylogenyNode n2 = PhylogenyNode
860 .createInstanceFromNhxString( "", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
861 final PhylogenyNode n3 = PhylogenyNode
862 .createInstanceFromNhxString( "n3", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
863 final PhylogenyNode n4 = PhylogenyNode
864 .createInstanceFromNhxString( "n4:0.01", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
865 if ( n1.isHasAssignedEvent() ) {
868 if ( PhylogenyNode.getNodeCount() != 4 ) {
871 if ( n3.getIndicator() != 0 ) {
874 if ( n3.getNumberOfExternalNodes() != 1 ) {
877 if ( !n3.isExternal() ) {
880 if ( !n3.isRoot() ) {
883 if ( !n4.getName().equals( "n4" ) ) {
887 catch ( final Exception e ) {
888 e.printStackTrace( System.out );
894 private static boolean testBasicPhyloXMLparsing() {
896 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
897 final PhyloXmlParser xml_parser = new PhyloXmlParser();
898 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
900 if ( xml_parser.getErrorCount() > 0 ) {
901 System.out.println( xml_parser.getErrorMessages().toString() );
904 if ( phylogenies_0.length != 4 ) {
907 final Phylogeny t1 = phylogenies_0[ 0 ];
908 final Phylogeny t2 = phylogenies_0[ 1 ];
909 final Phylogeny t3 = phylogenies_0[ 2 ];
910 final Phylogeny t4 = phylogenies_0[ 3 ];
911 if ( t1.getNumberOfExternalNodes() != 1 ) {
914 if ( !t1.isRooted() ) {
917 if ( t1.isRerootable() ) {
920 if ( !t1.getType().equals( "gene_tree" ) ) {
923 if ( t2.getNumberOfExternalNodes() != 2 ) {
926 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
929 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
932 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
935 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
938 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
941 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
944 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
945 .startsWith( "actgtgggggt" ) ) {
948 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
949 .startsWith( "ctgtgatgcat" ) ) {
952 if ( t3.getNumberOfExternalNodes() != 4 ) {
955 if ( !t1.getName().equals( "t1" ) ) {
958 if ( !t2.getName().equals( "t2" ) ) {
961 if ( !t3.getName().equals( "t3" ) ) {
964 if ( !t4.getName().equals( "t4" ) ) {
967 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
970 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
973 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
976 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
977 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
980 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
983 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
986 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
989 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
990 .equals( "apoptosis" ) ) {
993 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
994 .equals( "GO:0006915" ) ) {
997 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
998 .equals( "UniProtKB" ) ) {
1001 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1002 .equals( "experimental" ) ) {
1005 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1006 .equals( "function" ) ) {
1009 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1010 .getValue() != 1 ) {
1013 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1014 .getType().equals( "ml" ) ) {
1017 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1018 .equals( "apoptosis" ) ) {
1021 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1022 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1025 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1026 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1029 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1030 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1033 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1034 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1037 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1038 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1041 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1042 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1045 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1046 .equals( "GO:0005829" ) ) {
1049 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1050 .equals( "intracellular organelle" ) ) {
1053 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1056 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1057 .equals( "UniProt link" ) ) ) {
1060 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1064 catch ( final Exception e ) {
1065 e.printStackTrace( System.out );
1071 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1073 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1074 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1075 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1076 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1079 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1081 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1083 if ( xml_parser.getErrorCount() > 0 ) {
1084 System.out.println( xml_parser.getErrorMessages().toString() );
1087 if ( phylogenies_0.length != 4 ) {
1090 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1091 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1092 if ( phylogenies_t1.length != 1 ) {
1095 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1096 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1099 if ( !t1_rt.isRooted() ) {
1102 if ( t1_rt.isRerootable() ) {
1105 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1108 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1109 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1110 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1111 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1114 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1117 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1120 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1123 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1124 .startsWith( "actgtgggggt" ) ) {
1127 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1128 .startsWith( "ctgtgatgcat" ) ) {
1131 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1132 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1133 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1134 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1135 if ( phylogenies_1.length != 1 ) {
1138 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1139 if ( !t3_rt.getName().equals( "t3" ) ) {
1142 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1145 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1148 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1151 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1154 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1155 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1158 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1161 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1164 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1165 .equals( "UniProtKB" ) ) {
1168 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1169 .equals( "apoptosis" ) ) {
1172 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1173 .equals( "GO:0006915" ) ) {
1176 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1177 .equals( "UniProtKB" ) ) {
1180 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1181 .equals( "experimental" ) ) {
1184 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1185 .equals( "function" ) ) {
1188 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1189 .getValue() != 1 ) {
1192 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1193 .getType().equals( "ml" ) ) {
1196 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1197 .equals( "apoptosis" ) ) {
1200 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1201 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1204 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1205 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1208 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1209 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1212 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1213 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1216 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1217 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1220 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1221 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1224 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1225 .equals( "GO:0005829" ) ) {
1228 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1229 .equals( "intracellular organelle" ) ) {
1232 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1235 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1236 .equals( "UniProt link" ) ) ) {
1239 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1242 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1245 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1246 .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." ) ) ) {
1249 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1252 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1255 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1258 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1261 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1262 .equals( "ncbi" ) ) {
1265 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1268 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1269 .getName().equals( "B" ) ) {
1272 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1273 .getFrom() != 21 ) {
1276 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1279 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1280 .getLength() != 24 ) {
1283 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1284 .getConfidence() != 2144 ) {
1287 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1288 .equals( "pfam" ) ) {
1291 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1294 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1297 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1300 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1303 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1304 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1307 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1310 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1313 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1316 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1319 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1322 if ( taxbb.getSynonyms().size() != 2 ) {
1325 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1328 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1331 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1334 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1337 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1340 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1341 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1345 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1348 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1351 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1354 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1357 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1360 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1363 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1367 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1370 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1371 .equalsIgnoreCase( "435" ) ) {
1374 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1377 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1378 .equalsIgnoreCase( "443.7" ) ) {
1381 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1384 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1387 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1388 .equalsIgnoreCase( "433" ) ) {
1392 catch ( final Exception e ) {
1393 e.printStackTrace( System.out );
1399 private static boolean testBasicPhyloXMLparsingValidating() {
1401 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1402 PhyloXmlParser xml_parser = null;
1404 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1406 catch ( final Exception e ) {
1407 // Do nothing -- means were not running from jar.
1409 if ( xml_parser == null ) {
1410 xml_parser = new PhyloXmlParser();
1411 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1412 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1415 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1418 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1420 if ( xml_parser.getErrorCount() > 0 ) {
1421 System.out.println( xml_parser.getErrorMessages().toString() );
1424 if ( phylogenies_0.length != 4 ) {
1427 final Phylogeny t1 = phylogenies_0[ 0 ];
1428 final Phylogeny t2 = phylogenies_0[ 1 ];
1429 final Phylogeny t3 = phylogenies_0[ 2 ];
1430 final Phylogeny t4 = phylogenies_0[ 3 ];
1431 if ( !t1.getName().equals( "t1" ) ) {
1434 if ( !t2.getName().equals( "t2" ) ) {
1437 if ( !t3.getName().equals( "t3" ) ) {
1440 if ( !t4.getName().equals( "t4" ) ) {
1443 if ( t1.getNumberOfExternalNodes() != 1 ) {
1446 if ( t2.getNumberOfExternalNodes() != 2 ) {
1449 if ( t3.getNumberOfExternalNodes() != 4 ) {
1452 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
1453 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
1454 if ( xml_parser.getErrorCount() > 0 ) {
1455 System.out.println( "errors:" );
1456 System.out.println( xml_parser.getErrorMessages().toString() );
1459 if ( phylogenies_1.length != 4 ) {
1462 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
1464 if ( xml_parser.getErrorCount() > 0 ) {
1465 System.out.println( "errors:" );
1466 System.out.println( xml_parser.getErrorMessages().toString() );
1469 if ( phylogenies_2.length != 1 ) {
1472 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
1475 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
1477 if ( xml_parser.getErrorCount() > 0 ) {
1478 System.out.println( xml_parser.getErrorMessages().toString() );
1481 if ( phylogenies_3.length != 2 ) {
1484 final Phylogeny a = phylogenies_3[ 0 ];
1485 if ( !a.getName().equals( "tree 4" ) ) {
1488 if ( a.getNumberOfExternalNodes() != 3 ) {
1491 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
1494 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
1497 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
1499 if ( xml_parser.getErrorCount() > 0 ) {
1500 System.out.println( xml_parser.getErrorMessages().toString() );
1503 if ( phylogenies_4.length != 1 ) {
1506 final Phylogeny s = phylogenies_4[ 0 ];
1507 if ( s.getNumberOfExternalNodes() != 6 ) {
1510 s.getNode( "first" );
1512 s.getNode( "\"<a'b&c'd\">\"" );
1513 s.getNode( "'''\"" );
1514 s.getNode( "\"\"\"" );
1515 s.getNode( "dick & doof" );
1517 catch ( final Exception e ) {
1518 e.printStackTrace( System.out );
1524 private static boolean testBasicTable() {
1526 final BasicTable<String> t0 = new BasicTable<String>();
1527 if ( t0.getNumberOfColumns() != 0 ) {
1530 if ( t0.getNumberOfRows() != 0 ) {
1533 t0.setValue( 3, 2, "23" );
1534 t0.setValue( 10, 1, "error" );
1535 t0.setValue( 10, 1, "110" );
1536 t0.setValue( 9, 1, "19" );
1537 t0.setValue( 1, 10, "101" );
1538 t0.setValue( 10, 10, "1010" );
1539 t0.setValue( 100, 10, "10100" );
1540 t0.setValue( 0, 0, "00" );
1541 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
1544 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
1547 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
1550 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
1553 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
1556 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
1559 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
1562 if ( t0.getNumberOfColumns() != 101 ) {
1565 if ( t0.getNumberOfRows() != 11 ) {
1568 if ( t0.getValueAsString( 49, 4 ) != null ) {
1571 final String l = ForesterUtil.getLineSeparator();
1572 final StringBuffer source = new StringBuffer();
1573 source.append( "" + l );
1574 source.append( "# 1 1 1 1 1 1 1 1" + l );
1575 source.append( " 00 01 02 03" + l );
1576 source.append( " 10 11 12 13 " + l );
1577 source.append( "20 21 22 23 " + l );
1578 source.append( " 30 31 32 33" + l );
1579 source.append( "40 41 42 43" + l );
1580 source.append( " # 1 1 1 1 1 " + l );
1581 source.append( "50 51 52 53 54" + l );
1582 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), " " );
1583 if ( t1.getNumberOfColumns() != 5 ) {
1586 if ( t1.getNumberOfRows() != 6 ) {
1589 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
1592 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
1595 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
1598 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
1601 final StringBuffer source1 = new StringBuffer();
1602 source1.append( "" + l );
1603 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
1604 source1.append( " 00; 01 ;02;03" + l );
1605 source1.append( " 10; 11; 12; 13 " + l );
1606 source1.append( "20; 21; 22; 23 " + l );
1607 source1.append( " 30; 31; 32; 33" + l );
1608 source1.append( "40;41;42;43" + l );
1609 source1.append( " # 1 1 1 1 1 " + l );
1610 source1.append( ";;;50 ; ;52; 53;;54 " + l );
1611 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ";" );
1612 if ( t2.getNumberOfColumns() != 5 ) {
1615 if ( t2.getNumberOfRows() != 6 ) {
1618 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
1621 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
1624 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
1627 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
1630 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
1633 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
1636 final StringBuffer source2 = new StringBuffer();
1637 source2.append( "" + l );
1638 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
1639 source2.append( " 00; 01 ;02;03" + l );
1640 source2.append( " 10; 11; 12; 13 " + l );
1641 source2.append( "20; 21; 22; 23 " + l );
1642 source2.append( " " + l );
1643 source2.append( " 30; 31; 32; 33" + l );
1644 source2.append( "40;41;42;43" + l );
1645 source2.append( " comment: 1 1 1 1 1 " + l );
1646 source2.append( ";;;50 ; 52; 53;;54 " + l );
1647 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
1653 if ( tl.size() != 2 ) {
1656 final BasicTable<String> t3 = tl.get( 0 );
1657 final BasicTable<String> t4 = tl.get( 1 );
1658 if ( t3.getNumberOfColumns() != 4 ) {
1661 if ( t3.getNumberOfRows() != 3 ) {
1664 if ( t4.getNumberOfColumns() != 4 ) {
1667 if ( t4.getNumberOfRows() != 3 ) {
1670 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
1673 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
1677 catch ( final Exception e ) {
1678 e.printStackTrace( System.out );
1684 private static boolean testBasicTolXMLparsing() {
1686 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1687 final TolParser parser = new TolParser();
1688 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
1689 if ( parser.getErrorCount() > 0 ) {
1690 System.out.println( parser.getErrorMessages().toString() );
1693 if ( phylogenies_0.length != 1 ) {
1696 final Phylogeny t1 = phylogenies_0[ 0 ];
1697 if ( t1.getNumberOfExternalNodes() != 5 ) {
1700 if ( !t1.isRooted() ) {
1703 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
1706 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
1709 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
1712 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
1715 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
1716 if ( parser.getErrorCount() > 0 ) {
1717 System.out.println( parser.getErrorMessages().toString() );
1720 if ( phylogenies_1.length != 1 ) {
1723 final Phylogeny t2 = phylogenies_1[ 0 ];
1724 if ( t2.getNumberOfExternalNodes() != 664 ) {
1727 if ( !t2.isRooted() ) {
1730 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
1733 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
1736 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
1739 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
1742 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
1745 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
1746 .equals( "Aquifex" ) ) {
1749 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
1750 if ( parser.getErrorCount() > 0 ) {
1751 System.out.println( parser.getErrorMessages().toString() );
1754 if ( phylogenies_2.length != 1 ) {
1757 final Phylogeny t3 = phylogenies_2[ 0 ];
1758 if ( t3.getNumberOfExternalNodes() != 184 ) {
1761 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
1764 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
1767 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
1770 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
1771 if ( parser.getErrorCount() > 0 ) {
1772 System.out.println( parser.getErrorMessages().toString() );
1775 if ( phylogenies_3.length != 1 ) {
1778 final Phylogeny t4 = phylogenies_3[ 0 ];
1779 if ( t4.getNumberOfExternalNodes() != 1 ) {
1782 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
1785 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
1788 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
1791 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
1792 if ( parser.getErrorCount() > 0 ) {
1793 System.out.println( parser.getErrorMessages().toString() );
1796 if ( phylogenies_4.length != 1 ) {
1799 final Phylogeny t5 = phylogenies_4[ 0 ];
1800 if ( t5.getNumberOfExternalNodes() != 13 ) {
1803 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
1806 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
1809 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
1813 catch ( final Exception e ) {
1814 e.printStackTrace( System.out );
1820 private static boolean testBasicTreeMethods() {
1822 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1823 final Phylogeny t1 = factory.create();
1824 if ( !t1.isEmpty() ) {
1827 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
1828 if ( t2.getNumberOfExternalNodes() != 4 ) {
1831 if ( t2.getHeight() != 8.5 ) {
1834 if ( !t2.isCompletelyBinary() ) {
1837 if ( t2.isEmpty() ) {
1840 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
1841 if ( t3.getNumberOfExternalNodes() != 5 ) {
1844 if ( t3.getHeight() != 11 ) {
1847 if ( t3.isCompletelyBinary() ) {
1850 final PhylogenyNode n = t3.getNode( "ABC" );
1851 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 ];
1852 if ( t4.getNumberOfExternalNodes() != 9 ) {
1855 if ( t4.getHeight() != 11 ) {
1858 if ( t4.isCompletelyBinary() ) {
1861 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)" );
1862 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
1863 if ( t5.getNumberOfExternalNodes() != 8 ) {
1866 if ( t5.getHeight() != 15 ) {
1869 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)" );
1870 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
1871 if ( t6.getHeight() != 15 ) {
1874 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)" );
1875 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
1876 if ( t7.getHeight() != 15 ) {
1879 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)" );
1880 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
1881 if ( t8.getNumberOfExternalNodes() != 10 ) {
1884 if ( t8.getHeight() != 15 ) {
1887 final char[] a9 = new char[] {};
1888 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
1889 if ( t9.getHeight() != 0 ) {
1892 final char[] a10 = new char[] { 'a', ':', '6' };
1893 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
1894 if ( t10.getHeight() != 6 ) {
1898 catch ( final Exception e ) {
1899 e.printStackTrace( System.out );
1905 private static boolean testConfidenceAssessor() {
1907 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1908 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
1909 final Phylogeny[] ev0 = factory
1910 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
1912 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
1913 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
1916 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
1919 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
1920 final Phylogeny[] ev1 = factory
1921 .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)));",
1923 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
1924 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
1927 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
1930 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
1931 final Phylogeny[] ev_b = factory
1932 .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",
1934 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
1935 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
1938 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
1942 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
1943 final Phylogeny[] ev1x = factory
1944 .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)));",
1946 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
1947 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
1950 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
1953 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
1954 final Phylogeny[] ev_bx = factory
1955 .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",
1957 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
1958 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
1961 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
1965 final Phylogeny[] t2 = factory
1966 .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);",
1968 final Phylogeny[] ev2 = factory
1969 .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);",
1971 for( final Phylogeny target : t2 ) {
1972 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
1975 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
1976 new NHXParser() )[ 0 ];
1977 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
1978 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
1979 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
1982 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
1985 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
1989 catch ( final Exception e ) {
1990 e.printStackTrace();
1996 private static boolean testCopyOfNodeData() {
1998 final PhylogenyNode n1 = PhylogenyNode
1999 .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]" );
2000 final PhylogenyNode n2 = n1.copyNodeData();
2001 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2005 catch ( final Exception e ) {
2006 e.printStackTrace();
2012 private static boolean testDataObjects() {
2014 final Confidence s0 = new Confidence();
2015 final Confidence s1 = new Confidence();
2016 if ( !s0.isEqual( s1 ) ) {
2019 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2020 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2021 if ( s2.isEqual( s1 ) ) {
2024 if ( !s2.isEqual( s3 ) ) {
2027 final Confidence s4 = ( Confidence ) s3.copy();
2028 if ( !s4.isEqual( s3 ) ) {
2035 final Taxonomy t1 = new Taxonomy();
2036 final Taxonomy t2 = new Taxonomy();
2037 final Taxonomy t3 = new Taxonomy();
2038 final Taxonomy t4 = new Taxonomy();
2039 final Taxonomy t5 = new Taxonomy();
2040 t1.setIdentifier( new Identifier( "ecoli" ) );
2041 t1.setTaxonomyCode( "ECOLI" );
2042 t1.setScientificName( "E. coli" );
2043 t1.setCommonName( "coli" );
2044 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2045 if ( !t1.isEqual( t0 ) ) {
2048 t2.setIdentifier( new Identifier( "ecoli" ) );
2049 t2.setTaxonomyCode( "OTHER" );
2050 t2.setScientificName( "what" );
2051 t2.setCommonName( "something" );
2052 if ( !t1.isEqual( t2 ) ) {
2055 t2.setIdentifier( new Identifier( "nemve" ) );
2056 if ( t1.isEqual( t2 ) ) {
2059 t1.setIdentifier( null );
2060 t3.setTaxonomyCode( "ECOLI" );
2061 t3.setScientificName( "what" );
2062 t3.setCommonName( "something" );
2063 if ( !t1.isEqual( t3 ) ) {
2066 t1.setIdentifier( null );
2067 t1.setTaxonomyCode( "" );
2068 t4.setScientificName( "E. ColI" );
2069 t4.setCommonName( "something" );
2070 if ( !t1.isEqual( t4 ) ) {
2073 t4.setScientificName( "B. subtilis" );
2074 t4.setCommonName( "something" );
2075 if ( t1.isEqual( t4 ) ) {
2078 t1.setIdentifier( null );
2079 t1.setTaxonomyCode( "" );
2080 t1.setScientificName( "" );
2081 t5.setCommonName( "COLI" );
2082 if ( !t1.isEqual( t5 ) ) {
2085 t5.setCommonName( "vibrio" );
2086 if ( t1.isEqual( t5 ) ) {
2091 final Identifier id0 = new Identifier( "123", "pfam" );
2092 final Identifier id1 = ( Identifier ) id0.copy();
2093 if ( !id1.isEqual( id1 ) ) {
2096 if ( !id1.isEqual( id0 ) ) {
2099 if ( !id0.isEqual( id1 ) ) {
2106 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
2107 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
2108 if ( !pd1.isEqual( pd1 ) ) {
2111 if ( !pd1.isEqual( pd0 ) ) {
2116 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
2117 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
2118 if ( !pd3.isEqual( pd3 ) ) {
2121 if ( !pd2.isEqual( pd3 ) ) {
2124 if ( !pd0.isEqual( pd3 ) ) {
2129 // DomainArchitecture
2130 // ------------------
2131 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
2132 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
2133 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
2134 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
2135 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
2136 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
2141 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
2142 if ( ds0.getNumberOfDomains() != 4 ) {
2145 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
2146 if ( !ds0.isEqual( ds0 ) ) {
2149 if ( !ds0.isEqual( ds1 ) ) {
2152 if ( ds1.getNumberOfDomains() != 4 ) {
2155 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
2160 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
2161 if ( ds0.isEqual( ds2 ) ) {
2167 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
2168 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
2169 System.out.println( ds3.toNHX() );
2172 if ( ds3.getNumberOfDomains() != 3 ) {
2177 final Event e1 = new Event( Event.EventType.fusion );
2178 if ( e1.isDuplication() ) {
2181 if ( !e1.isFusion() ) {
2184 if ( !e1.asText().toString().equals( "fusion" ) ) {
2187 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
2190 final Event e11 = new Event( Event.EventType.fusion );
2191 if ( !e11.isEqual( e1 ) ) {
2194 if ( !e11.toNHX().toString().equals( "" ) ) {
2197 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
2198 if ( e2.isDuplication() ) {
2201 if ( !e2.isSpeciationOrDuplication() ) {
2204 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
2207 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
2210 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
2213 if ( e11.isEqual( e2 ) ) {
2216 final Event e2c = ( Event ) e2.copy();
2217 if ( !e2c.isEqual( e2 ) ) {
2220 Event e3 = new Event( 1, 2, 3 );
2221 if ( e3.isDuplication() ) {
2224 if ( e3.isSpeciation() ) {
2227 if ( e3.isGeneLoss() ) {
2230 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2233 final Event e3c = ( Event ) e3.copy();
2234 final Event e3cc = ( Event ) e3c.copy();
2235 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
2239 if ( !e3c.isEqual( e3cc ) ) {
2242 Event e4 = new Event( 1, 2, 3 );
2243 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2246 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
2249 final Event e4c = ( Event ) e4.copy();
2251 final Event e4cc = ( Event ) e4c.copy();
2252 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2255 if ( !e4c.isEqual( e4cc ) ) {
2258 final Event e5 = new Event();
2259 if ( !e5.isUnassigned() ) {
2262 if ( !e5.asText().toString().equals( "unassigned" ) ) {
2265 if ( !e5.asSimpleText().toString().equals( "" ) ) {
2268 final Event e6 = new Event( 1, 0, 0 );
2269 if ( !e6.asText().toString().equals( "duplication" ) ) {
2272 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
2275 final Event e7 = new Event( 0, 1, 0 );
2276 if ( !e7.asText().toString().equals( "speciation" ) ) {
2279 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
2282 final Event e8 = new Event( 0, 0, 1 );
2283 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
2286 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
2290 catch ( final Exception e ) {
2291 e.printStackTrace( System.out );
2297 private static boolean testDeletionOfExternalNodes() {
2299 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2300 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
2301 final PhylogenyWriter w = new PhylogenyWriter();
2302 if ( t0.isEmpty() ) {
2305 if ( t0.getNumberOfExternalNodes() != 1 ) {
2308 t0.deleteSubtree( t0.getNode( "A" ), false );
2309 if ( t0.getNumberOfExternalNodes() != 0 ) {
2312 if ( !t0.isEmpty() ) {
2315 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
2316 if ( t1.getNumberOfExternalNodes() != 2 ) {
2319 t1.deleteSubtree( t1.getNode( "A" ), false );
2320 if ( t1.getNumberOfExternalNodes() != 1 ) {
2323 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
2326 t1.deleteSubtree( t1.getNode( "B" ), false );
2327 if ( t1.getNumberOfExternalNodes() != 1 ) {
2330 t1.deleteSubtree( t1.getNode( "r" ), false );
2331 if ( !t1.isEmpty() ) {
2334 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
2335 if ( t2.getNumberOfExternalNodes() != 3 ) {
2338 t2.deleteSubtree( t2.getNode( "B" ), false );
2339 if ( t2.getNumberOfExternalNodes() != 2 ) {
2342 t2.toNewHampshireX();
2343 PhylogenyNode n = t2.getNode( "A" );
2344 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2347 t2.deleteSubtree( t2.getNode( "A" ), false );
2348 if ( t2.getNumberOfExternalNodes() != 2 ) {
2351 t2.deleteSubtree( t2.getNode( "C" ), true );
2352 if ( t2.getNumberOfExternalNodes() != 1 ) {
2355 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2356 if ( t3.getNumberOfExternalNodes() != 4 ) {
2359 t3.deleteSubtree( t3.getNode( "B" ), true );
2360 if ( t3.getNumberOfExternalNodes() != 3 ) {
2363 n = t3.getNode( "A" );
2364 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2367 n = n.getNextExternalNode();
2368 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2371 t3.deleteSubtree( t3.getNode( "A" ), true );
2372 if ( t3.getNumberOfExternalNodes() != 2 ) {
2375 n = t3.getNode( "C" );
2376 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2379 t3.deleteSubtree( t3.getNode( "C" ), true );
2380 if ( t3.getNumberOfExternalNodes() != 1 ) {
2383 t3.deleteSubtree( t3.getNode( "D" ), true );
2384 if ( t3.getNumberOfExternalNodes() != 0 ) {
2387 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2388 if ( t4.getNumberOfExternalNodes() != 6 ) {
2391 t4.deleteSubtree( t4.getNode( "B2" ), true );
2392 if ( t4.getNumberOfExternalNodes() != 5 ) {
2395 String s = w.toNewHampshire( t4, false, true ).toString();
2396 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2399 t4.deleteSubtree( t4.getNode( "B11" ), true );
2400 if ( t4.getNumberOfExternalNodes() != 4 ) {
2403 t4.deleteSubtree( t4.getNode( "C" ), true );
2404 if ( t4.getNumberOfExternalNodes() != 3 ) {
2407 n = t4.getNode( "A" );
2408 n = n.getNextExternalNode();
2409 if ( !n.getName().equals( "B12" ) ) {
2412 n = n.getNextExternalNode();
2413 if ( !n.getName().equals( "D" ) ) {
2416 s = w.toNewHampshire( t4, false, true ).toString();
2417 if ( !s.equals( "((A,B12),D);" ) ) {
2420 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2421 t5.deleteSubtree( t5.getNode( "A" ), true );
2422 if ( t5.getNumberOfExternalNodes() != 5 ) {
2425 s = w.toNewHampshire( t5, false, true ).toString();
2426 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
2429 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2430 t6.deleteSubtree( t6.getNode( "B11" ), true );
2431 if ( t6.getNumberOfExternalNodes() != 5 ) {
2434 s = w.toNewHampshire( t6, false, false ).toString();
2435 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
2438 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2439 t7.deleteSubtree( t7.getNode( "B12" ), true );
2440 if ( t7.getNumberOfExternalNodes() != 5 ) {
2443 s = w.toNewHampshire( t7, false, true ).toString();
2444 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
2447 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2448 t8.deleteSubtree( t8.getNode( "B2" ), true );
2449 if ( t8.getNumberOfExternalNodes() != 5 ) {
2452 s = w.toNewHampshire( t8, false, false ).toString();
2453 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2456 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2457 t9.deleteSubtree( t9.getNode( "C" ), true );
2458 if ( t9.getNumberOfExternalNodes() != 5 ) {
2461 s = w.toNewHampshire( t9, false, true ).toString();
2462 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
2465 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2466 t10.deleteSubtree( t10.getNode( "D" ), true );
2467 if ( t10.getNumberOfExternalNodes() != 5 ) {
2470 s = w.toNewHampshire( t10, false, true ).toString();
2471 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
2474 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
2475 t11.deleteSubtree( t11.getNode( "A" ), true );
2476 if ( t11.getNumberOfExternalNodes() != 2 ) {
2479 s = w.toNewHampshire( t11, false, true ).toString();
2480 if ( !s.equals( "(B,C);" ) ) {
2483 t11.deleteSubtree( t11.getNode( "C" ), true );
2484 if ( t11.getNumberOfExternalNodes() != 1 ) {
2487 s = w.toNewHampshire( t11, false, false ).toString();
2488 if ( !s.equals( "B;" ) ) {
2491 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
2492 t12.deleteSubtree( t12.getNode( "B2" ), true );
2493 if ( t12.getNumberOfExternalNodes() != 8 ) {
2496 s = w.toNewHampshire( t12, false, true ).toString();
2497 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
2500 t12.deleteSubtree( t12.getNode( "B3" ), true );
2501 if ( t12.getNumberOfExternalNodes() != 7 ) {
2504 s = w.toNewHampshire( t12, false, true ).toString();
2505 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
2508 t12.deleteSubtree( t12.getNode( "C3" ), true );
2509 if ( t12.getNumberOfExternalNodes() != 6 ) {
2512 s = w.toNewHampshire( t12, false, true ).toString();
2513 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
2516 t12.deleteSubtree( t12.getNode( "A1" ), true );
2517 if ( t12.getNumberOfExternalNodes() != 5 ) {
2520 s = w.toNewHampshire( t12, false, true ).toString();
2521 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
2524 t12.deleteSubtree( t12.getNode( "B1" ), true );
2525 if ( t12.getNumberOfExternalNodes() != 4 ) {
2528 s = w.toNewHampshire( t12, false, true ).toString();
2529 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
2532 t12.deleteSubtree( t12.getNode( "A3" ), true );
2533 if ( t12.getNumberOfExternalNodes() != 3 ) {
2536 s = w.toNewHampshire( t12, false, true ).toString();
2537 if ( !s.equals( "(A2,(C1,C2));" ) ) {
2540 t12.deleteSubtree( t12.getNode( "A2" ), true );
2541 if ( t12.getNumberOfExternalNodes() != 2 ) {
2544 s = w.toNewHampshire( t12, false, true ).toString();
2545 if ( !s.equals( "(C1,C2);" ) ) {
2548 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
2549 t13.deleteSubtree( t13.getNode( "D" ), true );
2550 if ( t13.getNumberOfExternalNodes() != 4 ) {
2553 s = w.toNewHampshire( t13, false, true ).toString();
2554 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
2557 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
2558 t14.deleteSubtree( t14.getNode( "E" ), true );
2559 if ( t14.getNumberOfExternalNodes() != 5 ) {
2562 s = w.toNewHampshire( t14, false, true ).toString();
2563 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
2566 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
2567 t15.deleteSubtree( t15.getNode( "B2" ), true );
2568 if ( t15.getNumberOfExternalNodes() != 11 ) {
2571 t15.deleteSubtree( t15.getNode( "B1" ), true );
2572 if ( t15.getNumberOfExternalNodes() != 10 ) {
2575 t15.deleteSubtree( t15.getNode( "B3" ), true );
2576 if ( t15.getNumberOfExternalNodes() != 9 ) {
2579 t15.deleteSubtree( t15.getNode( "B4" ), true );
2580 if ( t15.getNumberOfExternalNodes() != 8 ) {
2583 t15.deleteSubtree( t15.getNode( "A1" ), true );
2584 if ( t15.getNumberOfExternalNodes() != 7 ) {
2587 t15.deleteSubtree( t15.getNode( "C4" ), true );
2588 if ( t15.getNumberOfExternalNodes() != 6 ) {
2592 catch ( final Exception e ) {
2593 e.printStackTrace( System.out );
2599 private static boolean testDescriptiveStatistics() {
2601 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
2602 dss1.addValue( 82 );
2603 dss1.addValue( 78 );
2604 dss1.addValue( 70 );
2605 dss1.addValue( 58 );
2606 dss1.addValue( 42 );
2607 if ( dss1.getN() != 5 ) {
2610 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
2613 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
2616 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
2619 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
2622 if ( !Test.isEqual( dss1.median(), 70 ) ) {
2625 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
2628 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
2631 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
2634 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
2637 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
2640 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
2643 dss1.addValue( 123 );
2644 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
2647 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
2650 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
2653 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
2654 dss2.addValue( -1.85 );
2655 dss2.addValue( 57.5 );
2656 dss2.addValue( 92.78 );
2657 dss2.addValue( 57.78 );
2658 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
2661 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
2664 final double[] a = dss2.getDataAsDoubleArray();
2665 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
2668 dss2.addValue( -100 );
2669 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
2672 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
2675 final double[] ds = new double[ 14 ];
2690 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
2691 if ( bins.length != 4 ) {
2694 if ( bins[ 0 ] != 2 ) {
2697 if ( bins[ 1 ] != 3 ) {
2700 if ( bins[ 2 ] != 4 ) {
2703 if ( bins[ 3 ] != 5 ) {
2706 final double[] ds1 = new double[ 9 ];
2716 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
2717 if ( bins1.length != 4 ) {
2720 if ( bins1[ 0 ] != 2 ) {
2723 if ( bins1[ 1 ] != 3 ) {
2726 if ( bins1[ 2 ] != 0 ) {
2729 if ( bins1[ 3 ] != 4 ) {
2732 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
2733 if ( bins1_1.length != 3 ) {
2736 if ( bins1_1[ 0 ] != 3 ) {
2739 if ( bins1_1[ 1 ] != 2 ) {
2742 if ( bins1_1[ 2 ] != 4 ) {
2745 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
2746 if ( bins1_2.length != 3 ) {
2749 if ( bins1_2[ 0 ] != 2 ) {
2752 if ( bins1_2[ 1 ] != 2 ) {
2755 if ( bins1_2[ 2 ] != 2 ) {
2758 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
2772 dss3.addValue( 10 );
2773 dss3.addValue( 10 );
2774 dss3.addValue( 10 );
2775 final AsciiHistogram histo = new AsciiHistogram( dss3 );
2776 histo.toStringBuffer( 10, '=', 40, 5 );
2777 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
2779 catch ( final Exception e ) {
2780 e.printStackTrace( System.out );
2786 private static boolean testDir( final String file ) {
2788 final File f = new File( file );
2789 if ( !f.exists() ) {
2792 if ( !f.isDirectory() ) {
2795 if ( !f.canRead() ) {
2799 catch ( final Exception e ) {
2805 private static boolean testExternalNodeRelatedMethods() {
2807 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2808 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2809 PhylogenyNode n = t1.getNode( "A" );
2810 n = n.getNextExternalNode();
2811 if ( !n.getName().equals( "B" ) ) {
2814 n = n.getNextExternalNode();
2815 if ( !n.getName().equals( "C" ) ) {
2818 n = n.getNextExternalNode();
2819 if ( !n.getName().equals( "D" ) ) {
2822 n = t1.getNode( "B" );
2823 while ( !n.isLastExternalNode() ) {
2824 n = n.getNextExternalNode();
2826 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
2827 n = t2.getNode( "A" );
2828 n = n.getNextExternalNode();
2829 if ( !n.getName().equals( "B" ) ) {
2832 n = n.getNextExternalNode();
2833 if ( !n.getName().equals( "C" ) ) {
2836 n = n.getNextExternalNode();
2837 if ( !n.getName().equals( "D" ) ) {
2840 n = t2.getNode( "B" );
2841 while ( !n.isLastExternalNode() ) {
2842 n = n.getNextExternalNode();
2844 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
2845 n = t3.getNode( "A" );
2846 n = n.getNextExternalNode();
2847 if ( !n.getName().equals( "B" ) ) {
2850 n = n.getNextExternalNode();
2851 if ( !n.getName().equals( "C" ) ) {
2854 n = n.getNextExternalNode();
2855 if ( !n.getName().equals( "D" ) ) {
2858 n = n.getNextExternalNode();
2859 if ( !n.getName().equals( "E" ) ) {
2862 n = n.getNextExternalNode();
2863 if ( !n.getName().equals( "F" ) ) {
2866 n = n.getNextExternalNode();
2867 if ( !n.getName().equals( "G" ) ) {
2870 n = n.getNextExternalNode();
2871 if ( !n.getName().equals( "H" ) ) {
2874 n = t3.getNode( "B" );
2875 while ( !n.isLastExternalNode() ) {
2876 n = n.getNextExternalNode();
2878 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2879 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
2880 final PhylogenyNode node = iter.next();
2882 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
2883 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
2884 final PhylogenyNode node = iter.next();
2887 catch ( final Exception e ) {
2888 e.printStackTrace( System.out );
2894 private static boolean testGeneralTable() {
2896 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
2897 t0.setValue( 3, 2, "23" );
2898 t0.setValue( 10, 1, "error" );
2899 t0.setValue( 10, 1, "110" );
2900 t0.setValue( 9, 1, "19" );
2901 t0.setValue( 1, 10, "101" );
2902 t0.setValue( 10, 10, "1010" );
2903 t0.setValue( 100, 10, "10100" );
2904 t0.setValue( 0, 0, "00" );
2905 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2908 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2911 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2914 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2917 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2920 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2923 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2926 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
2929 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
2932 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
2933 t1.setValue( "3", "2", "23" );
2934 t1.setValue( "10", "1", "error" );
2935 t1.setValue( "10", "1", "110" );
2936 t1.setValue( "9", "1", "19" );
2937 t1.setValue( "1", "10", "101" );
2938 t1.setValue( "10", "10", "1010" );
2939 t1.setValue( "100", "10", "10100" );
2940 t1.setValue( "0", "0", "00" );
2941 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
2942 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
2945 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
2948 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
2951 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
2954 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
2957 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
2960 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
2963 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
2966 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
2969 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
2973 catch ( final Exception e ) {
2974 e.printStackTrace( System.out );
2980 private static boolean testGetDistance() {
2982 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2983 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",
2984 new NHXParser() )[ 0 ];
2985 final PhylogenyMethods pm = PhylogenyMethods.getInstance();
2986 if ( pm.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
2989 if ( pm.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
2992 if ( pm.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
2995 if ( pm.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
2998 if ( pm.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
3001 if ( pm.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
3004 if ( pm.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
3007 if ( pm.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
3010 if ( pm.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
3013 if ( pm.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
3016 if ( pm.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
3019 if ( pm.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
3022 if ( pm.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
3025 if ( pm.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
3028 if ( pm.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
3031 if ( pm.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
3034 if ( pm.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
3037 if ( pm.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
3040 if ( pm.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
3043 if ( pm.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
3046 if ( pm.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
3049 if ( pm.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
3052 if ( pm.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
3055 if ( pm.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
3058 if ( pm.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
3061 if ( pm.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
3064 if ( pm.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
3067 if ( pm.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
3070 if ( pm.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
3073 if ( pm.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
3076 if ( pm.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
3079 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",
3080 new NHXParser() )[ 0 ];
3081 if ( pm.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
3084 if ( pm.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
3087 if ( pm.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
3090 if ( pm.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
3093 if ( pm.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
3096 if ( pm.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
3099 if ( pm.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
3102 if ( pm.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
3105 if ( pm.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
3108 if ( pm.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
3111 if ( pm.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
3115 catch ( final Exception e ) {
3116 e.printStackTrace( System.out );
3122 private static boolean testGetLCA() {
3124 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3125 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
3126 new NHXParser() )[ 0 ];
3127 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
3128 if ( !A.getName().equals( "A" ) ) {
3131 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
3132 if ( !gh.getName().equals( "gh" ) ) {
3135 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
3136 if ( !ab.getName().equals( "ab" ) ) {
3139 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
3140 if ( !ab2.getName().equals( "ab" ) ) {
3143 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
3144 if ( !gh2.getName().equals( "gh" ) ) {
3147 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
3148 if ( !gh3.getName().equals( "gh" ) ) {
3151 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
3152 if ( !abc.getName().equals( "abc" ) ) {
3155 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
3156 if ( !abc2.getName().equals( "abc" ) ) {
3159 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
3160 if ( !abcd.getName().equals( "abcd" ) ) {
3163 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
3164 if ( !abcd2.getName().equals( "abcd" ) ) {
3167 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
3168 if ( !abcdef.getName().equals( "abcdef" ) ) {
3171 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
3172 if ( !abcdef2.getName().equals( "abcdef" ) ) {
3175 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
3176 if ( !abcdef3.getName().equals( "abcdef" ) ) {
3179 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
3180 if ( !abcdef4.getName().equals( "abcdef" ) ) {
3183 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
3184 if ( !abcde.getName().equals( "abcde" ) ) {
3187 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
3188 if ( !abcde2.getName().equals( "abcde" ) ) {
3191 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
3192 if ( !r.getName().equals( "abcdefgh" ) ) {
3195 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
3196 if ( !r2.getName().equals( "abcdefgh" ) ) {
3199 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
3200 if ( !r3.getName().equals( "abcdefgh" ) ) {
3203 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
3204 if ( !abcde3.getName().equals( "abcde" ) ) {
3207 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
3208 if ( !abcde4.getName().equals( "abcde" ) ) {
3211 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
3212 if ( !ab3.getName().equals( "ab" ) ) {
3215 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
3216 if ( !ab4.getName().equals( "ab" ) ) {
3219 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
3220 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
3221 if ( !cd.getName().equals( "cd" ) ) {
3224 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
3225 if ( !cd2.getName().equals( "cd" ) ) {
3228 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
3229 if ( !cde.getName().equals( "cde" ) ) {
3232 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
3233 if ( !cde2.getName().equals( "cde" ) ) {
3236 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
3237 if ( !cdef.getName().equals( "cdef" ) ) {
3240 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
3241 if ( !cdef2.getName().equals( "cdef" ) ) {
3244 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
3245 if ( !cdef3.getName().equals( "cdef" ) ) {
3248 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
3249 if ( !rt.getName().equals( "r" ) ) {
3252 final Phylogeny p3 = factory
3253 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
3254 new NHXParser() )[ 0 ];
3255 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
3256 if ( !bc_3.getName().equals( "bc" ) ) {
3259 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
3260 if ( !ac_3.getName().equals( "abc" ) ) {
3263 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
3264 if ( !ad_3.getName().equals( "abcde" ) ) {
3267 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
3268 if ( !af_3.getName().equals( "abcdef" ) ) {
3271 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
3272 if ( !ag_3.getName().equals( "" ) ) {
3275 if ( !ag_3.isRoot() ) {
3278 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
3279 if ( !al_3.getName().equals( "" ) ) {
3282 if ( !al_3.isRoot() ) {
3285 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
3286 if ( !kl_3.getName().equals( "" ) ) {
3289 if ( !kl_3.isRoot() ) {
3292 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
3293 if ( !fl_3.getName().equals( "" ) ) {
3296 if ( !fl_3.isRoot() ) {
3299 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
3300 if ( !gk_3.getName().equals( "ghijk" ) ) {
3303 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
3304 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
3305 if ( !r_4.getName().equals( "r" ) ) {
3308 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
3309 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
3310 if ( !r_5.getName().equals( "root" ) ) {
3313 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
3314 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
3315 if ( !r_6.getName().equals( "rot" ) ) {
3318 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
3319 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
3320 if ( !r_7.getName().equals( "rott" ) ) {
3324 catch ( final Exception e ) {
3325 e.printStackTrace( System.out );
3331 private static boolean testGetLCA2() {
3333 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3334 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
3335 new NHXParser() )[ 0 ];
3336 PhylogenyMethods.preOrderReId( p1 );
3337 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3338 p1.getNode( "A" ) );
3339 if ( !A.getName().equals( "A" ) ) {
3342 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
3343 p1.getNode( "gh" ) );
3344 if ( !gh.getName().equals( "gh" ) ) {
3347 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3348 p1.getNode( "B" ) );
3349 if ( !ab.getName().equals( "ab" ) ) {
3352 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
3353 p1.getNode( "A" ) );
3354 if ( !ab2.getName().equals( "ab" ) ) {
3357 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
3358 p1.getNode( "G" ) );
3359 if ( !gh2.getName().equals( "gh" ) ) {
3362 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
3363 p1.getNode( "H" ) );
3364 if ( !gh3.getName().equals( "gh" ) ) {
3367 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
3368 p1.getNode( "A" ) );
3369 if ( !abc.getName().equals( "abc" ) ) {
3372 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3373 p1.getNode( "C" ) );
3374 if ( !abc2.getName().equals( "abc" ) ) {
3377 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3378 p1.getNode( "D" ) );
3379 if ( !abcd.getName().equals( "abcd" ) ) {
3382 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
3383 p1.getNode( "A" ) );
3384 if ( !abcd2.getName().equals( "abcd" ) ) {
3387 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3388 p1.getNode( "F" ) );
3389 if ( !abcdef.getName().equals( "abcdef" ) ) {
3392 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
3393 p1.getNode( "A" ) );
3394 if ( !abcdef2.getName().equals( "abcdef" ) ) {
3397 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
3398 p1.getNode( "F" ) );
3399 if ( !abcdef3.getName().equals( "abcdef" ) ) {
3402 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
3403 p1.getNode( "ab" ) );
3404 if ( !abcdef4.getName().equals( "abcdef" ) ) {
3407 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3408 p1.getNode( "E" ) );
3409 if ( !abcde.getName().equals( "abcde" ) ) {
3412 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
3413 p1.getNode( "A" ) );
3414 if ( !abcde2.getName().equals( "abcde" ) ) {
3417 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
3418 p1.getNode( "abcdefgh" ) );
3419 if ( !r.getName().equals( "abcdefgh" ) ) {
3422 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3423 p1.getNode( "H" ) );
3424 if ( !r2.getName().equals( "abcdefgh" ) ) {
3427 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
3428 p1.getNode( "A" ) );
3429 if ( !r3.getName().equals( "abcdefgh" ) ) {
3432 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
3433 p1.getNode( "abcde" ) );
3434 if ( !abcde3.getName().equals( "abcde" ) ) {
3437 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
3438 p1.getNode( "E" ) );
3439 if ( !abcde4.getName().equals( "abcde" ) ) {
3442 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
3443 p1.getNode( "B" ) );
3444 if ( !ab3.getName().equals( "ab" ) ) {
3447 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
3448 p1.getNode( "ab" ) );
3449 if ( !ab4.getName().equals( "ab" ) ) {
3452 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
3453 PhylogenyMethods.preOrderReId( p2 );
3454 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
3455 p2.getNode( "d" ) );
3456 if ( !cd.getName().equals( "cd" ) ) {
3459 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
3460 p2.getNode( "c" ) );
3461 if ( !cd2.getName().equals( "cd" ) ) {
3464 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
3465 p2.getNode( "e" ) );
3466 if ( !cde.getName().equals( "cde" ) ) {
3469 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
3470 p2.getNode( "c" ) );
3471 if ( !cde2.getName().equals( "cde" ) ) {
3474 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
3475 p2.getNode( "f" ) );
3476 if ( !cdef.getName().equals( "cdef" ) ) {
3479 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
3480 p2.getNode( "f" ) );
3481 if ( !cdef2.getName().equals( "cdef" ) ) {
3484 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
3485 p2.getNode( "d" ) );
3486 if ( !cdef3.getName().equals( "cdef" ) ) {
3489 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
3490 p2.getNode( "a" ) );
3491 if ( !rt.getName().equals( "r" ) ) {
3494 final Phylogeny p3 = factory
3495 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
3496 new NHXParser() )[ 0 ];
3497 PhylogenyMethods.preOrderReId( p3 );
3498 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
3499 p3.getNode( "c" ) );
3500 if ( !bc_3.getName().equals( "bc" ) ) {
3503 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
3504 p3.getNode( "c" ) );
3505 if ( !ac_3.getName().equals( "abc" ) ) {
3508 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
3509 p3.getNode( "d" ) );
3510 if ( !ad_3.getName().equals( "abcde" ) ) {
3513 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
3514 p3.getNode( "f" ) );
3515 if ( !af_3.getName().equals( "abcdef" ) ) {
3518 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
3519 p3.getNode( "g" ) );
3520 if ( !ag_3.getName().equals( "" ) ) {
3523 if ( !ag_3.isRoot() ) {
3526 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
3527 p3.getNode( "l" ) );
3528 if ( !al_3.getName().equals( "" ) ) {
3531 if ( !al_3.isRoot() ) {
3534 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
3535 p3.getNode( "l" ) );
3536 if ( !kl_3.getName().equals( "" ) ) {
3539 if ( !kl_3.isRoot() ) {
3542 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
3543 p3.getNode( "l" ) );
3544 if ( !fl_3.getName().equals( "" ) ) {
3547 if ( !fl_3.isRoot() ) {
3550 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
3551 p3.getNode( "k" ) );
3552 if ( !gk_3.getName().equals( "ghijk" ) ) {
3555 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
3556 PhylogenyMethods.preOrderReId( p4 );
3557 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
3558 p4.getNode( "c" ) );
3559 if ( !r_4.getName().equals( "r" ) ) {
3562 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
3563 PhylogenyMethods.preOrderReId( p5 );
3564 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
3565 p5.getNode( "c" ) );
3566 if ( !r_5.getName().equals( "root" ) ) {
3569 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
3570 PhylogenyMethods.preOrderReId( p6 );
3571 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
3572 p6.getNode( "a" ) );
3573 if ( !r_6.getName().equals( "rot" ) ) {
3576 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
3577 PhylogenyMethods.preOrderReId( p7 );
3578 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
3579 p7.getNode( "e" ) );
3580 if ( !r_7.getName().equals( "rott" ) ) {
3583 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
3584 p7.getNode( "a" ) );
3585 if ( !r_71.getName().equals( "rott" ) ) {
3588 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
3589 p7.getNode( "rott" ) );
3590 if ( !r_72.getName().equals( "rott" ) ) {
3593 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
3594 p7.getNode( "a" ) );
3595 if ( !r_73.getName().equals( "rott" ) ) {
3598 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
3599 p7.getNode( "rott" ) );
3600 if ( !r_74.getName().equals( "rott" ) ) {
3603 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
3604 p7.getNode( "e" ) );
3605 if ( !r_75.getName().equals( "e" ) ) {
3609 catch ( final Exception e ) {
3610 e.printStackTrace( System.out );
3616 private static boolean testHmmscanOutputParser() {
3617 final String test_dir = Test.PATH_TO_TEST_DATA;
3619 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
3620 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
3622 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
3623 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
3624 final List<Protein> proteins = parser2.parse();
3625 if ( parser2.getProteinsEncountered() != 4 ) {
3628 if ( proteins.size() != 4 ) {
3631 if ( parser2.getDomainsEncountered() != 69 ) {
3634 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
3637 if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
3640 final Protein p1 = proteins.get( 0 );
3641 if ( p1.getNumberOfProteinDomains() != 15 ) {
3644 if ( p1.getLength() != 850 ) {
3647 final Protein p2 = proteins.get( 1 );
3648 if ( p2.getNumberOfProteinDomains() != 51 ) {
3651 if ( p2.getLength() != 1291 ) {
3654 final Protein p3 = proteins.get( 2 );
3655 if ( p3.getNumberOfProteinDomains() != 2 ) {
3658 final Protein p4 = proteins.get( 3 );
3659 if ( p4.getNumberOfProteinDomains() != 1 ) {
3662 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
3665 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
3668 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
3671 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
3674 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
3677 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
3680 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
3683 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
3686 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
3690 catch ( final Exception e ) {
3691 e.printStackTrace( System.out );
3697 private static boolean testLastExternalNodeMethods() {
3699 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3700 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
3701 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
3702 final PhylogenyNode n1 = t0.getNode( "A" );
3703 if ( n1.isLastExternalNode() ) {
3706 final PhylogenyNode n2 = t0.getNode( "B" );
3707 if ( n2.isLastExternalNode() ) {
3710 final PhylogenyNode n3 = t0.getNode( "C" );
3711 if ( n3.isLastExternalNode() ) {
3714 final PhylogenyNode n4 = t0.getNode( "D" );
3715 if ( !n4.isLastExternalNode() ) {
3719 catch ( final Exception e ) {
3720 e.printStackTrace( System.out );
3726 private static boolean testLevelOrderIterator() {
3728 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3729 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
3730 PhylogenyNodeIterator it0;
3731 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
3734 for( it0.reset(); it0.hasNext(); ) {
3737 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
3738 if ( !it.next().getName().equals( "r" ) ) {
3741 if ( !it.next().getName().equals( "ab" ) ) {
3744 if ( !it.next().getName().equals( "cd" ) ) {
3747 if ( !it.next().getName().equals( "A" ) ) {
3750 if ( !it.next().getName().equals( "B" ) ) {
3753 if ( !it.next().getName().equals( "C" ) ) {
3756 if ( !it.next().getName().equals( "D" ) ) {
3759 if ( it.hasNext() ) {
3762 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",
3763 new NHXParser() )[ 0 ];
3764 PhylogenyNodeIterator it2;
3765 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
3768 for( it2.reset(); it2.hasNext(); ) {
3771 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
3772 if ( !it3.next().getName().equals( "r" ) ) {
3775 if ( !it3.next().getName().equals( "abc" ) ) {
3778 if ( !it3.next().getName().equals( "defg" ) ) {
3781 if ( !it3.next().getName().equals( "A" ) ) {
3784 if ( !it3.next().getName().equals( "B" ) ) {
3787 if ( !it3.next().getName().equals( "C" ) ) {
3790 if ( !it3.next().getName().equals( "D" ) ) {
3793 if ( !it3.next().getName().equals( "E" ) ) {
3796 if ( !it3.next().getName().equals( "F" ) ) {
3799 if ( !it3.next().getName().equals( "G" ) ) {
3802 if ( !it3.next().getName().equals( "1" ) ) {
3805 if ( !it3.next().getName().equals( "2" ) ) {
3808 if ( !it3.next().getName().equals( "3" ) ) {
3811 if ( !it3.next().getName().equals( "4" ) ) {
3814 if ( !it3.next().getName().equals( "5" ) ) {
3817 if ( !it3.next().getName().equals( "6" ) ) {
3820 if ( !it3.next().getName().equals( "f1" ) ) {
3823 if ( !it3.next().getName().equals( "f2" ) ) {
3826 if ( !it3.next().getName().equals( "f3" ) ) {
3829 if ( !it3.next().getName().equals( "a" ) ) {
3832 if ( !it3.next().getName().equals( "b" ) ) {
3835 if ( !it3.next().getName().equals( "f21" ) ) {
3838 if ( !it3.next().getName().equals( "X" ) ) {
3841 if ( !it3.next().getName().equals( "Y" ) ) {
3844 if ( !it3.next().getName().equals( "Z" ) ) {
3847 if ( it3.hasNext() ) {
3850 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
3851 PhylogenyNodeIterator it4;
3852 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
3855 for( it4.reset(); it4.hasNext(); ) {
3858 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
3859 if ( !it5.next().getName().equals( "r" ) ) {
3862 if ( !it5.next().getName().equals( "A" ) ) {
3865 if ( !it5.next().getName().equals( "B" ) ) {
3868 if ( !it5.next().getName().equals( "C" ) ) {
3871 if ( !it5.next().getName().equals( "D" ) ) {
3874 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
3875 PhylogenyNodeIterator it6;
3876 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
3879 for( it6.reset(); it6.hasNext(); ) {
3882 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
3883 if ( !it7.next().getName().equals( "A" ) ) {
3886 if ( it.hasNext() ) {
3890 catch ( final Exception e ) {
3891 e.printStackTrace( System.out );
3897 private static boolean testMidpointrooting() {
3899 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3900 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",
3901 new NHXParser() )[ 0 ];
3902 if ( !t1.isRooted() ) {
3905 PhylogenyMethods.midpointRoot( t1 );
3906 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
3909 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
3912 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
3915 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
3918 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
3921 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
3924 t1.reRoot( t1.getNode( "A" ) );
3925 PhylogenyMethods.midpointRoot( t1 );
3926 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
3929 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
3932 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
3935 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
3938 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
3941 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
3945 catch ( final Exception e ) {
3946 e.printStackTrace( System.out );
3952 private static boolean testNexusCharactersParsing() {
3954 final NexusCharactersParser parser = new NexusCharactersParser();
3955 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
3957 String[] labels = parser.getCharStateLabels();
3958 if ( labels.length != 7 ) {
3961 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
3964 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
3967 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
3970 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
3973 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
3976 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
3979 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
3982 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
3984 labels = parser.getCharStateLabels();
3985 if ( labels.length != 7 ) {
3988 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
3991 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
3994 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
3997 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
4000 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
4003 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
4006 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
4010 catch ( final Exception e ) {
4011 e.printStackTrace( System.out );
4017 private static boolean testNexusMatrixParsing() {
4019 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
4020 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
4022 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
4023 if ( m.getNumberOfCharacters() != 9 ) {
4026 if ( m.getNumberOfIdentifiers() != 5 ) {
4029 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
4032 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
4035 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
4038 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
4041 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
4044 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
4047 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
4050 // if ( labels.length != 7 ) {
4053 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
4056 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
4059 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
4062 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
4065 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
4068 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
4071 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
4074 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
4076 // labels = parser.getCharStateLabels();
4077 // if ( labels.length != 7 ) {
4080 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
4083 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
4086 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
4089 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
4092 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
4095 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
4098 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
4102 catch ( final Exception e ) {
4103 e.printStackTrace( System.out );
4109 private static boolean testNexusTreeParsing() {
4111 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4112 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
4113 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
4114 if ( phylogenies.length != 1 ) {
4117 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
4120 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
4124 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
4125 if ( phylogenies.length != 1 ) {
4128 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
4131 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
4135 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
4136 if ( phylogenies.length != 1 ) {
4139 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
4142 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
4145 if ( phylogenies[ 0 ].isRooted() ) {
4149 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
4150 if ( phylogenies.length != 18 ) {
4153 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
4156 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
4159 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
4162 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
4165 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
4168 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
4171 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
4174 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
4177 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
4180 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
4183 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
4186 if ( phylogenies[ 8 ].isRooted() ) {
4189 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
4192 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
4195 if ( !phylogenies[ 9 ].isRooted() ) {
4198 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
4201 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
4204 if ( !phylogenies[ 10 ].isRooted() ) {
4207 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
4210 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
4213 if ( phylogenies[ 11 ].isRooted() ) {
4216 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
4219 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
4222 if ( !phylogenies[ 12 ].isRooted() ) {
4225 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
4228 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
4231 if ( !phylogenies[ 13 ].isRooted() ) {
4234 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
4237 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
4240 if ( !phylogenies[ 14 ].isRooted() ) {
4243 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
4246 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
4249 if ( phylogenies[ 15 ].isRooted() ) {
4252 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
4255 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
4258 if ( !phylogenies[ 16 ].isRooted() ) {
4261 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
4264 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
4267 if ( phylogenies[ 17 ].isRooted() ) {
4270 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
4274 catch ( final Exception e ) {
4275 e.printStackTrace( System.out );
4281 private static boolean testNexusTreeParsingTranslating() {
4283 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4284 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
4285 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
4286 if ( phylogenies.length != 1 ) {
4289 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
4292 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
4295 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
4298 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
4301 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
4302 .equals( "Aranaeus" ) ) {
4306 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
4307 if ( phylogenies.length != 3 ) {
4310 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
4313 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
4316 if ( phylogenies[ 0 ].isRooted() ) {
4319 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
4322 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
4325 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
4326 .equals( "Aranaeus" ) ) {
4329 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
4332 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
4335 if ( phylogenies[ 1 ].isRooted() ) {
4338 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
4341 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
4344 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
4345 .equals( "Aranaeus" ) ) {
4348 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
4351 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
4354 if ( !phylogenies[ 2 ].isRooted() ) {
4357 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
4360 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
4363 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
4364 .equals( "Aranaeus" ) ) {
4368 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
4369 if ( phylogenies.length != 3 ) {
4372 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
4375 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
4378 if ( phylogenies[ 0 ].isRooted() ) {
4381 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
4384 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
4387 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
4388 .equals( "Aranaeus" ) ) {
4391 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
4394 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
4397 if ( phylogenies[ 1 ].isRooted() ) {
4400 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
4403 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
4406 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
4407 .equals( "Aranaeus" ) ) {
4410 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
4413 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
4416 if ( !phylogenies[ 2 ].isRooted() ) {
4419 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
4422 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
4425 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
4426 .equals( "Aranaeus" ) ) {
4430 catch ( final Exception e ) {
4431 e.printStackTrace( System.out );
4437 private static boolean testNHParsing() {
4439 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4440 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
4441 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
4444 final NHXParser nhxp = new NHXParser();
4445 nhxp.setTaxonomyExtraction( PhylogenyMethods.TAXONOMY_EXTRACTION.NO );
4446 nhxp.setReplaceUnderscores( true );
4447 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
4448 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
4451 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
4454 final Phylogeny p1b = factory
4455 .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 ",
4456 new NHXParser() )[ 0 ];
4457 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
4460 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
4463 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
4464 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
4465 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
4466 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
4467 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
4468 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
4469 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
4470 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
4471 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
4472 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
4473 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
4474 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
4475 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
4477 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
4480 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
4483 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
4486 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
4489 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
4490 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
4491 final String p16_S = "((A,B),C)";
4492 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
4493 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
4496 final String p17_S = "(C,(A,B))";
4497 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
4498 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
4501 final String p18_S = "((A,B),(C,D))";
4502 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
4503 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
4506 final String p19_S = "(((A,B),C),D)";
4507 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
4508 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
4511 final String p20_S = "(A,(B,(C,D)))";
4512 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
4513 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
4516 final String p21_S = "(A,(B,(C,(D,E))))";
4517 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
4518 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
4521 final String p22_S = "((((A,B),C),D),E)";
4522 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
4523 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
4526 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
4527 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
4528 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
4531 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
4532 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
4533 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
4536 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
4537 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
4538 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
4539 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
4542 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
4545 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
4546 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
4547 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
4548 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
4549 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
4550 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
4551 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
4552 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
4553 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
4554 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
4557 final String p26_S = "(A,B)ab";
4558 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
4559 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
4562 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
4563 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
4565 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
4568 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
4569 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
4570 final String p28_S3 = "(A,B)ab";
4571 final String p28_S4 = "((((A,B),C),D),;E;)";
4572 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
4574 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
4577 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
4580 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
4583 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
4586 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";
4587 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
4588 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
4591 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";
4592 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
4593 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
4596 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
4597 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
4598 if ( ( p32.length != 1 ) || !p32[ 0 ].isEmpty() ) {
4601 final String p33_S = "A";
4602 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
4603 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
4606 final String p34_S = "B;";
4607 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
4608 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
4611 final String p35_S = "B:0.2";
4612 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
4613 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
4616 final String p36_S = "(A)";
4617 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
4618 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
4621 final String p37_S = "((A))";
4622 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
4623 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
4626 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
4627 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
4628 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
4631 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
4632 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
4633 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
4636 final String p40_S = "(A,B,C)";
4637 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
4638 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
4641 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
4642 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
4643 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
4646 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
4647 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
4648 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
4651 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)";
4652 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
4653 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
4656 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)))";
4657 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
4658 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
4661 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
4662 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
4663 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
4666 final String p46_S = "";
4667 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
4668 if ( ( p46.length != 1 ) || !p46[ 0 ].isEmpty() ) {
4671 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
4672 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
4675 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
4676 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
4679 final Phylogeny p49 = factory
4680 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
4681 new NHXParser() )[ 0 ];
4682 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
4685 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
4686 if ( p50.getNode( "A" ) == null ) {
4689 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
4690 .equals( "((A,B)ab:2.0[88],C);" ) ) {
4693 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
4696 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
4697 .equals( "((A,B)88:2.0,C);" ) ) {
4700 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
4701 if ( p51.getNode( "A(A" ) == null ) {
4704 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
4705 if ( p52.getNode( "A(A" ) == null ) {
4708 final Phylogeny p53 = factory
4709 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
4710 new NHXParser() )[ 0 ];
4711 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
4715 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
4716 if ( p54.getNode( "A" ) == null ) {
4719 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
4720 .equals( "((A,B)[88],C);" ) ) {
4724 catch ( final Exception e ) {
4725 e.printStackTrace( System.out );
4731 private static boolean testNHXconversion() {
4733 final PhylogenyNode n1 = new PhylogenyNode();
4734 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
4735 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
4736 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
4737 final PhylogenyNode n5 = PhylogenyNode
4738 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1:W=2:C=10.20.30:XN=S=tag1=value1=unit1]" );
4739 final PhylogenyNode n6 = PhylogenyNode
4740 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1:W=2:C=0.0.0:XN=B=bool_tag=T]" );
4741 if ( !n1.toNewHampshireX().equals( "" ) ) {
4744 if ( !n2.toNewHampshireX().equals( "" ) ) {
4747 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
4750 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
4753 if ( !n5.toNewHampshireX()
4754 .equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:XN=S=tag1=value1=unit1:B=56:W=2.0:C=10.20.30]" ) ) {
4757 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:XN=B=bool_tag=T:B=100:W=2.0:C=0.0.0]" ) ) {
4761 catch ( final Exception e ) {
4762 e.printStackTrace( System.out );
4768 private static boolean testNHXNodeParsing() {
4770 final PhylogenyNode n1 = new PhylogenyNode();
4771 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
4772 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
4773 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
4774 final PhylogenyNode n5 = PhylogenyNode
4775 .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]" );
4776 if ( !n3.getName().equals( "n3" ) ) {
4779 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
4782 if ( n3.isDuplication() ) {
4785 if ( n3.isHasAssignedEvent() ) {
4788 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
4791 if ( !n4.getName().equals( "n4" ) ) {
4794 if ( n4.getDistanceToParent() != 0.01 ) {
4797 if ( !n5.getName().equals( "n5" ) ) {
4800 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
4803 if ( n5.getDistanceToParent() != 0.1 ) {
4806 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
4809 if ( !n5.isDuplication() ) {
4812 if ( !n5.isHasAssignedEvent() ) {
4815 if ( PhylogenyMethods.getBranchWidthValue( n5 ) != 2 ) {
4818 if ( n5.getNodeData().getProperties().getPropertyRefs().length != 2 ) {
4821 final PhylogenyNode n8 = PhylogenyNode
4822 .createInstanceFromNhxString( "n8_ECOLI/12:0.01",
4823 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4824 if ( !n8.getName().equals( "n8_ECOLI/12" ) ) {
4827 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
4830 final PhylogenyNode n9 = PhylogenyNode
4831 .createInstanceFromNhxString( "n9_ECOLI/12=12:0.01",
4832 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4833 if ( !n9.getName().equals( "n9_ECOLI/12=12" ) ) {
4836 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
4839 final PhylogenyNode n10 = PhylogenyNode
4840 .createInstanceFromNhxString( "n10.ECOLI", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4841 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
4844 final PhylogenyNode n20 = PhylogenyNode
4845 .createInstanceFromNhxString( "n20_ECOLI/1-2", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4846 if ( !n20.getName().equals( "n20_ECOLI/1-2" ) ) {
4849 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
4852 final PhylogenyNode n20x = PhylogenyNode
4853 .createInstanceFromNhxString( "n20_ECOL1/1-2", PhylogenyMethods.TAXONOMY_EXTRACTION.YES );
4854 if ( !n20x.getName().equals( "n20_ECOL1/1-2" ) ) {
4857 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
4860 final PhylogenyNode n20xx = PhylogenyNode
4861 .createInstanceFromNhxString( "n20_eCOL1/1-2", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4862 if ( !n20xx.getName().equals( "n20_eCOL1/1-2" ) ) {
4865 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
4868 final PhylogenyNode n20xxx = PhylogenyNode
4869 .createInstanceFromNhxString( "n20_ecoli/1-2", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4870 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
4873 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
4876 final PhylogenyNode n20xxxx = PhylogenyNode
4877 .createInstanceFromNhxString( "n20_Ecoli/1-2", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4878 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
4881 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
4884 final PhylogenyNode n21 = PhylogenyNode
4885 .createInstanceFromNhxString( "n21_PIG", PhylogenyMethods.TAXONOMY_EXTRACTION.YES );
4886 if ( !n21.getName().equals( "n21_PIG" ) ) {
4889 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
4892 final PhylogenyNode n21x = PhylogenyNode
4893 .createInstanceFromNhxString( "n21_PIG", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4894 if ( !n21x.getName().equals( "n21_PIG" ) ) {
4897 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
4900 final PhylogenyNode n22 = PhylogenyNode
4901 .createInstanceFromNhxString( "n22/PIG", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4902 if ( !n22.getName().equals( "n22/PIG" ) ) {
4905 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
4908 final PhylogenyNode n23 = PhylogenyNode
4909 .createInstanceFromNhxString( "n23/PIG_1", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4910 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
4913 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
4916 final PhylogenyNode a = PhylogenyNode
4917 .createInstanceFromNhxString( "n10_ECOLI/1-2", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4918 if ( !a.getName().equals( "n10_ECOLI/1-2" ) ) {
4921 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
4924 final PhylogenyNode b = PhylogenyNode
4925 .createInstanceFromNhxString( "n10_ECOLI1/1-2",
4926 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4927 if ( !b.getName().equals( "n10_ECOLI1/1-2" ) ) {
4930 if ( !PhylogenyMethods.getSpecies( b ).equals( "ECOLI" ) ) {
4933 final PhylogenyNode c = PhylogenyNode
4934 .createInstanceFromNhxString( "n10_RATAF12/1000-2000",
4935 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4936 if ( !c.getName().equals( "n10_RATAF12/1000-2000" ) ) {
4939 if ( !PhylogenyMethods.getSpecies( c ).equals( "RATAF" ) ) {
4942 final PhylogenyNode c1 = PhylogenyNode
4943 .createInstanceFromNhxString( "n10_BOVIN_1/1000-2000",
4944 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4945 if ( !c1.getName().equals( "n10_BOVIN_1/1000-2000" ) ) {
4948 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
4951 final PhylogenyNode c2 = PhylogenyNode
4952 .createInstanceFromNhxString( "n10_Bovin_1/1000-2000",
4953 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4954 if ( !c2.getName().equals( "n10_Bovin_1/1000-2000" ) ) {
4957 if ( !PhylogenyMethods.getSpecies( c2 ).equals( "" ) ) {
4960 final PhylogenyNode d = PhylogenyNode
4961 .createInstanceFromNhxString( "n10_RAT1/1-2", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4962 if ( !d.getName().equals( "n10_RAT1/1-2" ) ) {
4965 if ( !PhylogenyMethods.getSpecies( d ).equals( "RAT" ) ) {
4968 final PhylogenyNode e = PhylogenyNode
4969 .createInstanceFromNhxString( "n10_RAT1", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4970 if ( !e.getName().equals( "n10_RAT1" ) ) {
4973 if ( !ForesterUtil.isEmpty( PhylogenyMethods.getSpecies( e ) ) ) {
4976 final PhylogenyNode e2 = PhylogenyNode
4977 .createInstanceFromNhxString( "n10_RAT1", PhylogenyMethods.TAXONOMY_EXTRACTION.YES );
4978 if ( !e2.getName().equals( "n10_RAT1" ) ) {
4981 if ( !PhylogenyMethods.getSpecies( e2 ).equals( "RAT" ) ) {
4984 final PhylogenyNode e3 = PhylogenyNode
4985 .createInstanceFromNhxString( "n10_RAT~", PhylogenyMethods.TAXONOMY_EXTRACTION.YES );
4986 if ( !e3.getName().equals( "n10_RAT~" ) ) {
4989 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
4992 final PhylogenyNode n11 = PhylogenyNode
4993 .createInstanceFromNhxString( "n111111_ECOLI/jdj:0.4",
4994 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
4995 if ( !n11.getName().equals( "n111111_ECOLI/jdj" ) ) {
4998 if ( n11.getDistanceToParent() != 0.4 ) {
5001 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
5004 final PhylogenyNode n12 = PhylogenyNode
5005 .createInstanceFromNhxString( "n111111-ECOLI---/jdj:0.4",
5006 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
5007 if ( !n12.getName().equals( "n111111-ECOLI---/jdj" ) ) {
5010 if ( n12.getDistanceToParent() != 0.4 ) {
5013 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
5016 final PhylogenyNode m = PhylogenyNode
5017 .createInstanceFromNhxString( "n10_MOUSEa", PhylogenyMethods.TAXONOMY_EXTRACTION.YES );
5018 if ( !m.getName().equals( "n10_MOUSEa" ) ) {
5021 if ( !PhylogenyMethods.getSpecies( m ).equals( "MOUSE" ) ) {
5024 final PhylogenyNode o = PhylogenyNode
5025 .createInstanceFromNhxString( "n10_MOUSE_", PhylogenyMethods.TAXONOMY_EXTRACTION.YES );
5026 if ( !o.getName().equals( "n10_MOUSE_" ) ) {
5029 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
5032 final Property tvu1 = n5.getNodeData().getProperties().getProperty( "tag1" );
5033 final Property tvu3 = n5.getNodeData().getProperties().getProperty( "tag3" );
5034 if ( !tvu1.getRef().equals( "tag1" ) ) {
5037 if ( !tvu1.getDataType().equals( "xsd:string" ) ) {
5040 if ( !tvu1.getUnit().equals( "unit1" ) ) {
5043 if ( !tvu1.getValue().equals( "value1" ) ) {
5046 if ( !tvu3.getRef().equals( "tag3" ) ) {
5049 if ( !tvu3.getDataType().equals( "xsd:string" ) ) {
5052 if ( !tvu3.getUnit().equals( "unit3" ) ) {
5055 if ( !tvu3.getValue().equals( "value3" ) ) {
5058 if ( n1.getName().compareTo( "" ) != 0 ) {
5061 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
5064 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
5067 if ( n2.getName().compareTo( "" ) != 0 ) {
5070 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
5073 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
5076 final PhylogenyNode n00 = PhylogenyNode
5077 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:ID=node_identifier:S=Ecoli:D=N:Co=N:B=100:T=1:On=100:SOn=100:SNn=100:W=2:C=0.0.0:XN=U=url_tag=www.yahoo.com]" );
5078 if ( !n00.getNodeData().getNodeIdentifier().getValue().equals( "node_identifier" ) ) {
5081 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
5084 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
5087 if ( !n00.getNodeData().getProperties().getProperty( "url_tag" ).getRef().equals( "url_tag" ) ) {
5090 if ( n00.getNodeData().getProperties().getProperty( "url_tag" ).getAppliesTo() != Property.AppliesTo.NODE ) {
5093 if ( !n00.getNodeData().getProperties().getProperty( "url_tag" ).getDataType().equals( "xsd:anyURI" ) ) {
5096 if ( !n00.getNodeData().getProperties().getProperty( "url_tag" ).getValue().equals( "www.yahoo.com" ) ) {
5099 if ( !n00.getNodeData().getProperties().getProperty( "url_tag" ).getUnit().equals( "" ) ) {
5102 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
5103 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
5106 final PhylogenyNode nx2 = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:G=gene_2]" );
5107 if ( !nx2.getNodeData().getSequence().getName().equals( "gene_2" ) ) {
5110 final PhylogenyNode n13 = PhylogenyNode
5111 .createInstanceFromNhxString( "blah_12345/1-2",
5112 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
5113 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
5116 if ( !PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
5119 final PhylogenyNode n14 = PhylogenyNode
5120 .createInstanceFromNhxString( "blah_12X45/1-2",
5121 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
5122 if ( !n14.getName().equals( "blah_12X45/1-2" ) ) {
5125 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "12X45" ) ) {
5128 final PhylogenyNode n15 = PhylogenyNode
5129 .createInstanceFromNhxString( "something_wicked[123]",
5130 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
5131 if ( !n15.getName().equals( "something_wicked" ) ) {
5134 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
5137 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
5140 final PhylogenyNode n16 = PhylogenyNode
5141 .createInstanceFromNhxString( "something_wicked2[9]",
5142 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
5143 if ( !n16.getName().equals( "something_wicked2" ) ) {
5146 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
5149 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
5152 final PhylogenyNode n17 = PhylogenyNode
5153 .createInstanceFromNhxString( "something_wicked3[a]",
5154 PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
5155 if ( !n17.getName().equals( "something_wicked3" ) ) {
5158 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
5161 final PhylogenyNode n18 = PhylogenyNode
5162 .createInstanceFromNhxString( ":0.5[91]", PhylogenyMethods.TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
5163 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
5166 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
5169 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
5173 catch ( final Exception e ) {
5174 e.printStackTrace( System.out );
5180 private static boolean testNHXParsing() {
5182 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5183 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
5184 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
5187 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]";
5188 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
5189 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
5192 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]";
5193 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
5194 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
5197 final Phylogeny[] p3 = factory
5198 .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]",
5200 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
5203 final Phylogeny[] p4 = factory
5204 .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(]",
5206 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
5209 final Phylogeny[] p5 = factory
5210 .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(((]",
5212 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
5215 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)";
5216 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)";
5217 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
5218 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
5221 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)))";
5222 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)))";
5223 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
5224 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
5227 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]) ))[,,, ])))))))";
5228 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
5229 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
5230 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
5233 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
5234 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
5237 final Phylogeny p10 = factory
5238 .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]",
5239 new NHXParser() )[ 0 ];
5240 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
5244 catch ( final Exception e ) {
5245 e.printStackTrace( System.out );
5251 private static boolean testNHXParsingQuotes() {
5253 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5254 final NHXParser p = new NHXParser();
5255 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
5256 if ( phylogenies_0.length != 5 ) {
5259 final Phylogeny phy = phylogenies_0[ 4 ];
5260 if ( phy.getNumberOfExternalNodes() != 7 ) {
5263 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
5266 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
5269 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
5270 .getScientificName().equals( "hsapiens" ) ) {
5273 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
5276 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
5279 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
5282 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
5285 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
5288 final NHXParser p1p = new NHXParser();
5289 p1p.setIgnoreQuotes( true );
5290 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
5291 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
5294 final NHXParser p2p = new NHXParser();
5295 p1p.setIgnoreQuotes( false );
5296 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
5297 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
5300 final NHXParser p3p = new NHXParser();
5301 p3p.setIgnoreQuotes( false );
5302 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
5303 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
5306 final NHXParser p4p = new NHXParser();
5307 p4p.setIgnoreQuotes( false );
5308 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
5309 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
5312 final Phylogeny p10 = factory
5313 .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]",
5314 new NHXParser() )[ 0 ];
5315 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]";
5316 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
5319 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
5320 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
5324 final Phylogeny p12 = factory
5325 .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]",
5326 new NHXParser() )[ 0 ];
5327 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]";
5328 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
5331 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
5332 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
5335 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;";
5336 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
5339 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
5340 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
5344 catch ( final Exception e ) {
5345 e.printStackTrace( System.out );
5351 private static boolean testNHXParsingMB() {
5353 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5354 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
5355 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
5356 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
5357 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
5358 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
5359 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
5360 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
5361 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
5362 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
5363 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
5366 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
5369 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
5370 0.1100000000000000e+00 ) ) {
5373 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
5376 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
5379 final Phylogeny p2 = factory
5380 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
5381 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
5382 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
5383 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
5384 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
5385 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
5386 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
5387 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
5388 + "7.369400000000000e-02}])",
5389 new NHXParser() )[ 0 ];
5390 if ( p2.getNode( "1" ) == null ) {
5393 if ( p2.getNode( "2" ) == null ) {
5397 catch ( final Exception e ) {
5398 e.printStackTrace( System.out );
5405 private static boolean testPhylogenyBranch() {
5407 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
5408 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
5409 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
5410 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
5411 if ( !a1b1.equals( a1b1 ) ) {
5414 if ( !a1b1.equals( b1a1 ) ) {
5417 if ( !b1a1.equals( a1b1 ) ) {
5420 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
5421 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
5422 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
5423 if ( a1_b1.equals( b1_a1 ) ) {
5426 if ( a1_b1.equals( a1_b1_ ) ) {
5429 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
5430 if ( !a1_b1.equals( b1_a1_ ) ) {
5433 if ( a1_b1_.equals( b1_a1_ ) ) {
5436 if ( !a1_b1_.equals( b1_a1 ) ) {
5440 catch ( final Exception e ) {
5441 e.printStackTrace( System.out );
5447 private static boolean testPhyloXMLparsingOfDistributionElement() {
5449 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5450 PhyloXmlParser xml_parser = null;
5452 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
5454 catch ( final Exception e ) {
5455 // Do nothing -- means were not running from jar.
5457 if ( xml_parser == null ) {
5458 xml_parser = new PhyloXmlParser();
5459 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
5460 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
5463 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
5466 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
5468 if ( xml_parser.getErrorCount() > 0 ) {
5469 System.out.println( xml_parser.getErrorMessages().toString() );
5472 if ( phylogenies_0.length != 1 ) {
5475 final Phylogeny t1 = phylogenies_0[ 0 ];
5476 PhylogenyNode n = null;
5477 Distribution d = null;
5478 n = t1.getNode( "root node" );
5479 if ( !n.getNodeData().isHasDistribution() ) {
5482 if ( n.getNodeData().getDistributions().size() != 1 ) {
5485 d = n.getNodeData().getDistribution();
5486 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
5489 if ( d.getPoints().size() != 1 ) {
5492 if ( d.getPolygons() != null ) {
5495 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
5498 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
5501 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
5504 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
5507 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
5510 n = t1.getNode( "node a" );
5511 if ( !n.getNodeData().isHasDistribution() ) {
5514 if ( n.getNodeData().getDistributions().size() != 2 ) {
5517 d = n.getNodeData().getDistribution( 1 );
5518 if ( !d.getDesc().equals( "San Diego" ) ) {
5521 if ( d.getPoints().size() != 1 ) {
5524 if ( d.getPolygons() != null ) {
5527 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
5530 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
5533 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
5536 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
5539 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
5542 n = t1.getNode( "node bb" );
5543 if ( !n.getNodeData().isHasDistribution() ) {
5546 if ( n.getNodeData().getDistributions().size() != 1 ) {
5549 d = n.getNodeData().getDistribution( 0 );
5550 if ( d.getPoints().size() != 3 ) {
5553 if ( d.getPolygons().size() != 2 ) {
5556 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
5559 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
5562 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
5565 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
5568 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
5571 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
5574 Polygon p = d.getPolygons().get( 0 );
5575 if ( p.getPoints().size() != 3 ) {
5578 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
5581 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
5584 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
5587 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
5590 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
5593 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
5596 p = d.getPolygons().get( 1 );
5597 if ( p.getPoints().size() != 3 ) {
5600 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
5603 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
5606 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
5610 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
5611 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
5612 if ( rt.length != 1 ) {
5615 final Phylogeny t1_rt = rt[ 0 ];
5616 n = t1_rt.getNode( "root node" );
5617 if ( !n.getNodeData().isHasDistribution() ) {
5620 if ( n.getNodeData().getDistributions().size() != 1 ) {
5623 d = n.getNodeData().getDistribution();
5624 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
5627 if ( d.getPoints().size() != 1 ) {
5630 if ( d.getPolygons() != null ) {
5633 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
5636 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
5639 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
5642 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
5645 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
5648 n = t1_rt.getNode( "node a" );
5649 if ( !n.getNodeData().isHasDistribution() ) {
5652 if ( n.getNodeData().getDistributions().size() != 2 ) {
5655 d = n.getNodeData().getDistribution( 1 );
5656 if ( !d.getDesc().equals( "San Diego" ) ) {
5659 if ( d.getPoints().size() != 1 ) {
5662 if ( d.getPolygons() != null ) {
5665 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
5668 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
5671 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
5674 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
5677 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
5680 n = t1_rt.getNode( "node bb" );
5681 if ( !n.getNodeData().isHasDistribution() ) {
5684 if ( n.getNodeData().getDistributions().size() != 1 ) {
5687 d = n.getNodeData().getDistribution( 0 );
5688 if ( d.getPoints().size() != 3 ) {
5691 if ( d.getPolygons().size() != 2 ) {
5694 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
5697 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
5700 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
5703 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
5706 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
5709 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
5712 p = d.getPolygons().get( 0 );
5713 if ( p.getPoints().size() != 3 ) {
5716 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
5719 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
5722 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
5725 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
5728 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
5731 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
5734 p = d.getPolygons().get( 1 );
5735 if ( p.getPoints().size() != 3 ) {
5738 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
5741 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
5744 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
5748 catch ( final Exception e ) {
5749 e.printStackTrace( System.out );
5755 private static boolean testPostOrderIterator() {
5757 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5758 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5759 PhylogenyNodeIterator it0;
5760 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
5763 for( it0.reset(); it0.hasNext(); ) {
5766 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
5767 final PhylogenyNodeIterator it = t1.iteratorPostorder();
5768 if ( !it.next().getName().equals( "A" ) ) {
5771 if ( !it.next().getName().equals( "B" ) ) {
5774 if ( !it.next().getName().equals( "ab" ) ) {
5777 if ( !it.next().getName().equals( "C" ) ) {
5780 if ( !it.next().getName().equals( "D" ) ) {
5783 if ( !it.next().getName().equals( "cd" ) ) {
5786 if ( !it.next().getName().equals( "abcd" ) ) {
5789 if ( !it.next().getName().equals( "E" ) ) {
5792 if ( !it.next().getName().equals( "F" ) ) {
5795 if ( !it.next().getName().equals( "ef" ) ) {
5798 if ( !it.next().getName().equals( "G" ) ) {
5801 if ( !it.next().getName().equals( "H" ) ) {
5804 if ( !it.next().getName().equals( "gh" ) ) {
5807 if ( !it.next().getName().equals( "efgh" ) ) {
5810 if ( !it.next().getName().equals( "r" ) ) {
5813 if ( it.hasNext() ) {
5817 catch ( final Exception e ) {
5818 e.printStackTrace( System.out );
5824 private static boolean testPreOrderIterator() {
5826 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5827 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5828 PhylogenyNodeIterator it0;
5829 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
5832 for( it0.reset(); it0.hasNext(); ) {
5835 PhylogenyNodeIterator it = t0.iteratorPreorder();
5836 if ( !it.next().getName().equals( "r" ) ) {
5839 if ( !it.next().getName().equals( "ab" ) ) {
5842 if ( !it.next().getName().equals( "A" ) ) {
5845 if ( !it.next().getName().equals( "B" ) ) {
5848 if ( !it.next().getName().equals( "cd" ) ) {
5851 if ( !it.next().getName().equals( "C" ) ) {
5854 if ( !it.next().getName().equals( "D" ) ) {
5857 if ( it.hasNext() ) {
5860 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
5861 it = t1.iteratorPreorder();
5862 if ( !it.next().getName().equals( "r" ) ) {
5865 if ( !it.next().getName().equals( "abcd" ) ) {
5868 if ( !it.next().getName().equals( "ab" ) ) {
5871 if ( !it.next().getName().equals( "A" ) ) {
5874 if ( !it.next().getName().equals( "B" ) ) {
5877 if ( !it.next().getName().equals( "cd" ) ) {
5880 if ( !it.next().getName().equals( "C" ) ) {
5883 if ( !it.next().getName().equals( "D" ) ) {
5886 if ( !it.next().getName().equals( "efgh" ) ) {
5889 if ( !it.next().getName().equals( "ef" ) ) {
5892 if ( !it.next().getName().equals( "E" ) ) {
5895 if ( !it.next().getName().equals( "F" ) ) {
5898 if ( !it.next().getName().equals( "gh" ) ) {
5901 if ( !it.next().getName().equals( "G" ) ) {
5904 if ( !it.next().getName().equals( "H" ) ) {
5907 if ( it.hasNext() ) {
5911 catch ( final Exception e ) {
5912 e.printStackTrace( System.out );
5918 private static boolean testPropertiesMap() {
5920 final PropertiesMap pm = new PropertiesMap();
5921 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
5922 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
5923 final Property p2 = new Property( "something:else",
5925 "improbable:research",
5928 pm.addProperty( p0 );
5929 pm.addProperty( p1 );
5930 pm.addProperty( p2 );
5931 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
5934 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
5937 if ( pm.getProperties().size() != 3 ) {
5940 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
5943 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
5946 if ( pm.getProperties().size() != 3 ) {
5949 pm.removeProperty( "dimensions:diameter" );
5950 if ( pm.getProperties().size() != 2 ) {
5953 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
5956 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
5960 catch ( final Exception e ) {
5961 e.printStackTrace( System.out );
5967 private static boolean testReIdMethods() {
5969 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5970 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
5971 final int count = PhylogenyNode.getNodeCount();
5973 if ( p.getNode( "r" ).getId() != count ) {
5976 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
5979 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
5982 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
5985 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
5988 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
5991 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
5994 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
5997 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
6000 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
6003 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
6006 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
6009 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
6012 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
6015 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
6019 catch ( final Exception e ) {
6020 e.printStackTrace( System.out );
6026 private static boolean testRerooting() {
6028 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6029 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",
6030 new NHXParser() )[ 0 ];
6031 if ( !t1.isRooted() ) {
6034 t1.reRoot( t1.getNode( "D" ) );
6035 t1.reRoot( t1.getNode( "CD" ) );
6036 t1.reRoot( t1.getNode( "A" ) );
6037 t1.reRoot( t1.getNode( "B" ) );
6038 t1.reRoot( t1.getNode( "AB" ) );
6039 t1.reRoot( t1.getNode( "D" ) );
6040 t1.reRoot( t1.getNode( "C" ) );
6041 t1.reRoot( t1.getNode( "CD" ) );
6042 t1.reRoot( t1.getNode( "A" ) );
6043 t1.reRoot( t1.getNode( "B" ) );
6044 t1.reRoot( t1.getNode( "AB" ) );
6045 t1.reRoot( t1.getNode( "D" ) );
6046 t1.reRoot( t1.getNode( "D" ) );
6047 t1.reRoot( t1.getNode( "C" ) );
6048 t1.reRoot( t1.getNode( "A" ) );
6049 t1.reRoot( t1.getNode( "B" ) );
6050 t1.reRoot( t1.getNode( "AB" ) );
6051 t1.reRoot( t1.getNode( "C" ) );
6052 t1.reRoot( t1.getNode( "D" ) );
6053 t1.reRoot( t1.getNode( "CD" ) );
6054 t1.reRoot( t1.getNode( "D" ) );
6055 t1.reRoot( t1.getNode( "A" ) );
6056 t1.reRoot( t1.getNode( "B" ) );
6057 t1.reRoot( t1.getNode( "AB" ) );
6058 t1.reRoot( t1.getNode( "C" ) );
6059 t1.reRoot( t1.getNode( "D" ) );
6060 t1.reRoot( t1.getNode( "CD" ) );
6061 t1.reRoot( t1.getNode( "D" ) );
6062 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6065 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6068 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6071 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
6074 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
6077 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
6080 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",
6081 new NHXParser() )[ 0 ];
6082 t2.reRoot( t2.getNode( "A" ) );
6083 t2.reRoot( t2.getNode( "D" ) );
6084 t2.reRoot( t2.getNode( "ABC" ) );
6085 t2.reRoot( t2.getNode( "A" ) );
6086 t2.reRoot( t2.getNode( "B" ) );
6087 t2.reRoot( t2.getNode( "D" ) );
6088 t2.reRoot( t2.getNode( "C" ) );
6089 t2.reRoot( t2.getNode( "ABC" ) );
6090 t2.reRoot( t2.getNode( "A" ) );
6091 t2.reRoot( t2.getNode( "B" ) );
6092 t2.reRoot( t2.getNode( "AB" ) );
6093 t2.reRoot( t2.getNode( "AB" ) );
6094 t2.reRoot( t2.getNode( "D" ) );
6095 t2.reRoot( t2.getNode( "C" ) );
6096 t2.reRoot( t2.getNode( "B" ) );
6097 t2.reRoot( t2.getNode( "AB" ) );
6098 t2.reRoot( t2.getNode( "D" ) );
6099 t2.reRoot( t2.getNode( "D" ) );
6100 t2.reRoot( t2.getNode( "ABC" ) );
6101 t2.reRoot( t2.getNode( "A" ) );
6102 t2.reRoot( t2.getNode( "B" ) );
6103 t2.reRoot( t2.getNode( "AB" ) );
6104 t2.reRoot( t2.getNode( "D" ) );
6105 t2.reRoot( t2.getNode( "C" ) );
6106 t2.reRoot( t2.getNode( "ABC" ) );
6107 t2.reRoot( t2.getNode( "A" ) );
6108 t2.reRoot( t2.getNode( "B" ) );
6109 t2.reRoot( t2.getNode( "AB" ) );
6110 t2.reRoot( t2.getNode( "D" ) );
6111 t2.reRoot( t2.getNode( "D" ) );
6112 t2.reRoot( t2.getNode( "C" ) );
6113 t2.reRoot( t2.getNode( "A" ) );
6114 t2.reRoot( t2.getNode( "B" ) );
6115 t2.reRoot( t2.getNode( "AB" ) );
6116 t2.reRoot( t2.getNode( "C" ) );
6117 t2.reRoot( t2.getNode( "D" ) );
6118 t2.reRoot( t2.getNode( "ABC" ) );
6119 t2.reRoot( t2.getNode( "D" ) );
6120 t2.reRoot( t2.getNode( "A" ) );
6121 t2.reRoot( t2.getNode( "B" ) );
6122 t2.reRoot( t2.getNode( "AB" ) );
6123 t2.reRoot( t2.getNode( "C" ) );
6124 t2.reRoot( t2.getNode( "D" ) );
6125 t2.reRoot( t2.getNode( "ABC" ) );
6126 t2.reRoot( t2.getNode( "D" ) );
6127 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
6130 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
6133 t2.reRoot( t2.getNode( "ABC" ) );
6134 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
6137 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
6140 t2.reRoot( t2.getNode( "AB" ) );
6141 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
6144 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
6147 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
6150 t2.reRoot( t2.getNode( "AB" ) );
6151 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
6154 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
6157 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
6160 t2.reRoot( t2.getNode( "D" ) );
6161 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
6164 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
6167 t2.reRoot( t2.getNode( "ABC" ) );
6168 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
6171 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
6174 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
6175 new NHXParser() )[ 0 ];
6176 t3.reRoot( t3.getNode( "B" ) );
6177 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
6180 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
6183 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
6186 t3.reRoot( t3.getNode( "B" ) );
6187 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
6190 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
6193 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
6196 t3.reRoot( t3.getRoot() );
6197 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
6200 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
6203 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
6207 catch ( final Exception e ) {
6208 e.printStackTrace( System.out );
6214 private static boolean testSDIse() {
6216 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6217 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
6218 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
6219 gene1.setRooted( true );
6220 species1.setRooted( true );
6221 final SDI sdi = new SDIse( gene1, species1 );
6222 if ( !gene1.getRoot().isDuplication() ) {
6225 final Phylogeny species2 = factory
6226 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
6227 new NHXParser() )[ 0 ];
6228 final Phylogeny gene2 = factory
6229 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
6230 new NHXParser() )[ 0 ];
6231 species2.setRooted( true );
6232 gene2.setRooted( true );
6233 final SDI sdi2 = new SDIse( gene2, species2 );
6234 if ( sdi2.getDuplicationsSum() != 0 ) {
6237 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
6240 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
6243 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
6246 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
6249 if ( !gene2.getNode( "r" ).isSpeciation() ) {
6252 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
6255 final Phylogeny species3 = factory
6256 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
6257 new NHXParser() )[ 0 ];
6258 final Phylogeny gene3 = factory
6259 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
6260 new NHXParser() )[ 0 ];
6261 species3.setRooted( true );
6262 gene3.setRooted( true );
6263 final SDI sdi3 = new SDIse( gene3, species3 );
6264 if ( sdi3.getDuplicationsSum() != 1 ) {
6267 if ( !gene3.getNode( "aa" ).isDuplication() ) {
6270 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
6273 final Phylogeny species4 = factory
6274 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
6275 new NHXParser() )[ 0 ];
6276 final Phylogeny gene4 = factory
6277 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
6278 new NHXParser() )[ 0 ];
6279 species4.setRooted( true );
6280 gene4.setRooted( true );
6281 final SDI sdi4 = new SDIse( gene4, species4 );
6282 if ( sdi4.getDuplicationsSum() != 1 ) {
6285 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
6288 if ( !gene4.getNode( "abc" ).isDuplication() ) {
6291 if ( gene4.getNode( "abcd" ).isDuplication() ) {
6294 if ( species4.getNumberOfExternalNodes() != 6 ) {
6297 if ( gene4.getNumberOfExternalNodes() != 6 ) {
6300 final Phylogeny species5 = factory
6301 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
6302 new NHXParser() )[ 0 ];
6303 final Phylogeny gene5 = factory
6304 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
6305 new NHXParser() )[ 0 ];
6306 species5.setRooted( true );
6307 gene5.setRooted( true );
6308 final SDI sdi5 = new SDIse( gene5, species5 );
6309 if ( sdi5.getDuplicationsSum() != 2 ) {
6312 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
6315 if ( !gene5.getNode( "adc" ).isDuplication() ) {
6318 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
6321 if ( species5.getNumberOfExternalNodes() != 6 ) {
6324 if ( gene5.getNumberOfExternalNodes() != 6 ) {
6327 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
6328 // Conjecture for Comparing Molecular Phylogenies"
6329 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
6330 final Phylogeny species6 = factory
6331 .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,"
6332 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
6333 new NHXParser() )[ 0 ];
6334 final Phylogeny gene6 = factory
6335 .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,"
6336 + "((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,"
6337 + "(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;",
6338 new NHXParser() )[ 0 ];
6339 species6.setRooted( true );
6340 gene6.setRooted( true );
6341 final SDI sdi6 = new SDIse( gene6, species6 );
6342 if ( sdi6.getDuplicationsSum() != 3 ) {
6345 if ( !gene6.getNode( "r" ).isDuplication() ) {
6348 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
6351 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
6354 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
6357 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
6360 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
6363 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
6366 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
6369 sdi6.computeMappingCostL();
6370 if ( sdi6.computeMappingCostL() != 17 ) {
6373 if ( species6.getNumberOfExternalNodes() != 9 ) {
6376 if ( gene6.getNumberOfExternalNodes() != 9 ) {
6379 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
6380 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
6381 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
6382 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
6383 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
6384 species7.setRooted( true );
6385 final Phylogeny gene7_1 = Test
6386 .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])" );
6387 gene7_1.setRooted( true );
6388 final SDI sdi7 = new SDIse( gene7_1, species7 );
6389 if ( sdi7.getDuplicationsSum() != 0 ) {
6392 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
6395 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
6398 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
6401 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
6404 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
6407 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
6410 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
6413 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
6416 final Phylogeny gene7_2 = Test
6417 .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])" );
6418 gene7_2.setRooted( true );
6419 final SDI sdi7_2 = new SDIse( gene7_2, species7 );
6420 if ( sdi7_2.getDuplicationsSum() != 1 ) {
6423 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
6426 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
6429 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
6432 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
6435 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
6438 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
6441 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
6444 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
6447 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
6451 catch ( final Exception e ) {
6457 private static boolean testSDIunrooted() {
6459 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6460 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
6461 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
6462 final Iterator<PhylogenyBranch> iter = l.iterator();
6463 PhylogenyBranch br = iter.next();
6464 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
6467 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
6471 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
6474 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
6478 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
6481 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
6485 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
6488 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
6492 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
6495 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
6499 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
6502 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
6506 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
6509 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
6513 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
6516 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
6520 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
6523 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
6527 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
6530 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
6534 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
6537 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
6541 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
6544 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
6548 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
6551 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
6555 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
6558 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
6562 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
6565 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
6568 if ( iter.hasNext() ) {
6571 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
6572 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
6573 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
6575 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
6578 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
6582 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
6585 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
6589 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
6592 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
6595 if ( iter1.hasNext() ) {
6598 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
6599 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
6600 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
6602 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
6605 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
6609 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
6612 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
6616 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
6619 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
6622 if ( iter2.hasNext() ) {
6625 final Phylogeny species0 = factory
6626 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
6627 new NHXParser() )[ 0 ];
6628 final Phylogeny gene1 = factory
6629 .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])",
6630 new NHXParser() )[ 0 ];
6631 species0.setRooted( true );
6632 gene1.setRooted( true );
6633 final SDIR sdi_unrooted = new SDIR();
6634 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
6635 if ( sdi_unrooted.getCount() != 1 ) {
6638 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
6641 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
6644 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
6647 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
6650 final Phylogeny gene2 = factory
6651 .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])",
6652 new NHXParser() )[ 0 ];
6653 gene2.setRooted( true );
6654 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
6655 if ( sdi_unrooted.getCount() != 1 ) {
6658 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
6661 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
6664 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
6667 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
6670 final Phylogeny species6 = factory
6671 .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,"
6672 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
6673 new NHXParser() )[ 0 ];
6674 final Phylogeny gene6 = factory
6675 .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],"
6676 + "(((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],"
6677 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
6678 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
6679 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
6680 new NHXParser() )[ 0 ];
6681 species6.setRooted( true );
6682 gene6.setRooted( true );
6683 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
6684 if ( sdi_unrooted.getCount() != 1 ) {
6687 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
6690 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
6693 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
6696 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
6699 if ( !p6[ 0 ].getRoot().isDuplication() ) {
6702 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
6705 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
6708 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
6711 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
6714 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
6717 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
6720 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
6724 final Phylogeny species7 = factory
6725 .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,"
6726 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
6727 new NHXParser() )[ 0 ];
6728 final Phylogeny gene7 = factory
6729 .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],"
6730 + "(((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],"
6731 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
6732 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
6733 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
6734 new NHXParser() )[ 0 ];
6735 species7.setRooted( true );
6736 gene7.setRooted( true );
6737 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
6738 if ( sdi_unrooted.getCount() != 1 ) {
6741 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
6744 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
6747 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
6750 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
6753 if ( !p7[ 0 ].getRoot().isDuplication() ) {
6756 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
6759 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
6762 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
6765 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
6768 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
6771 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
6774 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
6778 final Phylogeny species8 = factory
6779 .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,"
6780 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
6781 new NHXParser() )[ 0 ];
6782 final Phylogeny gene8 = factory
6783 .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],"
6784 + "(((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],"
6785 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
6786 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
6787 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
6788 new NHXParser() )[ 0 ];
6789 species8.setRooted( true );
6790 gene8.setRooted( true );
6791 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
6792 if ( sdi_unrooted.getCount() != 1 ) {
6795 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
6798 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
6801 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
6804 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
6807 if ( !p8[ 0 ].getRoot().isDuplication() ) {
6810 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
6813 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
6816 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
6819 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
6822 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
6825 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
6828 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
6833 catch ( final Exception e ) {
6834 e.printStackTrace( System.out );
6840 private static boolean testOrthologTable() {
6842 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6843 final Phylogeny s1 = factory.create( Test.PATH_TO_TEST_DATA + "rio_species.xml", new PhyloXmlParser() )[ 0 ];
6844 final NHXParser p = new NHXParser();
6845 p.setTaxonomyExtraction( TAXONOMY_EXTRACTION.YES );
6846 final Phylogeny g1[] = factory.create( new File( Test.PATH_TO_TEST_DATA
6847 + "rio_Bcl-2_e1_20_mafft_05_40_fme.mlt" ), p );
6848 for( final Phylogeny gt : g1 ) {
6849 gt.setRooted( true );
6850 final GSDI sdi = new GSDI( gt, s1, true, true, true );
6852 final IntMatrix m = RIO.calculateOrthologTable( g1 );
6853 // System.out.println( m.toString() );
6855 catch ( final Exception e ) {
6856 e.printStackTrace();
6862 private static boolean testSplit() {
6864 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6865 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
6866 //Archaeopteryx.createApplication( p0 );
6867 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
6868 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
6869 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
6870 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
6871 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
6872 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
6873 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
6874 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
6875 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
6876 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
6877 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
6878 // System.out.println( s0.toString() );
6880 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
6881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
6882 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
6883 if ( s0.match( query_nodes ) ) {
6886 query_nodes = new HashSet<PhylogenyNode>();
6887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
6888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
6889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
6890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
6891 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
6892 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
6893 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
6894 if ( !s0.match( query_nodes ) ) {
6898 query_nodes = new HashSet<PhylogenyNode>();
6899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
6900 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
6901 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
6902 if ( !s0.match( query_nodes ) ) {
6906 query_nodes = new HashSet<PhylogenyNode>();
6907 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
6908 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
6909 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
6910 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
6911 if ( !s0.match( query_nodes ) ) {
6915 query_nodes = new HashSet<PhylogenyNode>();
6916 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
6917 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
6918 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
6919 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
6920 if ( !s0.match( query_nodes ) ) {
6924 query_nodes = new HashSet<PhylogenyNode>();
6925 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
6926 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
6927 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
6928 if ( !s0.match( query_nodes ) ) {
6932 query_nodes = new HashSet<PhylogenyNode>();
6933 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
6934 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
6935 if ( !s0.match( query_nodes ) ) {
6939 query_nodes = new HashSet<PhylogenyNode>();
6940 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
6941 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
6942 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
6943 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
6944 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
6945 if ( !s0.match( query_nodes ) ) {
6949 query_nodes = new HashSet<PhylogenyNode>();
6950 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
6951 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
6952 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
6953 if ( !s0.match( query_nodes ) ) {
6957 query_nodes = new HashSet<PhylogenyNode>();
6958 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
6959 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
6960 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
6961 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
6962 if ( !s0.match( query_nodes ) ) {
6966 query_nodes = new HashSet<PhylogenyNode>();
6967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
6968 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
6969 if ( s0.match( query_nodes ) ) {
6973 query_nodes = new HashSet<PhylogenyNode>();
6974 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
6975 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
6976 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
6977 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
6978 if ( s0.match( query_nodes ) ) {
6982 query_nodes = new HashSet<PhylogenyNode>();
6983 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
6984 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
6985 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
6986 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
6987 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
6988 if ( s0.match( query_nodes ) ) {
6992 query_nodes = new HashSet<PhylogenyNode>();
6993 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
6994 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
6995 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
6996 if ( s0.match( query_nodes ) ) {
7000 query_nodes = new HashSet<PhylogenyNode>();
7001 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7002 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7003 if ( s0.match( query_nodes ) ) {
7007 query_nodes = new HashSet<PhylogenyNode>();
7008 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7009 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7010 if ( s0.match( query_nodes ) ) {
7014 query_nodes = new HashSet<PhylogenyNode>();
7015 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7016 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
7017 if ( s0.match( query_nodes ) ) {
7021 query_nodes = new HashSet<PhylogenyNode>();
7022 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7023 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7024 if ( s0.match( query_nodes ) ) {
7028 query_nodes = new HashSet<PhylogenyNode>();
7029 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7030 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7031 if ( s0.match( query_nodes ) ) {
7035 query_nodes = new HashSet<PhylogenyNode>();
7036 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7037 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7038 if ( s0.match( query_nodes ) ) {
7042 query_nodes = new HashSet<PhylogenyNode>();
7043 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7044 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7045 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7046 if ( s0.match( query_nodes ) ) {
7050 query_nodes = new HashSet<PhylogenyNode>();
7051 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7052 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7053 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7054 if ( s0.match( query_nodes ) ) {
7058 query_nodes = new HashSet<PhylogenyNode>();
7059 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7060 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7061 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7062 if ( s0.match( query_nodes ) ) {
7066 query_nodes = new HashSet<PhylogenyNode>();
7067 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7068 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7069 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7070 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7071 if ( s0.match( query_nodes ) ) {
7075 // query_nodes = new HashSet<PhylogenyNode>();
7076 // query_nodes.add( new PhylogenyNode( "X" ) );
7077 // query_nodes.add( new PhylogenyNode( "Y" ) );
7078 // query_nodes.add( new PhylogenyNode( "A" ) );
7079 // query_nodes.add( new PhylogenyNode( "B" ) );
7080 // query_nodes.add( new PhylogenyNode( "C" ) );
7081 // query_nodes.add( new PhylogenyNode( "D" ) );
7082 // query_nodes.add( new PhylogenyNode( "E" ) );
7083 // query_nodes.add( new PhylogenyNode( "F" ) );
7084 // query_nodes.add( new PhylogenyNode( "G" ) );
7085 // if ( !s0.match( query_nodes ) ) {
7088 // query_nodes = new HashSet<PhylogenyNode>();
7089 // query_nodes.add( new PhylogenyNode( "X" ) );
7090 // query_nodes.add( new PhylogenyNode( "Y" ) );
7091 // query_nodes.add( new PhylogenyNode( "A" ) );
7092 // query_nodes.add( new PhylogenyNode( "B" ) );
7093 // query_nodes.add( new PhylogenyNode( "C" ) );
7094 // if ( !s0.match( query_nodes ) ) {
7098 // query_nodes = new HashSet<PhylogenyNode>();
7099 // query_nodes.add( new PhylogenyNode( "X" ) );
7100 // query_nodes.add( new PhylogenyNode( "Y" ) );
7101 // query_nodes.add( new PhylogenyNode( "D" ) );
7102 // query_nodes.add( new PhylogenyNode( "E" ) );
7103 // query_nodes.add( new PhylogenyNode( "F" ) );
7104 // query_nodes.add( new PhylogenyNode( "G" ) );
7105 // if ( !s0.match( query_nodes ) ) {
7109 // query_nodes = new HashSet<PhylogenyNode>();
7110 // query_nodes.add( new PhylogenyNode( "X" ) );
7111 // query_nodes.add( new PhylogenyNode( "Y" ) );
7112 // query_nodes.add( new PhylogenyNode( "A" ) );
7113 // query_nodes.add( new PhylogenyNode( "B" ) );
7114 // query_nodes.add( new PhylogenyNode( "C" ) );
7115 // query_nodes.add( new PhylogenyNode( "D" ) );
7116 // if ( !s0.match( query_nodes ) ) {
7120 // query_nodes = new HashSet<PhylogenyNode>();
7121 // query_nodes.add( new PhylogenyNode( "X" ) );
7122 // query_nodes.add( new PhylogenyNode( "Y" ) );
7123 // query_nodes.add( new PhylogenyNode( "E" ) );
7124 // query_nodes.add( new PhylogenyNode( "F" ) );
7125 // query_nodes.add( new PhylogenyNode( "G" ) );
7126 // if ( !s0.match( query_nodes ) ) {
7130 // query_nodes = new HashSet<PhylogenyNode>();
7131 // query_nodes.add( new PhylogenyNode( "X" ) );
7132 // query_nodes.add( new PhylogenyNode( "Y" ) );
7133 // query_nodes.add( new PhylogenyNode( "F" ) );
7134 // query_nodes.add( new PhylogenyNode( "G" ) );
7135 // if ( !s0.match( query_nodes ) ) {
7139 query_nodes = new HashSet<PhylogenyNode>();
7140 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
7141 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7142 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7143 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7144 if ( s0.match( query_nodes ) ) {
7148 query_nodes = new HashSet<PhylogenyNode>();
7149 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
7150 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7151 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7152 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7153 if ( s0.match( query_nodes ) ) {
7156 ///////////////////////////
7158 query_nodes = new HashSet<PhylogenyNode>();
7159 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
7160 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7161 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7162 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7163 if ( s0.match( query_nodes ) ) {
7167 query_nodes = new HashSet<PhylogenyNode>();
7168 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
7169 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7170 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7171 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7172 if ( s0.match( query_nodes ) ) {
7176 query_nodes = new HashSet<PhylogenyNode>();
7177 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
7178 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7179 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7180 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
7181 if ( s0.match( query_nodes ) ) {
7185 query_nodes = new HashSet<PhylogenyNode>();
7186 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
7187 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7188 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7189 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7190 if ( s0.match( query_nodes ) ) {
7194 query_nodes = new HashSet<PhylogenyNode>();
7195 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
7196 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7197 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7198 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7199 if ( s0.match( query_nodes ) ) {
7203 query_nodes = new HashSet<PhylogenyNode>();
7204 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7205 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7206 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7207 if ( s0.match( query_nodes ) ) {
7211 query_nodes = new HashSet<PhylogenyNode>();
7212 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
7213 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7214 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7215 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7216 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7217 if ( s0.match( query_nodes ) ) {
7221 query_nodes = new HashSet<PhylogenyNode>();
7222 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
7223 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7224 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7225 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7226 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7227 if ( s0.match( query_nodes ) ) {
7231 query_nodes = new HashSet<PhylogenyNode>();
7232 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
7233 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7234 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7235 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7236 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7237 if ( s0.match( query_nodes ) ) {
7241 query_nodes = new HashSet<PhylogenyNode>();
7242 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
7243 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
7244 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7245 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7246 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7247 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7248 if ( s0.match( query_nodes ) ) {
7252 catch ( final Exception e ) {
7253 e.printStackTrace();
7259 private static boolean testSplitStrict() {
7261 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7262 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
7263 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
7264 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7265 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7266 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
7267 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7268 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7269 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7270 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7271 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
7272 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
7273 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7274 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7275 if ( s0.match( query_nodes ) ) {
7278 query_nodes = new HashSet<PhylogenyNode>();
7279 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7280 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7281 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
7282 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7283 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7284 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7285 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7286 if ( !s0.match( query_nodes ) ) {
7290 query_nodes = new HashSet<PhylogenyNode>();
7291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7292 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7293 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
7294 if ( !s0.match( query_nodes ) ) {
7298 query_nodes = new HashSet<PhylogenyNode>();
7299 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7300 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7301 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7302 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7303 if ( !s0.match( query_nodes ) ) {
7307 query_nodes = new HashSet<PhylogenyNode>();
7308 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7309 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7310 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
7311 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7312 if ( !s0.match( query_nodes ) ) {
7316 query_nodes = new HashSet<PhylogenyNode>();
7317 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7318 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7319 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7320 if ( !s0.match( query_nodes ) ) {
7324 query_nodes = new HashSet<PhylogenyNode>();
7325 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7326 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7327 if ( !s0.match( query_nodes ) ) {
7331 query_nodes = new HashSet<PhylogenyNode>();
7332 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7333 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7334 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
7335 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7336 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7337 if ( !s0.match( query_nodes ) ) {
7341 query_nodes = new HashSet<PhylogenyNode>();
7342 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7343 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7344 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7345 if ( !s0.match( query_nodes ) ) {
7349 query_nodes = new HashSet<PhylogenyNode>();
7350 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7351 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7352 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7353 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7354 if ( !s0.match( query_nodes ) ) {
7358 query_nodes = new HashSet<PhylogenyNode>();
7359 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7360 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7361 if ( s0.match( query_nodes ) ) {
7365 query_nodes = new HashSet<PhylogenyNode>();
7366 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7367 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7368 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7369 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
7370 if ( s0.match( query_nodes ) ) {
7374 query_nodes = new HashSet<PhylogenyNode>();
7375 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7376 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7377 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7378 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7379 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
7380 if ( s0.match( query_nodes ) ) {
7384 query_nodes = new HashSet<PhylogenyNode>();
7385 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7386 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7387 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7388 if ( s0.match( query_nodes ) ) {
7392 query_nodes = new HashSet<PhylogenyNode>();
7393 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7394 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7395 if ( s0.match( query_nodes ) ) {
7399 query_nodes = new HashSet<PhylogenyNode>();
7400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7401 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7402 if ( s0.match( query_nodes ) ) {
7406 query_nodes = new HashSet<PhylogenyNode>();
7407 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7408 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
7409 if ( s0.match( query_nodes ) ) {
7413 query_nodes = new HashSet<PhylogenyNode>();
7414 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7415 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7416 if ( s0.match( query_nodes ) ) {
7420 query_nodes = new HashSet<PhylogenyNode>();
7421 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7422 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7423 if ( s0.match( query_nodes ) ) {
7427 query_nodes = new HashSet<PhylogenyNode>();
7428 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7429 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7430 if ( s0.match( query_nodes ) ) {
7434 query_nodes = new HashSet<PhylogenyNode>();
7435 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7436 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
7437 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7438 if ( s0.match( query_nodes ) ) {
7442 query_nodes = new HashSet<PhylogenyNode>();
7443 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7444 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
7445 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7446 if ( s0.match( query_nodes ) ) {
7450 query_nodes = new HashSet<PhylogenyNode>();
7451 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7452 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7453 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7454 if ( s0.match( query_nodes ) ) {
7458 query_nodes = new HashSet<PhylogenyNode>();
7459 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
7460 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
7461 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
7462 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
7463 if ( s0.match( query_nodes ) ) {
7467 catch ( final Exception e ) {
7468 e.printStackTrace();
7474 private static boolean testSubtreeDeletion() {
7476 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7477 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
7478 t1.deleteSubtree( t1.getNode( "A" ), false );
7479 if ( t1.getNumberOfExternalNodes() != 5 ) {
7482 t1.toNewHampshireX();
7483 t1.deleteSubtree( t1.getNode( "E" ), false );
7484 if ( t1.getNumberOfExternalNodes() != 4 ) {
7487 t1.toNewHampshireX();
7488 t1.deleteSubtree( t1.getNode( "F" ), false );
7489 if ( t1.getNumberOfExternalNodes() != 3 ) {
7492 t1.toNewHampshireX();
7493 t1.deleteSubtree( t1.getNode( "D" ), false );
7494 t1.toNewHampshireX();
7495 if ( t1.getNumberOfExternalNodes() != 3 ) {
7498 t1.deleteSubtree( t1.getNode( "def" ), false );
7499 t1.toNewHampshireX();
7500 if ( t1.getNumberOfExternalNodes() != 2 ) {
7503 t1.deleteSubtree( t1.getNode( "B" ), false );
7504 t1.toNewHampshireX();
7505 if ( t1.getNumberOfExternalNodes() != 1 ) {
7508 t1.deleteSubtree( t1.getNode( "C" ), false );
7509 t1.toNewHampshireX();
7510 if ( t1.getNumberOfExternalNodes() != 1 ) {
7513 t1.deleteSubtree( t1.getNode( "abc" ), false );
7514 t1.toNewHampshireX();
7515 if ( t1.getNumberOfExternalNodes() != 1 ) {
7518 t1.deleteSubtree( t1.getNode( "r" ), false );
7519 if ( t1.getNumberOfExternalNodes() != 0 ) {
7522 if ( !t1.isEmpty() ) {
7525 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
7526 t2.deleteSubtree( t2.getNode( "A" ), false );
7527 t2.toNewHampshireX();
7528 if ( t2.getNumberOfExternalNodes() != 5 ) {
7531 t2.deleteSubtree( t2.getNode( "abc" ), false );
7532 t2.toNewHampshireX();
7533 if ( t2.getNumberOfExternalNodes() != 3 ) {
7536 t2.deleteSubtree( t2.getNode( "def" ), false );
7537 t2.toNewHampshireX();
7538 if ( t2.getNumberOfExternalNodes() != 1 ) {
7542 catch ( final Exception e ) {
7543 e.printStackTrace( System.out );
7549 private static boolean testSupportCount() {
7551 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7552 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
7553 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
7554 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
7555 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
7556 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
7557 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
7559 SupportCount.count( t0_1, phylogenies_1, true, false );
7560 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
7561 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
7562 + "(((((A,B),C),D),E),((F,G),X))"
7563 + "(((((A,Y),B),C),D),((F,G),E))"
7564 + "(((((A,B),C),D),E),(F,G))"
7565 + "(((((A,B),C),D),E),(F,G))"
7566 + "(((((A,B),C),D),E),(F,G))"
7567 + "(((((A,B),C),D),E),(F,G),Z)"
7568 + "(((((A,B),C),D),E),(F,G))"
7569 + "((((((A,B),C),D),E),F),G)"
7570 + "(((((X,Y),F,G),E),((A,B),C)),D)",
7572 SupportCount.count( t0_2, phylogenies_2, true, false );
7573 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
7574 while ( it.hasNext() ) {
7575 final PhylogenyNode n = it.next();
7576 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
7580 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
7581 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
7582 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
7583 SupportCount.count( t0_3, phylogenies_3, true, false );
7584 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
7585 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
7588 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
7591 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
7594 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
7597 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
7600 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
7603 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
7606 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
7609 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
7612 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
7615 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
7616 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
7617 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
7618 SupportCount.count( t0_4, phylogenies_4, true, false );
7619 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
7620 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
7623 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
7626 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
7629 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
7632 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
7635 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
7638 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
7641 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
7644 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
7647 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
7650 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
7651 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
7652 double d = SupportCount.compare( b1, a, true, true, true );
7653 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
7656 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
7657 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
7658 d = SupportCount.compare( b2, a, true, true, true );
7659 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
7662 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
7663 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
7664 d = SupportCount.compare( b3, a, true, true, true );
7665 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
7668 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
7669 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
7670 d = SupportCount.compare( b4, a, true, true, false );
7671 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
7675 catch ( final Exception e ) {
7676 e.printStackTrace( System.out );
7682 private static boolean testSupportTransfer() {
7684 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7685 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)",
7686 new NHXParser() )[ 0 ];
7687 final Phylogeny p2 = factory
7688 .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 ];
7689 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
7692 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
7695 support_transfer.moveBranchLengthsToBootstrap( p1 );
7696 support_transfer.transferSupportValues( p1, p2 );
7697 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
7700 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
7703 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
7706 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
7709 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
7712 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
7715 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
7718 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
7722 catch ( final Exception e ) {
7723 e.printStackTrace( System.out );
7729 private static boolean testUniprotTaxonomySearch() {
7731 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
7733 if ( results.size() != 1 ) {
7736 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
7739 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
7742 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
7745 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
7748 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
7752 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
7753 if ( results.size() != 1 ) {
7756 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
7759 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
7762 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
7765 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
7768 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
7772 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
7773 if ( results.size() != 1 ) {
7776 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
7779 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
7782 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
7785 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
7788 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
7792 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
7793 if ( results.size() != 1 ) {
7796 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
7799 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
7802 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
7805 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
7808 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
7811 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
7814 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
7817 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
7818 .equals( "Nematostella vectensis" ) ) {
7819 System.out.println( results.get( 0 ).getLineage() );
7823 catch ( final IOException e ) {
7824 System.out.println();
7825 System.out.println( "the following might be due to absence internet connection:" );
7826 e.printStackTrace( System.out );
7829 catch ( final Exception e ) {
7835 private static boolean testEmblEntryRetrieval() {
7836 //The format for GenBank Accession numbers are:
7837 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
7838 //Protein: 3 letters + 5 numerals
7839 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
7840 if ( !SequenceIdParser.parseGenbankAccessor( "AY423861" ).equals( "AY423861" ) ) {
7843 if ( !SequenceIdParser.parseGenbankAccessor( ".AY423861." ).equals( "AY423861" ) ) {
7846 if ( SequenceIdParser.parseGenbankAccessor( "AAY423861" ) != null ) {
7849 if ( SequenceIdParser.parseGenbankAccessor( "AY4238612" ) != null ) {
7852 if ( SequenceIdParser.parseGenbankAccessor( "AAY4238612" ) != null ) {
7855 if ( SequenceIdParser.parseGenbankAccessor( "Y423861" ) != null ) {
7858 if ( !SequenceIdParser.parseGenbankAccessor( "S12345" ).equals( "S12345" ) ) {
7861 if ( !SequenceIdParser.parseGenbankAccessor( "|S12345|" ).equals( "S12345" ) ) {
7864 if ( SequenceIdParser.parseGenbankAccessor( "|S123456" ) != null ) {
7867 if ( SequenceIdParser.parseGenbankAccessor( "ABC123456" ) != null ) {
7870 if ( !SequenceIdParser.parseGenbankAccessor( "ABC12345" ).equals( "ABC12345" ) ) {
7873 if ( !SequenceIdParser.parseGenbankAccessor( "&ABC12345&" ).equals( "ABC12345" ) ) {
7876 if ( SequenceIdParser.parseGenbankAccessor( "ABCD12345" ) != null ) {
7882 private static boolean testUniprotEntryRetrieval() {
7883 if ( !SequenceDbWsTools.parseUniProtAccessor( "P12345" ).equals( "P12345" ) ) {
7886 if ( SequenceDbWsTools.parseUniProtAccessor( "EP12345" ) != null ) {
7889 if ( SequenceDbWsTools.parseUniProtAccessor( "3 4P12345" ) != null ) {
7892 if ( SequenceDbWsTools.parseUniProtAccessor( "P12345E" ) != null ) {
7895 if ( SequenceDbWsTools.parseUniProtAccessor( "P123455" ) != null ) {
7898 if ( SequenceDbWsTools.parseUniProtAccessor( "EP12345E" ) != null ) {
7901 if ( SequenceDbWsTools.parseUniProtAccessor( "AY423861" ) != null ) {
7904 if ( !SequenceDbWsTools.parseUniProtAccessor( "P1DDD5" ).equals( "P1DDD5" ) ) {
7907 if ( SequenceDbWsTools.parseUniProtAccessor( "P1DDDD" ) != null ) {
7910 if ( !SequenceDbWsTools.parseUniProtAccessor( "P1234X/P12345/12-42" ).equals( "P12345" ) ) {
7913 if ( !SequenceDbWsTools.parseUniProtAccessor( "P1234X P12345 12-42" ).equals( "P12345" ) ) {
7916 if ( !SequenceDbWsTools.parseUniProtAccessor( "P12345/12-42" ).equals( "P12345" ) ) {
7919 if ( !SequenceDbWsTools.parseUniProtAccessor( "P1234X/P12345" ).equals( "P12345" ) ) {
7923 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
7924 if ( !entry.getAccession().equals( "P12345" ) ) {
7927 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
7930 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
7933 if ( !entry.getSequenceSymbol().equals( "GOT2" ) ) {
7936 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
7940 catch ( final IOException e ) {
7941 System.out.println();
7942 System.out.println( "the following might be due to absence internet connection:" );
7943 e.printStackTrace( System.out );
7946 catch ( final Exception e ) {
7952 private static boolean testWabiTxSearch() {
7955 result = TxSearch.searchSimple( "nematostella" );
7956 result = TxSearch.getTxId( "nematostella" );
7957 if ( !result.equals( "45350" ) ) {
7960 result = TxSearch.getTxName( "45350" );
7961 if ( !result.equals( "Nematostella" ) ) {
7964 result = TxSearch.getTxId( "nematostella vectensis" );
7965 if ( !result.equals( "45351" ) ) {
7968 result = TxSearch.getTxName( "45351" );
7969 if ( !result.equals( "Nematostella vectensis" ) ) {
7972 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
7973 if ( !result.equals( "536089" ) ) {
7976 result = TxSearch.getTxName( "536089" );
7977 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
7980 final List<String> queries = new ArrayList<String>();
7981 queries.add( "Campylobacter coli" );
7982 queries.add( "Escherichia coli" );
7983 queries.add( "Arabidopsis" );
7984 queries.add( "Trichoplax" );
7985 queries.add( "Samanea saman" );
7986 queries.add( "Kluyveromyces marxianus" );
7987 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
7988 queries.add( "Bornavirus parrot/PDD/2008" );
7989 final List<RANKS> ranks = new ArrayList<RANKS>();
7990 ranks.add( RANKS.SUPERKINGDOM );
7991 ranks.add( RANKS.KINGDOM );
7992 ranks.add( RANKS.FAMILY );
7993 ranks.add( RANKS.GENUS );
7994 ranks.add( RANKS.TRIBE );
7995 result = TxSearch.searchLineage( queries, ranks );
7996 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
7997 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
7999 catch ( final Exception e ) {
8000 System.out.println();
8001 System.out.println( "the following might be due to absence internet connection:" );
8002 e.printStackTrace( System.out );
8008 private static boolean testAminoAcidSequence() {
8010 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
8011 if ( aa1.getLength() != 13 ) {
8014 if ( aa1.getResidueAt( 0 ) != 'A' ) {
8017 if ( aa1.getResidueAt( 2 ) != 'K' ) {
8020 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
8023 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
8024 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
8027 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
8028 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
8031 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
8032 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
8036 catch ( final Exception e ) {
8037 e.printStackTrace();
8043 private static boolean testCreateBalancedPhylogeny() {
8045 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
8046 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
8049 if ( p0.getNumberOfExternalNodes() != 15625 ) {
8052 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
8053 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
8056 if ( p1.getNumberOfExternalNodes() != 100 ) {
8060 catch ( final Exception e ) {
8061 e.printStackTrace();
8067 private static boolean testFastaParser() {
8069 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
8072 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
8075 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
8076 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
8079 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
8082 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
8085 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
8088 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
8091 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
8095 catch ( final Exception e ) {
8096 e.printStackTrace();
8102 private static boolean testGeneralMsaParser() {
8104 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
8105 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
8106 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
8107 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
8108 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
8109 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
8110 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
8111 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
8112 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
8115 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
8118 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
8121 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
8124 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
8127 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
8130 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
8133 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
8136 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
8139 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
8142 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
8145 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
8148 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
8149 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
8152 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
8155 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
8158 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
8159 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
8162 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
8165 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
8168 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
8169 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
8172 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
8175 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
8179 catch ( final Exception e ) {
8180 e.printStackTrace();
8186 private static boolean testMafft( final String path ) {
8188 final List<String> opts = new ArrayList<String>();
8189 opts.add( "--maxiterate" );
8191 opts.add( "--localpair" );
8192 opts.add( "--quiet" );
8194 final MsaInferrer mafft = Mafft.createInstance( path );
8195 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
8196 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
8199 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
8203 catch ( final Exception e ) {
8204 e.printStackTrace( System.out );
8210 private static boolean testNextNodeWithCollapsing() {
8212 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8214 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
8215 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
8216 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
8217 t0.getNode( "cd" ).setCollapse( true );
8218 t0.getNode( "cde" ).setCollapse( true );
8219 n = t0.getFirstExternalNode();
8220 while ( n != null ) {
8222 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8224 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
8227 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
8230 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
8233 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
8236 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
8239 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
8243 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
8244 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
8245 t1.getNode( "ab" ).setCollapse( true );
8246 t1.getNode( "cd" ).setCollapse( true );
8247 t1.getNode( "cde" ).setCollapse( true );
8248 n = t1.getNode( "ab" );
8249 ext = new ArrayList<PhylogenyNode>();
8250 while ( n != null ) {
8252 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8254 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
8257 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
8260 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
8263 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
8266 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
8272 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
8273 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
8274 t2.getNode( "ab" ).setCollapse( true );
8275 t2.getNode( "cd" ).setCollapse( true );
8276 t2.getNode( "cde" ).setCollapse( true );
8277 t2.getNode( "c" ).setCollapse( true );
8278 t2.getNode( "d" ).setCollapse( true );
8279 t2.getNode( "e" ).setCollapse( true );
8280 t2.getNode( "gh" ).setCollapse( true );
8281 n = t2.getNode( "ab" );
8282 ext = new ArrayList<PhylogenyNode>();
8283 while ( n != null ) {
8285 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8287 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
8290 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
8293 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
8296 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
8302 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
8303 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
8304 t3.getNode( "ab" ).setCollapse( true );
8305 t3.getNode( "cd" ).setCollapse( true );
8306 t3.getNode( "cde" ).setCollapse( true );
8307 t3.getNode( "c" ).setCollapse( true );
8308 t3.getNode( "d" ).setCollapse( true );
8309 t3.getNode( "e" ).setCollapse( true );
8310 t3.getNode( "gh" ).setCollapse( true );
8311 t3.getNode( "fgh" ).setCollapse( true );
8312 n = t3.getNode( "ab" );
8313 ext = new ArrayList<PhylogenyNode>();
8314 while ( n != null ) {
8316 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8318 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
8321 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
8324 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
8330 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
8331 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
8332 t4.getNode( "ab" ).setCollapse( true );
8333 t4.getNode( "cd" ).setCollapse( true );
8334 t4.getNode( "cde" ).setCollapse( true );
8335 t4.getNode( "c" ).setCollapse( true );
8336 t4.getNode( "d" ).setCollapse( true );
8337 t4.getNode( "e" ).setCollapse( true );
8338 t4.getNode( "gh" ).setCollapse( true );
8339 t4.getNode( "fgh" ).setCollapse( true );
8340 t4.getNode( "abcdefgh" ).setCollapse( true );
8341 n = t4.getNode( "abcdefgh" );
8342 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
8347 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
8348 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
8350 n = t5.getFirstExternalNode();
8351 while ( n != null ) {
8353 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8355 if ( ext.size() != 8 ) {
8358 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
8361 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
8364 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
8367 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
8370 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
8373 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
8376 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
8379 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
8384 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
8385 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
8387 t6.getNode( "ab" ).setCollapse( true );
8388 n = t6.getNode( "ab" );
8389 while ( n != null ) {
8391 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8393 if ( ext.size() != 7 ) {
8396 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
8399 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
8402 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
8405 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
8408 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
8411 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
8414 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
8419 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
8420 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
8422 t7.getNode( "cd" ).setCollapse( true );
8423 n = t7.getNode( "a" );
8424 while ( n != null ) {
8426 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8428 if ( ext.size() != 7 ) {
8431 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
8434 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
8437 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
8440 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
8443 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
8446 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
8449 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
8454 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
8455 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
8457 t8.getNode( "cd" ).setCollapse( true );
8458 t8.getNode( "c" ).setCollapse( true );
8459 t8.getNode( "d" ).setCollapse( true );
8460 n = t8.getNode( "a" );
8461 while ( n != null ) {
8463 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8465 if ( ext.size() != 7 ) {
8468 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
8471 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
8474 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
8475 System.out.println( "2 fail" );
8478 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
8481 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
8484 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
8487 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
8492 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
8493 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
8495 t9.getNode( "gh" ).setCollapse( true );
8496 n = t9.getNode( "a" );
8497 while ( n != null ) {
8499 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8501 if ( ext.size() != 7 ) {
8504 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
8507 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
8510 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
8513 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
8516 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
8519 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
8522 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
8527 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
8528 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
8530 t10.getNode( "gh" ).setCollapse( true );
8531 t10.getNode( "g" ).setCollapse( true );
8532 t10.getNode( "h" ).setCollapse( true );
8533 n = t10.getNode( "a" );
8534 while ( n != null ) {
8536 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8538 if ( ext.size() != 7 ) {
8541 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
8544 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
8547 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
8550 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
8553 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
8556 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
8559 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
8564 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
8565 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
8567 t11.getNode( "gh" ).setCollapse( true );
8568 t11.getNode( "fgh" ).setCollapse( true );
8569 n = t11.getNode( "a" );
8570 while ( n != null ) {
8572 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8574 if ( ext.size() != 6 ) {
8577 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
8580 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
8583 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
8586 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
8589 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
8592 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
8597 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
8598 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
8600 t12.getNode( "gh" ).setCollapse( true );
8601 t12.getNode( "fgh" ).setCollapse( true );
8602 t12.getNode( "g" ).setCollapse( true );
8603 t12.getNode( "h" ).setCollapse( true );
8604 t12.getNode( "f" ).setCollapse( true );
8605 n = t12.getNode( "a" );
8606 while ( n != null ) {
8608 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8610 if ( ext.size() != 6 ) {
8613 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
8616 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
8619 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
8622 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
8625 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
8628 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
8633 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
8634 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
8636 t13.getNode( "ab" ).setCollapse( true );
8637 t13.getNode( "b" ).setCollapse( true );
8638 t13.getNode( "fgh" ).setCollapse( true );
8639 t13.getNode( "gh" ).setCollapse( true );
8640 n = t13.getNode( "ab" );
8641 while ( n != null ) {
8643 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8645 if ( ext.size() != 5 ) {
8648 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
8651 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
8654 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
8657 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
8660 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
8665 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
8666 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
8668 t14.getNode( "ab" ).setCollapse( true );
8669 t14.getNode( "a" ).setCollapse( true );
8670 t14.getNode( "fgh" ).setCollapse( true );
8671 t14.getNode( "gh" ).setCollapse( true );
8672 n = t14.getNode( "ab" );
8673 while ( n != null ) {
8675 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8677 if ( ext.size() != 5 ) {
8680 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
8683 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
8686 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
8689 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
8692 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
8697 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" );
8698 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
8700 t15.getNode( "ab" ).setCollapse( true );
8701 t15.getNode( "a" ).setCollapse( true );
8702 t15.getNode( "fgh" ).setCollapse( true );
8703 t15.getNode( "gh" ).setCollapse( true );
8704 n = t15.getNode( "ab" );
8705 while ( n != null ) {
8707 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8709 if ( ext.size() != 6 ) {
8712 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
8715 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
8718 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
8721 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
8724 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
8727 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
8732 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" );
8733 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
8735 t16.getNode( "ab" ).setCollapse( true );
8736 t16.getNode( "a" ).setCollapse( true );
8737 t16.getNode( "fgh" ).setCollapse( true );
8738 t16.getNode( "gh" ).setCollapse( true );
8739 t16.getNode( "cd" ).setCollapse( true );
8740 t16.getNode( "cde" ).setCollapse( true );
8741 t16.getNode( "d" ).setCollapse( true );
8742 t16.getNode( "x" ).setCollapse( true );
8743 n = t16.getNode( "ab" );
8744 while ( n != null ) {
8746 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
8748 if ( ext.size() != 4 ) {
8751 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
8754 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
8757 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
8760 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
8764 catch ( final Exception e ) {
8765 e.printStackTrace( System.out );
8771 private static boolean testMsaQualityMethod() {
8773 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
8774 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
8775 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
8776 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
8777 final List<Sequence> l = new ArrayList<Sequence>();
8782 final Msa msa = BasicMsa.createInstance( l );
8783 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
8786 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
8789 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
8792 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
8796 catch ( final Exception e ) {
8797 e.printStackTrace( System.out );
8803 private static boolean testSequenceIdParsing() {
8805 Identifier id = SequenceIdParser.parse( "gb_ADF31344_segmented_worms_" );
8806 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
8807 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
8809 System.out.println( "value =" + id.getValue() );
8810 System.out.println( "provider=" + id.getProvider() );
8815 id = SequenceIdParser.parse( "segmented worms|gb_ADF31344" );
8816 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
8817 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
8819 System.out.println( "value =" + id.getValue() );
8820 System.out.println( "provider=" + id.getProvider() );
8825 id = SequenceIdParser.parse( "segmented worms gb_ADF31344 and more" );
8826 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
8827 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
8829 System.out.println( "value =" + id.getValue() );
8830 System.out.println( "provider=" + id.getProvider() );
8835 id = SequenceIdParser.parse( "gb_AAA96518_1" );
8836 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
8837 || !id.getValue().equals( "AAA96518" ) || !id.getProvider().equals( "ncbi" ) ) {
8839 System.out.println( "value =" + id.getValue() );
8840 System.out.println( "provider=" + id.getProvider() );
8845 id = SequenceIdParser.parse( "gb_EHB07727_1_rodents_" );
8846 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
8847 || !id.getValue().equals( "EHB07727" ) || !id.getProvider().equals( "ncbi" ) ) {
8849 System.out.println( "value =" + id.getValue() );
8850 System.out.println( "provider=" + id.getProvider() );
8855 id = SequenceIdParser.parse( "dbj_BAF37827_1_turtles_" );
8856 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
8857 || !id.getValue().equals( "BAF37827" ) || !id.getProvider().equals( "ncbi" ) ) {
8859 System.out.println( "value =" + id.getValue() );
8860 System.out.println( "provider=" + id.getProvider() );
8865 id = SequenceIdParser.parse( "emb_CAA73223_1_primates_" );
8866 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
8867 || !id.getValue().equals( "CAA73223" ) || !id.getProvider().equals( "ncbi" ) ) {
8869 System.out.println( "value =" + id.getValue() );
8870 System.out.println( "provider=" + id.getProvider() );
8875 id = SequenceIdParser.parse( "mites|ref_XP_002434188_1" );
8876 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
8877 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
8879 System.out.println( "value =" + id.getValue() );
8880 System.out.println( "provider=" + id.getProvider() );
8885 id = SequenceIdParser.parse( "mites_ref_XP_002434188_1_bla_XP_12345" );
8886 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
8887 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
8889 System.out.println( "value =" + id.getValue() );
8890 System.out.println( "provider=" + id.getProvider() );
8895 id = SequenceIdParser.parse( "P4A123" );
8896 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
8897 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
8899 System.out.println( "value =" + id.getValue() );
8900 System.out.println( "provider=" + id.getProvider() );
8905 id = SequenceIdParser.parse( "pllf[pok P4A123_osdjfosnqo035-9233332904i000490 vf tmv x45" );
8906 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
8907 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
8909 System.out.println( "value =" + id.getValue() );
8910 System.out.println( "provider=" + id.getProvider() );
8915 id = SequenceIdParser.parse( "XP_12345" );
8917 System.out.println( "value =" + id.getValue() );
8918 System.out.println( "provider=" + id.getProvider() );
8921 // lcl_91970_unknown_
8923 catch ( final Exception e ) {
8924 e.printStackTrace( System.out );