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.sdi;
28 import java.io.IOException;
30 import org.forester.development.DevelopmentTools;
31 import org.forester.io.parsers.nhx.NHXParser;
32 import org.forester.io.parsers.util.ParserUtils;
33 import org.forester.phylogeny.Phylogeny;
34 import org.forester.phylogeny.PhylogenyMethods;
35 import org.forester.phylogeny.data.Event;
36 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
37 import org.forester.phylogeny.factories.PhylogenyFactory;
38 import org.forester.sdi.SDI.TaxonomyComparisonBase;
39 import org.forester.util.ForesterUtil;
41 public final class TestGSDI {
43 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" ) + ForesterUtil.getFileSeparator()
44 + "test_data" + ForesterUtil.getFileSeparator();
46 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
47 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
52 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
53 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
56 public static boolean test() {
57 if ( !TestGSDI.testGSDI_general() ) {
60 if ( !TestGSDI.testGSDI_against_binary_gene_tree() ) {
66 private static boolean testGSDI_against_binary_gene_tree() {
68 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
69 final String multi_species_2_str = "(((((([&&NHX:S=1],[&&NHX:S=2]),"
70 + "([&&NHX:S=3],[&&NHX:S=4],[&&NHX:S=5])),"
71 + "([&&NHX:S=6],[&&NHX:S=7],[&&NHX:S=8],[&&NHX:S=9])),"
72 + "([&&NHX:S=10],[&&NHX:S=11])),"
73 + "([&&NHX:S=12],[&&NHX:S=13],[&&NHX:S=14])),"
74 + "([&&NHX:S=15],([&&NHX:S=16],[&&NHX:S=17]),([&&NHX:S=18],[&&NHX:S=19],[&&NHX:S=20]),([&&NHX:S=21],[&&NHX:S=22],[&&NHX:S=23],[&&NHX:S=24])));";
75 final String gene_2_1_str = "(((((([&&NHX:S=1],[&&NHX:S=2])1_2,([&&NHX:S=3],[&&NHX:S=4])),"
76 + "([&&NHX:S=6],[&&NHX:S=7])6_7_8_9)1_9,([&&NHX:S=10],[&&NHX:S=11])),"
77 + "([&&NHX:S=12],[&&NHX:S=13])12_13_14)1_14,"
78 + "([&&NHX:S=15],([&&NHX:S=21],[&&NHX:S=24])21_22_23_24)15_24);";
79 final Phylogeny multi_species_2 = factory.create( multi_species_2_str, new NHXParser() )[ 0 ];
80 final Phylogeny gene_2_1 = factory.create( gene_2_1_str, new NHXParser() )[ 0 ];
81 multi_species_2.setRooted( true );
82 gene_2_1.setRooted( true );
83 final GSDI sdi = new GSDI( gene_2_1, multi_species_2, false );
84 if ( sdi.getSpeciationOrDuplicationEventsSum() != 0 ) {
87 if ( sdi.getDuplicationsSum() != 0 ) {
91 catch ( final Exception e ) {
92 e.printStackTrace( System.out );
98 private static boolean testGSDI_general() {
100 final PhylogenyMethods pm = PhylogenyMethods.getInstance();
101 final String s2_ = "((" + "([&&NHX:S=a1],[&&NHX:S=a2],[&&NHX:S=a3],[&&NHX:S=a4]),"
102 + "([&&NHX:S=b1],[&&NHX:S=b2],[&&NHX:S=b3],[&&NHX:S=b4]),"
103 + "([&&NHX:S=c1],[&&NHX:S=c2],[&&NHX:S=c3],[&&NHX:S=c4]),"
104 + "([&&NHX:S=d1],[&&NHX:S=d2],[&&NHX:S=d3],[&&NHX:S=d4])),("
105 + "([&&NHX:S=e1],[&&NHX:S=e2],[&&NHX:S=e3],[&&NHX:S=e4]),"
106 + "([&&NHX:S=f1],[&&NHX:S=f2],[&&NHX:S=f3],[&&NHX:S=f4]),"
107 + "([&&NHX:S=g1],[&&NHX:S=g2],[&&NHX:S=g3],[&&NHX:S=g4]),"
108 + "([&&NHX:S=h1],[&&NHX:S=h2],[&&NHX:S=h3],[&&NHX:S=h4])),("
109 + "([&&NHX:S=i1],[&&NHX:S=i2],[&&NHX:S=i3],[&&NHX:S=i4]),"
110 + "([&&NHX:S=j1],[&&NHX:S=j2],[&&NHX:S=j3],[&&NHX:S=j4]),"
111 + "([&&NHX:S=k1],[&&NHX:S=k2],[&&NHX:S=k3],[&&NHX:S=k4]),"
112 + "([&&NHX:S=l1],[&&NHX:S=l2],[&&NHX:S=l3],[&&NHX:S=l4])),("
113 + "([&&NHX:S=m1],[&&NHX:S=m2],[&&NHX:S=m3],[&&NHX:S=m4]),"
114 + "([&&NHX:S=n1],[&&NHX:S=n2],[&&NHX:S=n3],[&&NHX:S=n4]),"
115 + "([&&NHX:S=o1],[&&NHX:S=o2],[&&NHX:S=o3],[&&NHX:S=o4]),"
116 + "([&&NHX:S=p1],[&&NHX:S=p2],[&&NHX:S=p3],[&&NHX:S=p4])"
117 + "),[&&NHX:S=x],[&&NHX:S=y],[&&NHX:S=z])";
118 final Phylogeny s2 = ParserBasedPhylogenyFactory.getInstance().create( s2_, new NHXParser() )[ 0 ];
119 s2.setRooted( true );
120 final String s1_ = "((([&&NHX:S=A2],[&&NHX:S=A1]),[&&NHX:S=B],[&&NHX:S=C]),[&&NHX:S=D])";
121 final Phylogeny s1 = ParserBasedPhylogenyFactory.getInstance().create( s1_, new NHXParser() )[ 0 ];
122 s1.setRooted( true );
123 final Phylogeny g1 = TestGSDI
124 .createPhylogeny( "((((B[&&NHX:S=B],A1[&&NHX:S=A1]),C[&&NHX:S=C]),A2[&&NHX:S=A2]),D[&&NHX:S=D])" );
125 final GSDI sdi1 = new GSDI( g1, s1, false );
126 // Archaeopteryx.createApplication( g1 );
127 // Archaeopteryx.createApplication( s1 );
128 if ( sdi1.getDuplicationsSum() != 1 ) {
131 if ( !PhylogenyMethods.calculateLCA( g1.getNode( "B" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
135 if ( !PhylogenyMethods.calculateLCA( g1.getNode( "C" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
136 .isSpeciationOrDuplication() ) {
139 if ( !( PhylogenyMethods.calculateLCA( g1.getNode( "A2" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
140 .isDuplication() ) ) {
143 if ( !PhylogenyMethods.calculateLCA( g1.getNode( "D" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
147 final Phylogeny g2 = TestGSDI
148 .createPhylogeny( "((((A2[&&NHX:S=A2],A1[&&NHX:S=A1]),B[&&NHX:S=B]),C[&&NHX:S=C]),D[&&NHX:S=D])" );
149 final GSDI sdi2 = new GSDI( g2, s1, false );
150 if ( sdi2.getDuplicationsSum() != 0 ) {
153 if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "A2" ) ).getNodeData().getEvent()
157 if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "B" ) ).getNodeData().getEvent()
161 if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "C" ) ).getNodeData().getEvent()
162 .isSpeciationOrDuplication() ) {
165 if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "D" ) ).getNodeData().getEvent()
169 final Phylogeny g3 = TestGSDI
170 .createPhylogeny( "((((A2[&&NHX:S=A2],A1[&&NHX:S=A1]),C[&&NHX:S=C]),B[&&NHX:S=B]),D[&&NHX:S=D])" );
171 final GSDI sdi3 = new GSDI( g3, s1, false );
172 if ( sdi3.getDuplicationsSum() != 0 ) {
175 if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "A2" ) ).getNodeData().getEvent()
179 if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "C" ) ).getNodeData().getEvent()
183 if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "B" ) ).getNodeData().getEvent()
184 .isSpeciationOrDuplication() ) {
187 if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "D" ) ).getNodeData().getEvent()
191 final Phylogeny g4 = TestGSDI
192 .createPhylogeny( "(((B[&&NHX:S=B],C1[&&NHX:S=C]),C2[&&NHX:S=C]),D[&&NHX:S=D])" );
193 final GSDI sdi4 = new GSDI( g4, s1, false );
194 if ( sdi4.getDuplicationsSum() != 1 ) {
197 if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "C1" ) ).getNodeData().getEvent()
201 if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "C2" ) ).getNodeData().getEvent()
205 if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "D" ) ).getNodeData().getEvent()
209 final Phylogeny g5 = TestGSDI
210 .createPhylogeny( "(((D1[&&NHX:S=D],A1[&&NHX:S=A1]),B[&&NHX:S=B]),((D2[&&NHX:S=D],D3[&&NHX:S=D]),C[&&NHX:S=C]))" );
211 final GSDI sdi5 = new GSDI( g5, s1, false );
212 if ( sdi5.getDuplicationsSum() != 3 ) {
215 if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "A1" ) ).getNodeData().getEvent()
219 if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "B" ) ).getNodeData().getEvent()
223 if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "D2" ) ).getNodeData().getEvent()
227 if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D2" ), g5.getNode( "D3" ) ).getNodeData().getEvent()
231 if ( !PhylogenyMethods.calculateLCA( g5.getNode( "C" ), g5.getNode( "D3" ) ).getNodeData().getEvent()
235 final Phylogeny species7 = TestGSDI.createPhylogeny( "(((((((([&&NHX:S=a1],[&&NHX:S=a2]),"
236 + "([&&NHX:S=b1],[&&NHX:S=b2])),[&&NHX:S=x]),(([&&NHX:S=m1],[&&NHX:S=m2]),"
237 + "([&&NHX:S=n1],[&&NHX:S=n2]))),(([&&NHX:S=i1],[&&NHX:S=i2]),"
238 + "([&&NHX:S=j1],[&&NHX:S=j2]))),(([&&NHX:S=e1],[&&NHX:S=e2]),"
239 + "([&&NHX:S=f1],[&&NHX:S=f2]))),[&&NHX:S=y]),[&&NHX:S=z])" );
240 final Phylogeny gene7_2 = TestGSDI
241 .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])" );
242 gene7_2.setRooted( true );
243 final GSDI sdi7_2 = new GSDI( gene7_2, species7, false );
244 if ( sdi7_2.getDuplicationsSum() != 1 ) {
247 if ( !TestGSDI.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
250 if ( !TestGSDI.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
253 if ( !TestGSDI.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
256 if ( !TestGSDI.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
259 if ( !TestGSDI.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
262 if ( !TestGSDI.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
265 if ( !TestGSDI.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
268 if ( !TestGSDI.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
271 if ( !TestGSDI.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
274 final Phylogeny g2_0 = TestGSDI.createPhylogeny( "(m1[&&NHX:S=m1],m3[&&NHX:S=m3])" );
275 final GSDI sdi2_0 = new GSDI( g2_0, s2, false );
276 if ( sdi2_0.getDuplicationsSum() != 0 ) {
279 if ( sdi2_0.getSpeciationOrDuplicationEventsSum() != 0 ) {
282 if ( sdi2_0.getSpeciationsSum() != 1 ) {
285 if ( !PhylogenyMethods.calculateLCA( g2_0.getNode( "m1" ), g2_0.getNode( "m3" ) ).getNodeData().getEvent()
289 final Phylogeny g2_1 = TestGSDI.createPhylogeny( "(e2[&&NHX:S=e2],h2[&&NHX:S=h2])" );
290 final GSDI sdi2_1 = new GSDI( g2_1, s2, false );
291 if ( sdi2_1.getDuplicationsSum() != 0 ) {
294 if ( sdi2_1.getSpeciationOrDuplicationEventsSum() != 0 ) {
297 if ( sdi2_1.getSpeciationsSum() != 1 ) {
300 if ( !PhylogenyMethods.calculateLCA( g2_1.getNode( "e2" ), g2_1.getNode( "h2" ) ).getNodeData().getEvent()
304 final Phylogeny g2_2 = TestGSDI.createPhylogeny( "(e2[&&NHX:S=e2],p4[&&NHX:S=p4])" );
305 final GSDI sdi2_2 = new GSDI( g2_2, s2, false );
306 if ( sdi2_2.getDuplicationsSum() != 0 ) {
309 if ( sdi2_2.getSpeciationOrDuplicationEventsSum() != 0 ) {
312 if ( sdi2_2.getSpeciationsSum() != 1 ) {
315 if ( !PhylogenyMethods.calculateLCA( g2_2.getNode( "e2" ), g2_2.getNode( "p4" ) ).getNodeData().getEvent()
319 final Phylogeny g2_3 = TestGSDI.createPhylogeny( "(e2a[&&NHX:S=e2],e2b[&&NHX:S=e2])" );
320 final GSDI sdi2_3 = new GSDI( g2_3, s2, false );
321 if ( sdi2_3.getDuplicationsSum() != 1 ) {
324 if ( sdi2_3.getSpeciationOrDuplicationEventsSum() != 0 ) {
327 if ( sdi2_3.getSpeciationsSum() != 0 ) {
330 if ( !PhylogenyMethods.calculateLCA( g2_3.getNode( "e2a" ), g2_3.getNode( "e2b" ) ).getNodeData()
331 .getEvent().isDuplication() ) {
334 final Phylogeny g2_4 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],j4[&&NHX:S=j4]),i3[&&NHX:S=i3])" );
335 final GSDI sdi2_4 = new GSDI( g2_4, s2, false );
336 if ( sdi2_4.getDuplicationsSum() != 0 ) {
339 if ( sdi2_4.getSpeciationOrDuplicationEventsSum() != 0 ) {
342 if ( sdi2_4.getSpeciationsSum() != 2 ) {
345 if ( !PhylogenyMethods.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "j4" ) ).getNodeData().getEvent()
349 if ( !PhylogenyMethods.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "i3" ) ).getNodeData().getEvent()
353 final Phylogeny g2_5 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],j4[&&NHX:S=j4]),f3[&&NHX:S=f3])" );
354 final GSDI sdi2_5 = new GSDI( g2_5, s2, false );
355 if ( sdi2_5.getDuplicationsSum() != 0 ) {
358 if ( sdi2_5.getSpeciationOrDuplicationEventsSum() != 0 ) {
361 if ( sdi2_5.getSpeciationsSum() != 2 ) {
364 if ( !PhylogenyMethods.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "j4" ) ).getNodeData().getEvent()
368 if ( !PhylogenyMethods.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "f3" ) ).getNodeData().getEvent()
372 final Phylogeny g2_6 = TestGSDI.createPhylogeny( "((j3[&&NHX:S=j3],i4[&&NHX:S=i4]),f3[&&NHX:S=f3])" );
373 final GSDI sdi2_6 = new GSDI( g2_6, s2, false );
374 if ( sdi2_6.getDuplicationsSum() != 0 ) {
377 if ( sdi2_6.getSpeciationOrDuplicationEventsSum() != 0 ) {
380 if ( sdi2_6.getSpeciationsSum() != 2 ) {
383 if ( !PhylogenyMethods.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "i4" ) ).getNodeData().getEvent()
387 if ( !PhylogenyMethods.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "f3" ) ).getNodeData().getEvent()
391 final Phylogeny g2_7 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],k1[&&NHX:S=k1]),i1[&&NHX:S=i1])" );
392 final GSDI sdi2_7 = new GSDI( g2_7, s2, false );
393 if ( sdi2_7.getDuplicationsSum() != 0 ) {
396 if ( sdi2_7.getSpeciationOrDuplicationEventsSum() != 1 ) {
399 if ( sdi2_7.getSpeciationsSum() != 1 ) {
402 if ( !PhylogenyMethods.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "k1" ) ).getNodeData().getEvent()
406 if ( !PhylogenyMethods.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "i1" ) ).getNodeData().getEvent()
407 .isSpeciationOrDuplication() ) {
410 final Phylogeny g2_8 = TestGSDI.createPhylogeny( "(j1[&&NHX:S=j1],(k1[&&NHX:S=k1],i1[&&NHX:S=i1]))" );
411 final GSDI sdi2_8 = new GSDI( g2_8, s2, false );
412 if ( sdi2_8.getDuplicationsSum() != 0 ) {
415 if ( sdi2_8.getSpeciationOrDuplicationEventsSum() != 1 ) {
418 if ( sdi2_8.getSpeciationsSum() != 1 ) {
421 if ( !PhylogenyMethods.calculateLCA( g2_8.getNode( "j1" ), g2_8.getNode( "k1" ) ).getNodeData().getEvent()
422 .isSpeciationOrDuplication() ) {
425 if ( !PhylogenyMethods.calculateLCA( g2_8.getNode( "k1" ), g2_8.getNode( "i1" ) ).getNodeData().getEvent()
429 final Phylogeny g2_9 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],k4[&&NHX:S=k4]),f2[&&NHX:S=f2])" );
430 final GSDI sdi2_9 = new GSDI( g2_9, s2, false );
431 if ( sdi2_9.getDuplicationsSum() != 0 ) {
434 if ( sdi2_9.getSpeciationOrDuplicationEventsSum() != 0 ) {
437 if ( sdi2_9.getSpeciationsSum() != 2 ) {
440 if ( !TestGSDI.getEvent( g2_9, "j1", "k4" ).isSpeciation() ) {
443 if ( !TestGSDI.getEvent( g2_9, "j1", "f2" ).isSpeciation() ) {
446 final Phylogeny g2_10 = TestGSDI.createPhylogeny( "((m1[&&NHX:S=m1],k4[&&NHX:S=k4]),f2[&&NHX:S=f2])" );
447 final GSDI sdi2_10 = new GSDI( g2_10, s2, false );
448 if ( sdi2_10.getDuplicationsSum() != 0 ) {
451 if ( sdi2_10.getSpeciationOrDuplicationEventsSum() != 1 ) {
454 if ( sdi2_10.getSpeciationsSum() != 1 ) {
457 if ( !TestGSDI.getEvent( g2_10, "m1", "k4" ).isSpeciation() ) {
460 if ( !TestGSDI.getEvent( g2_10, "m1", "f2" ).isSpeciationOrDuplication() ) {
463 final Phylogeny g2_11 = TestGSDI.createPhylogeny( "((m1[&&NHX:S=m1],k4[&&NHX:S=k4]),x[&&NHX:S=x])" );
464 final GSDI sdi2_11 = new GSDI( g2_11, s2, false );
465 if ( sdi2_11.getDuplicationsSum() != 0 ) {
468 if ( sdi2_11.getSpeciationOrDuplicationEventsSum() != 1 ) {
471 if ( sdi2_11.getSpeciationsSum() != 1 ) {
474 if ( !TestGSDI.getEvent( g2_11, "m1", "k4" ).isSpeciation() ) {
477 if ( !TestGSDI.getEvent( g2_11, "m1", "x" ).isSpeciationOrDuplication() ) {
480 final Phylogeny g2_12 = TestGSDI.createPhylogeny( "(m1[&&NHX:S=m1],(k4[&&NHX:S=k4],x[&&NHX:S=x]))" );
481 final GSDI sdi2_12 = new GSDI( g2_12, s2, false );
482 if ( sdi2_12.getDuplicationsSum() != 0 ) {
485 if ( sdi2_12.getSpeciationOrDuplicationEventsSum() != 1 ) {
488 if ( sdi2_12.getSpeciationsSum() != 1 ) {
491 if ( !TestGSDI.getEvent( g2_12, "x", "k4" ).isSpeciation() ) {
494 if ( !TestGSDI.getEvent( g2_12, "m1", "x" ).isSpeciationOrDuplication() ) {
497 final Phylogeny g2_13 = TestGSDI.createPhylogeny( "(x[&&NHX:S=x],(y[&&NHX:S=y],z[&&NHX:S=z]))" );
498 final GSDI sdi2_13 = new GSDI( g2_13, s2, false );
499 if ( sdi2_13.getDuplicationsSum() != 0 ) {
502 if ( sdi2_13.getSpeciationOrDuplicationEventsSum() != 1 ) {
505 if ( sdi2_13.getSpeciationsSum() != 1 ) {
508 if ( !TestGSDI.getEvent( g2_13, "y", "z" ).isSpeciation() ) {
511 if ( !TestGSDI.getEvent( g2_13, "x", "z" ).isSpeciationOrDuplication() ) {
514 final Phylogeny g2_14 = TestGSDI.createPhylogeny( "(a1_1[&&NHX:S=a1],(b1[&&NHX:S=b1],a1[&&NHX:S=a1]))" );
515 final GSDI sdi2_14 = new GSDI( g2_14, s2, false );
516 if ( sdi2_14.getDuplicationsSum() != 1 ) {
519 if ( sdi2_14.getSpeciationOrDuplicationEventsSum() != 0 ) {
522 if ( sdi2_14.getSpeciationsSum() != 1 ) {
525 if ( !TestGSDI.getEvent( g2_14, "b1", "a1" ).isSpeciation() ) {
528 if ( !TestGSDI.getEvent( g2_14, "b1", "a1_1" ).isDuplication() ) {
531 final Phylogeny g2_15 = TestGSDI.createPhylogeny( "(a2[&&NHX:S=a2],(b1[&&NHX:S=b1],a1[&&NHX:S=a1]))" );
532 final GSDI sdi2_15 = new GSDI( g2_15, s2, false );
533 if ( sdi2_15.getDuplicationsSum() != 1 ) {
536 if ( sdi2_15.getSpeciationOrDuplicationEventsSum() != 0 ) {
539 if ( sdi2_15.getSpeciationsSum() != 1 ) {
542 if ( !TestGSDI.getEvent( g2_15, "b1", "a1" ).isSpeciation() ) {
545 if ( !TestGSDI.getEvent( g2_15, "b1", "a2" ).isDuplication() ) {
548 final Phylogeny g2_16 = TestGSDI.createPhylogeny( "(n2[&&NHX:S=n2],(j3[&&NHX:S=j3],n1[&&NHX:S=n1]))" );
549 final GSDI sdi2_16 = new GSDI( g2_16, s2, false );
550 if ( sdi2_16.getDuplicationsSum() != 1 ) {
553 if ( sdi2_16.getSpeciationOrDuplicationEventsSum() != 0 ) {
556 if ( sdi2_16.getSpeciationsSum() != 1 ) {
559 if ( !TestGSDI.getEvent( g2_16, "j3", "n1" ).isSpeciation() ) {
562 if ( !TestGSDI.getEvent( g2_16, "j3", "n2" ).isDuplication() ) {
565 final Phylogeny g2_17 = TestGSDI.createPhylogeny( "(p4[&&NHX:S=p4],(j3[&&NHX:S=j3],n1[&&NHX:S=n1]))" );
566 final GSDI sdi2_17 = new GSDI( g2_17, s2, false );
567 if ( sdi2_17.getDuplicationsSum() != 1 ) {
570 if ( sdi2_17.getSpeciationOrDuplicationEventsSum() != 0 ) {
573 if ( sdi2_17.getSpeciationsSum() != 1 ) {
576 if ( !TestGSDI.getEvent( g2_17, "j3", "n1" ).isSpeciation() ) {
579 if ( !TestGSDI.getEvent( g2_17, "j3", "p4" ).isDuplication() ) {
582 final Phylogeny g2_18 = TestGSDI
583 .createPhylogeny( "((n11[&&NHX:S=n1],n12[&&NHX:S=n1]),(n13[&&NHX:S=n1],n14[&&NHX:S=n1]))" );
584 final GSDI sdi2_18 = new GSDI( g2_18, s2, false );
585 if ( sdi2_18.getDuplicationsSum() != 3 ) {
588 if ( sdi2_18.getSpeciationOrDuplicationEventsSum() != 0 ) {
591 if ( sdi2_18.getSpeciationsSum() != 0 ) {
594 if ( !TestGSDI.getEvent( g2_18, "n11", "n12" ).isDuplication() ) {
597 if ( !TestGSDI.getEvent( g2_18, "n13", "n14" ).isDuplication() ) {
600 if ( !TestGSDI.getEvent( g2_18, "n11", "n13" ).isDuplication() ) {
603 final Phylogeny g2_19 = TestGSDI
604 .createPhylogeny( "((n11[&&NHX:S=n1],n21[&&NHX:S=n2]),(n12[&&NHX:S=n1],n22[&&NHX:S=n2]))" );
605 final GSDI sdi2_19 = new GSDI( g2_19, s2, false );
606 if ( sdi2_19.getDuplicationsSum() != 1 ) {
609 if ( sdi2_19.getSpeciationOrDuplicationEventsSum() != 0 ) {
612 if ( sdi2_19.getSpeciationsSum() != 2 ) {
615 if ( !TestGSDI.getEvent( g2_19, "n11", "n21" ).isSpeciation() ) {
618 if ( !TestGSDI.getEvent( g2_19, "n12", "n22" ).isSpeciation() ) {
621 if ( !TestGSDI.getEvent( g2_19, "n11", "n12" ).isDuplication() ) {
624 final Phylogeny g2_20 = TestGSDI
625 .createPhylogeny( "((n11[&&NHX:S=n1],n2[&&NHX:S=n2]),(n12[&&NHX:S=n1],n3[&&NHX:S=n3]))" );
626 final GSDI sdi2_20 = new GSDI( g2_20, s2, false );
627 if ( sdi2_20.getDuplicationsSum() != 1 ) {
630 if ( sdi2_20.getSpeciationOrDuplicationEventsSum() != 0 ) {
633 if ( sdi2_20.getSpeciationsSum() != 2 ) {
636 if ( !TestGSDI.getEvent( g2_20, "n11", "n2" ).isSpeciation() ) {
639 if ( !TestGSDI.getEvent( g2_20, "n12", "n3" ).isSpeciation() ) {
642 if ( !TestGSDI.getEvent( g2_20, "n11", "n12" ).isDuplication() ) {
645 final Phylogeny g2_21 = TestGSDI
646 .createPhylogeny( "((n1[&&NHX:S=n1],n2[&&NHX:S=n2]),(n3[&&NHX:S=n3],a1[&&NHX:S=a1]))" );
647 final GSDI sdi2_21 = new GSDI( g2_21, s2, false );
648 if ( sdi2_21.getDuplicationsSum() != 1 ) {
651 if ( sdi2_21.getSpeciationOrDuplicationEventsSum() != 0 ) {
654 if ( sdi2_21.getSpeciationsSum() != 2 ) {
657 if ( !TestGSDI.getEvent( g2_21, "n1", "n2" ).isSpeciation() ) {
660 if ( !TestGSDI.getEvent( g2_21, "n3", "a1" ).isSpeciation() ) {
663 if ( !TestGSDI.getEvent( g2_21, "n2", "a1" ).isDuplication() ) {
666 final Phylogeny g2_22 = TestGSDI
667 .createPhylogeny( "((n1[&&NHX:S=n1],n2[&&NHX:S=n2]),(n3[&&NHX:S=n3],n4[&&NHX:S=n4]))" );
668 final GSDI sdi2_22 = new GSDI( g2_22, s2, false );
669 //Archaeopteryx.createApplication( g2_22 );
670 //Archaeopteryx.createApplication( s2 );
671 if ( sdi2_22.getDuplicationsSum() != 0 ) {
674 if ( sdi2_22.getSpeciationOrDuplicationEventsSum() != 1 ) {
677 if ( sdi2_22.getSpeciationsSum() != 2 ) {
680 if ( !TestGSDI.getEvent( g2_22, "n1", "n2" ).isSpeciation() ) {
683 if ( !TestGSDI.getEvent( g2_22, "n3", "n4" ).isSpeciation() ) {
686 if ( !TestGSDI.getEvent( g2_22, "n1", "n3" ).isSpeciationOrDuplication() ) {
689 final Phylogeny g2_23 = TestGSDI
690 .createPhylogeny( "((a1[&&NHX:S=a1],b1[&&NHX:S=b1]),(c1[&&NHX:S=c1],d1[&&NHX:S=d1]))" );
691 final GSDI sdi2_23 = new GSDI( g2_23, s2, false );
692 if ( sdi2_23.getDuplicationsSum() != 0 ) {
695 if ( sdi2_23.getSpeciationOrDuplicationEventsSum() != 1 ) {
698 if ( sdi2_23.getSpeciationsSum() != 2 ) {
701 if ( !TestGSDI.getEvent( g2_23, "a1", "b1" ).isSpeciation() ) {
704 if ( !TestGSDI.getEvent( g2_23, "c1", "d1" ).isSpeciation() ) {
707 if ( !TestGSDI.getEvent( g2_23, "a1", "c1" ).isSpeciationOrDuplication() ) {
710 final Phylogeny g2_24 = TestGSDI
711 .createPhylogeny( "((a1[&&NHX:S=a1],e1[&&NHX:S=e1]),(i1[&&NHX:S=i1],m1[&&NHX:S=m1]))" );
712 final GSDI sdi2_24 = new GSDI( g2_24, s2, false );
713 if ( sdi2_24.getDuplicationsSum() != 0 ) {
716 if ( sdi2_24.getSpeciationOrDuplicationEventsSum() != 1 ) {
719 if ( sdi2_24.getSpeciationsSum() != 2 ) {
722 if ( !TestGSDI.getEvent( g2_24, "a1", "e1" ).isSpeciation() ) {
725 if ( !TestGSDI.getEvent( g2_24, "i1", "m1" ).isSpeciation() ) {
728 if ( !TestGSDI.getEvent( g2_24, "a1", "i1" ).isSpeciationOrDuplication() ) {
731 final Phylogeny g2_25 = TestGSDI
732 .createPhylogeny( "((a1[&&NHX:S=a1],a4[&&NHX:S=a4]),(b1[&&NHX:S=b1],c1[&&NHX:S=c1]))" );
733 final GSDI sdi2_25 = new GSDI( g2_25, s2, false );
734 if ( sdi2_25.getDuplicationsSum() != 0 ) {
737 if ( sdi2_25.getSpeciationOrDuplicationEventsSum() != 1 ) {
740 if ( sdi2_25.getSpeciationsSum() != 2 ) {
743 if ( !TestGSDI.getEvent( g2_25, "a1", "a4" ).isSpeciation() ) {
746 if ( !TestGSDI.getEvent( g2_25, "b1", "c1" ).isSpeciation() ) {
749 if ( !TestGSDI.getEvent( g2_25, "a1", "b1" ).isSpeciationOrDuplication() ) {
752 final Phylogeny g2_26 = TestGSDI
753 .createPhylogeny( "(((a1[&&NHX:S=a1],a4[&&NHX:S=a4]),b1[&&NHX:S=b1]),e1[&&NHX:S=e1])" );
754 final GSDI sdi2_26 = new GSDI( g2_26, s2, false );
755 if ( sdi2_26.getDuplicationsSum() != 0 ) {
758 if ( sdi2_26.getSpeciationOrDuplicationEventsSum() != 0 ) {
761 if ( sdi2_26.getSpeciationsSum() != 3 ) {
764 if ( !TestGSDI.getEvent( g2_26, "a1", "a4" ).isSpeciation() ) {
767 if ( !TestGSDI.getEvent( g2_26, "a1", "b1" ).isSpeciation() ) {
770 if ( !TestGSDI.getEvent( g2_26, "a1", "e1" ).isSpeciation() ) {
773 final Phylogeny g2_27 = TestGSDI
774 .createPhylogeny( "(((a1[&&NHX:S=a1],a4[&&NHX:S=a4]),b1[&&NHX:S=b1]),c1[&&NHX:S=c1])" );
775 final GSDI sdi2_27 = new GSDI( g2_27, s2, false );
776 if ( sdi2_27.getDuplicationsSum() != 0 ) {
779 if ( sdi2_27.getSpeciationOrDuplicationEventsSum() != 1 ) {
782 if ( sdi2_27.getSpeciationsSum() != 2 ) {
785 if ( !TestGSDI.getEvent( g2_27, "a1", "a4" ).isSpeciation() ) {
788 if ( !TestGSDI.getEvent( g2_27, "a1", "b1" ).isSpeciation() ) {
791 if ( !TestGSDI.getEvent( g2_27, "a1", "c1" ).isSpeciationOrDuplication() ) {
794 final Phylogeny g2_28 = TestGSDI
795 .createPhylogeny( "(((a1[&&NHX:S=a1],b1[&&NHX:S=b1]),c1[&&NHX:S=c1]),e1[&&NHX:S=e1])" );
796 final GSDI sdi2_28 = new GSDI( g2_28, s2, false );
797 if ( sdi2_28.getDuplicationsSum() != 0 ) {
800 if ( sdi2_28.getSpeciationOrDuplicationEventsSum() != 1 ) {
803 if ( sdi2_28.getSpeciationsSum() != 2 ) {
806 if ( !TestGSDI.getEvent( g2_28, "a1", "b1" ).isSpeciation() ) {
809 if ( !TestGSDI.getEvent( g2_28, "a1", "c1" ).isSpeciationOrDuplication() ) {
812 if ( !TestGSDI.getEvent( g2_28, "a1", "e1" ).isSpeciation() ) {
815 final Phylogeny g2_29 = TestGSDI
816 .createPhylogeny( "(((a1[&&NHX:S=a1],b1[&&NHX:S=b1]),c1[&&NHX:S=c1]),d1[&&NHX:S=d1])" );
817 final GSDI sdi2_29 = new GSDI( g2_29, s2, false );
818 if ( sdi2_29.getDuplicationsSum() != 0 ) {
821 if ( sdi2_29.getSpeciationOrDuplicationEventsSum() != 2 ) {
824 if ( sdi2_29.getSpeciationsSum() != 1 ) {
827 if ( !TestGSDI.getEvent( g2_29, "a1", "b1" ).isSpeciation() ) {
830 if ( !TestGSDI.getEvent( g2_29, "a1", "c1" ).isSpeciationOrDuplication() ) {
833 if ( !TestGSDI.getEvent( g2_29, "a1", "d1" ).isSpeciationOrDuplication() ) {
836 final Phylogeny g2_30 = TestGSDI
837 .createPhylogeny( "(((a1[&&NHX:S=a1],b1[&&NHX:S=b1]),c1[&&NHX:S=c1]),a2[&&NHX:S=a2])" );
838 final GSDI sdi2_30 = new GSDI( g2_30, s2, false );
839 if ( sdi2_30.getDuplicationsSum() != 1 ) {
842 if ( sdi2_30.getSpeciationOrDuplicationEventsSum() != 1 ) {
845 if ( sdi2_30.getSpeciationsSum() != 1 ) {
848 if ( !TestGSDI.getEvent( g2_30, "a1", "b1" ).isSpeciation() ) {
851 if ( !TestGSDI.getEvent( g2_30, "a1", "c1" ).isSpeciationOrDuplication() ) {
854 if ( !TestGSDI.getEvent( g2_30, "a1", "a2" ).isDuplication() ) {
857 final Phylogeny g2_31 = TestGSDI
858 .createPhylogeny( "(((a1[&&NHX:S=a1],b1[&&NHX:S=b1]),c1[&&NHX:S=c1]),c2[&&NHX:S=c2])" );
859 final GSDI sdi2_31 = new GSDI( g2_31, s2, false );
860 if ( sdi2_31.getDuplicationsSum() != 1 ) {
863 if ( sdi2_31.getSpeciationOrDuplicationEventsSum() != 1 ) {
866 if ( sdi2_31.getSpeciationsSum() != 1 ) {
869 if ( !TestGSDI.getEvent( g2_31, "a1", "b1" ).isSpeciation() ) {
872 if ( !TestGSDI.getEvent( g2_31, "a1", "c1" ).isSpeciationOrDuplication() ) {
875 if ( !TestGSDI.getEvent( g2_31, "a1", "c2" ).isDuplication() ) {
878 final Phylogeny g2_32 = TestGSDI
879 .createPhylogeny( "((((((((((a1[&&NHX:S=a1],a2[&&NHX:S=a2]),b1[&&NHX:S=b1]),c1[&&NHX:S=c1]),d1[&&NHX:S=d1]),x[&&NHX:S=x]),p1[&&NHX:S=p1]),i1[&&NHX:S=i1]),e1[&&NHX:S=e1]),y[&&NHX:S=y]),z[&&NHX:S=z])" );
880 final GSDI sdi2_32 = new GSDI( g2_32, s2, false );
881 if ( sdi2_32.getDuplicationsSum() != 0 ) {
884 if ( sdi2_32.getSpeciationOrDuplicationEventsSum() != 7 ) {
887 if ( sdi2_32.getSpeciationsSum() != 3 ) {
890 if ( !TestGSDI.getEvent( g2_32, "a1", "a2" ).isSpeciation() ) {
893 if ( !TestGSDI.getEvent( g2_32, "a1", "b1" ).isSpeciation() ) {
896 if ( !TestGSDI.getEvent( g2_32, "a1", "c1" ).isSpeciationOrDuplication() ) {
899 if ( !TestGSDI.getEvent( g2_32, "a1", "d1" ).isSpeciationOrDuplication() ) {
902 if ( !TestGSDI.getEvent( g2_32, "a1", "x" ).isSpeciation() ) {
905 if ( !TestGSDI.getEvent( g2_32, "a1", "p1" ).isSpeciationOrDuplication() ) {
908 if ( !TestGSDI.getEvent( g2_32, "a1", "i1" ).isSpeciationOrDuplication() ) {
911 if ( !TestGSDI.getEvent( g2_32, "a1", "e1" ).isSpeciationOrDuplication() ) {
914 if ( !TestGSDI.getEvent( g2_32, "a1", "y" ).isSpeciationOrDuplication() ) {
917 if ( !TestGSDI.getEvent( g2_32, "a1", "z" ).isSpeciationOrDuplication() ) {
920 final Phylogeny g2_33 = TestGSDI
921 .createPhylogeny( "(((((((((((a1[&&NHX:S=a1],a2[&&NHX:S=a2]),b1[&&NHX:S=b1]),c1[&&NHX:S=c1]),d1[&&NHX:S=d1]),x[&&NHX:S=x]),p1[&&NHX:S=p1]),i1[&&NHX:S=i1]),k2[&&NHX:S=k2]),e1[&&NHX:S=e1]),y[&&NHX:S=y]),z[&&NHX:S=z])" );
922 final GSDI sdi2_33 = new GSDI( g2_33, s2, false );
923 if ( sdi2_33.getDuplicationsSum() != 1 ) {
926 if ( sdi2_33.getSpeciationOrDuplicationEventsSum() != 7 ) {
929 if ( sdi2_33.getSpeciationsSum() != 3 ) {
932 if ( !TestGSDI.getEvent( g2_33, "a1", "a2" ).isSpeciation() ) {
935 if ( !TestGSDI.getEvent( g2_33, "a1", "b1" ).isSpeciation() ) {
938 if ( !TestGSDI.getEvent( g2_33, "a1", "c1" ).isSpeciationOrDuplication() ) {
941 if ( !TestGSDI.getEvent( g2_33, "a1", "d1" ).isSpeciationOrDuplication() ) {
944 if ( !TestGSDI.getEvent( g2_33, "a1", "x" ).isSpeciation() ) {
947 if ( !TestGSDI.getEvent( g2_33, "a1", "p1" ).isSpeciationOrDuplication() ) {
950 if ( !TestGSDI.getEvent( g2_33, "a1", "i1" ).isSpeciationOrDuplication() ) {
953 if ( !TestGSDI.getEvent( g2_33, "a1", "k2" ).isDuplication() ) {
956 if ( !TestGSDI.getEvent( g2_33, "a1", "e1" ).isSpeciationOrDuplication() ) {
959 if ( !TestGSDI.getEvent( g2_33, "a1", "y" ).isSpeciationOrDuplication() ) {
962 if ( !TestGSDI.getEvent( g2_33, "a1", "z" ).isSpeciationOrDuplication() ) {
965 final Phylogeny g2_33_d = TestGSDI
966 .createPhylogeny( "((((((((((((a1[&&NHX:S=a1],a2[&&NHX:S=a2])[&&NHX:D=N],b1[&&NHX:S=b1])[&&NHX:D=N],c1[&&NHX:S=c1])[&&NHX:D=?],d1[&&NHX:S=d1])[&&NHX:D=?],x[&&NHX:S=x])[&&NHX:D=N],p1[&&NHX:S=p1])[&&NHX:D=?],i1[&&NHX:S=i1])[&&NHX:D=?],k2[&&NHX:S=k2])[&&NHX:D=Y],e1[&&NHX:S=e1])[&&NHX:D=Y],y[&&NHX:S=y])[&&NHX:D=Y],z[&&NHX:S=z])[&&NHX:D=?],(((((((((((a1[&&NHX:S=a1],a2[&&NHX:S=a2])[&&NHX:D=N],b1[&&NHX:S=b1])[&&NHX:D=N],c1[&&NHX:S=c1])[&&NHX:D=?],d1[&&NHX:S=d1])[&&NHX:D=?],x[&&NHX:S=x])[&&NHX:D=N],p1[&&NHX:S=p1])[&&NHX:D=?],i1[&&NHX:S=i1])[&&NHX:D=?],k2[&&NHX:S=k2])[&&NHX:D=Y],e1[&&NHX:S=e1])[&&NHX:D=Y],y[&&NHX:S=y])[&&NHX:D=Y],z[&&NHX:S=z])[&&NHX:D=?])" );
967 final GSDI sdi2_33_d = new GSDI( g2_33_d, s2, false );
968 if ( sdi2_33_d.getDuplicationsSum() != 3 ) {
971 if ( sdi2_33_d.getSpeciationOrDuplicationEventsSum() != 14 ) {
974 if ( sdi2_33_d.getSpeciationsSum() != 6 ) {
977 final Phylogeny g2_34 = TestGSDI
978 .createPhylogeny( "(((n1_0[&&NHX:S=n1],n2_0[&&NHX:S=n2]),(n1_1[&&NHX:S=n1],n3_0[&&NHX:S=n3])),n4_0[&&NHX:S=n4])" );
979 final GSDI sdi2_34 = new GSDI( g2_34, s2, false );
980 if ( sdi2_34.getDuplicationsSum() != 1 ) {
983 if ( sdi2_34.getSpeciationOrDuplicationEventsSum() != 1 ) {
986 if ( sdi2_34.getSpeciationsSum() != 2 ) {
989 if ( !TestGSDI.getEvent( g2_34, "n1_0", "n2_0" ).isSpeciation() ) {
992 if ( !TestGSDI.getEvent( g2_34, "n1_1", "n3_0" ).isSpeciation() ) {
995 if ( !TestGSDI.getEvent( g2_34, "n1_0", "n1_1" ).isDuplication() ) {
998 if ( !TestGSDI.getEvent( g2_34, "n1_0", "n4_0" ).isSpeciationOrDuplication() ) {
1001 final Phylogeny g2_35 = TestGSDI
1002 .createPhylogeny( "((((n1_0[&&NHX:S=n1],n2_0[&&NHX:S=n2]),(n1_1[&&NHX:S=n1],n3_0[&&NHX:S=n3])),n4_0[&&NHX:S=n4]),a1_0[&&NHX:S=a1])" );
1003 final GSDI sdi2_35 = new GSDI( g2_35, s2, false );
1004 if ( sdi2_35.getDuplicationsSum() != 1 ) {
1007 if ( sdi2_35.getSpeciationOrDuplicationEventsSum() != 1 ) {
1010 if ( sdi2_35.getSpeciationsSum() != 3 ) {
1013 if ( !TestGSDI.getEvent( g2_35, "n1_0", "n2_0" ).isSpeciation() ) {
1016 if ( !TestGSDI.getEvent( g2_35, "n1_1", "n3_0" ).isSpeciation() ) {
1019 if ( !TestGSDI.getEvent( g2_35, "n1_0", "n1_1" ).isDuplication() ) {
1022 if ( !TestGSDI.getEvent( g2_35, "n1_0", "n4_0" ).isSpeciationOrDuplication() ) {
1025 if ( !TestGSDI.getEvent( g2_35, "n1_0", "a1_0" ).isSpeciation() ) {
1028 final Phylogeny g2_36 = TestGSDI
1029 .createPhylogeny( "(((a1_0[&&NHX:S=a1],b1_0[&&NHX:S=b1]),(a1_1[&&NHX:S=a1],c1_0[&&NHX:S=c1])),d1_0[&&NHX:S=d1])" );
1030 final GSDI sdi2_36 = new GSDI( g2_36, s2, false );
1031 if ( sdi2_36.getDuplicationsSum() != 1 ) {
1034 if ( sdi2_36.getSpeciationOrDuplicationEventsSum() != 1 ) {
1037 if ( sdi2_36.getSpeciationsSum() != 2 ) {
1040 if ( !TestGSDI.getEvent( g2_36, "a1_0", "b1_0" ).isSpeciation() ) {
1043 if ( !TestGSDI.getEvent( g2_36, "a1_1", "c1_0" ).isSpeciation() ) {
1046 if ( !TestGSDI.getEvent( g2_36, "a1_0", "c1_0" ).isDuplication() ) {
1049 if ( !TestGSDI.getEvent( g2_36, "a1_0", "d1_0" ).isSpeciationOrDuplication() ) {
1052 final Phylogeny g2_37 = TestGSDI
1053 .createPhylogeny( "(((a1_0[&&NHX:S=a1],b1_0[&&NHX:S=b1]),(a2_0[&&NHX:S=a2],c1_0[&&NHX:S=c1])),d1_0[&&NHX:S=d1])" );
1054 final GSDI sdi2_37 = new GSDI( g2_37, s2, false );
1055 if ( sdi2_37.getDuplicationsSum() != 1 ) {
1058 if ( sdi2_37.getSpeciationOrDuplicationEventsSum() != 1 ) {
1061 if ( sdi2_37.getSpeciationsSum() != 2 ) {
1064 if ( !TestGSDI.getEvent( g2_37, "a1_0", "b1_0" ).isSpeciation() ) {
1067 if ( !TestGSDI.getEvent( g2_37, "a2_0", "c1_0" ).isSpeciation() ) {
1070 if ( !TestGSDI.getEvent( g2_37, "a1_0", "c1_0" ).isDuplication() ) {
1073 if ( !TestGSDI.getEvent( g2_37, "a1_0", "d1_0" ).isSpeciationOrDuplication() ) {
1076 final Phylogeny g2_38 = TestGSDI
1077 .createPhylogeny( "(((([&&NHX:S=n1],[&&NHX:S=n1]),([&&NHX:S=n1],[&&NHX:S=n1])),[&&NHX:S=n1]),[&&NHX:S=n1])" );
1078 final GSDI sdi2_38 = new GSDI( g2_38, s2, false );
1079 if ( sdi2_38.getDuplicationsSum() != 5 ) {
1082 if ( sdi2_38.getSpeciationOrDuplicationEventsSum() != 0 ) {
1085 if ( sdi2_38.getSpeciationsSum() != 0 ) {
1088 final Phylogeny g2_100 = TestGSDI
1089 .createPhylogeny( "(((e1[&&NHX:S=e1],f2[&&NHX:S=f2]),(d3[&&NHX:S=d3],g4[&&NHX:S=g4])),(((a1[&&NHX:S=a1],h2[&&NHX:S=h2]),c3[&&NHX:S=c3]),(i4[&&NHX:S=i4],b1[&&NHX:S=b1])))" );
1090 final GSDI sdi2_100 = new GSDI( g2_100, s2, false );
1091 if ( sdi2_100.getDuplicationsSum() != 4 ) {
1094 if ( sdi2_100.getSpeciationOrDuplicationEventsSum() != 0 ) {
1097 if ( sdi2_100.getSpeciationsSum() != 4 ) {
1100 if ( !TestGSDI.getEvent( g2_100, "e1", "f2" ).isSpeciation() ) {
1103 if ( !TestGSDI.getEvent( g2_100, "d3", "g4" ).isSpeciation() ) {
1106 if ( !TestGSDI.getEvent( g2_100, "e1", "d3" ).isDuplication() ) {
1109 if ( !TestGSDI.getEvent( g2_100, "a1", "h2" ).isSpeciation() ) {
1112 if ( !TestGSDI.getEvent( g2_100, "a1", "c3" ).isDuplication() ) {
1115 if ( !TestGSDI.getEvent( g2_100, "i4", "b1" ).isSpeciation() ) {
1118 if ( !TestGSDI.getEvent( g2_100, "a1", "i4" ).isDuplication() ) {
1121 if ( !TestGSDI.getEvent( g2_100, "e1", "a1" ).isDuplication() ) {
1124 final Phylogeny g2_101 = TestGSDI
1125 .createPhylogeny( "(((e1[&&NHX:S=e1],f2[&&NHX:S=f2]),(d3[&&NHX:S=d3],g4[&&NHX:S=g4])),(((a1[&&NHX:S=a1],b2[&&NHX:S=b2]),c3[&&NHX:S=c3]),(i4[&&NHX:S=i4],j1[&&NHX:S=j1])))" );
1126 final GSDI sdi2_101 = new GSDI( g2_101, s2, false );
1127 if ( sdi2_101.getDuplicationsSum() != 2 ) {
1130 if ( sdi2_101.getSpeciationOrDuplicationEventsSum() != 1 ) {
1133 if ( sdi2_101.getSpeciationsSum() != 5 ) {
1136 if ( !TestGSDI.getEvent( g2_101, "e1", "f2" ).isSpeciation() ) {
1139 if ( !TestGSDI.getEvent( g2_101, "d3", "g4" ).isSpeciation() ) {
1142 if ( !TestGSDI.getEvent( g2_101, "e1", "d3" ).isDuplication() ) {
1145 if ( !TestGSDI.getEvent( g2_101, "a1", "b2" ).isSpeciation() ) {
1148 if ( !TestGSDI.getEvent( g2_101, "a1", "c3" ).isSpeciationOrDuplication() ) {
1151 if ( !TestGSDI.getEvent( g2_101, "i4", "j1" ).isSpeciation() ) {
1154 if ( !TestGSDI.getEvent( g2_101, "a1", "i4" ).isSpeciation() ) {
1157 if ( !TestGSDI.getEvent( g2_101, "e1", "a1" ).isDuplication() ) {
1160 final Phylogeny s_7_4 = DevelopmentTools.createBalancedPhylogeny( 7, 4 );
1161 DevelopmentTools.numberSpeciesInOrder( s_7_4 );
1162 final Phylogeny g_7_4_1 = TestGSDI
1163 .createPhylogeny( "(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((("
1164 + "1[&&NHX:S=1],2[&&NHX:S=2]),3[&&NHX:S=3]),4[&&NHX:S=4]),5[&&NHX:S=5]),"
1165 + "6[&&NHX:S=6]),7[&&NHX:S=7]),8[&&NHX:S=8]),9[&&NHX:S=9]),10[&&NHX:S=10]),11[&&NHX:S=11]),"
1166 + "12[&&NHX:S=12]),13[&&NHX:S=13]),14[&&NHX:S=14]),15[&&NHX:S=15]),16[&&NHX:S=16]),17[&&NHX:S=17]),"
1167 + "18[&&NHX:S=18]),19[&&NHX:S=19]),20[&&NHX:S=20]),21[&&NHX:S=21]),22[&&NHX:S=22]),23[&&NHX:S=23]),"
1168 + "24[&&NHX:S=24]),25[&&NHX:S=25]),26[&&NHX:S=26]),27[&&NHX:S=27]),28[&&NHX:S=28]),29[&&NHX:S=29]),"
1169 + "30[&&NHX:S=30]),31[&&NHX:S=31]),32[&&NHX:S=32]),33[&&NHX:S=33]),34[&&NHX:S=34]),35[&&NHX:S=35]),"
1170 + "36[&&NHX:S=36]),37[&&NHX:S=37]),38[&&NHX:S=38]),39[&&NHX:S=39]),40[&&NHX:S=40]),41[&&NHX:S=41]),"
1171 + "42[&&NHX:S=42]),43[&&NHX:S=43]),44[&&NHX:S=44]),45[&&NHX:S=45]),46[&&NHX:S=46]),47[&&NHX:S=47]),"
1172 + "48[&&NHX:S=48]),49[&&NHX:S=49]),50[&&NHX:S=50]),51[&&NHX:S=51]),52[&&NHX:S=52]),53[&&NHX:S=53]),"
1173 + "54[&&NHX:S=54]),55[&&NHX:S=55]),56[&&NHX:S=56]),57[&&NHX:S=57]),58[&&NHX:S=58]),59[&&NHX:S=59]),"
1174 + "60[&&NHX:S=60]),61[&&NHX:S=61]),62[&&NHX:S=62]),63[&&NHX:S=63]),64[&&NHX:S=64]),65[&&NHX:S=65])" );
1175 final GSDI sdi7_4_1 = new GSDI( g_7_4_1, s_7_4, false );
1176 if ( sdi7_4_1.getDuplicationsSum() != 54 ) {
1179 if ( sdi7_4_1.getSpeciationOrDuplicationEventsSum() != 6 ) {
1182 if ( sdi7_4_1.getSpeciationsSum() != 4 ) {
1185 if ( !TestGSDI.getEvent( g_7_4_1, "1", "2" ).isSpeciation() ) {
1188 if ( !TestGSDI.getEvent( g_7_4_1, "1", "3" ).isSpeciationOrDuplication() ) {
1191 if ( !TestGSDI.getEvent( g_7_4_1, "1", "4" ).isSpeciationOrDuplication() ) {
1194 if ( !TestGSDI.getEvent( g_7_4_1, "1", "5" ).isSpeciation() ) {
1197 if ( !TestGSDI.getEvent( g_7_4_1, "1", "6" ).isDuplication() ) {
1200 if ( !TestGSDI.getEvent( g_7_4_1, "1", "9" ).isSpeciationOrDuplication() ) {
1203 if ( !TestGSDI.getEvent( g_7_4_1, "1", "13" ).isSpeciationOrDuplication() ) {
1206 if ( !TestGSDI.getEvent( g_7_4_1, "1", "17" ).isSpeciation() ) {
1209 if ( !TestGSDI.getEvent( g_7_4_1, "1", "33" ).isSpeciationOrDuplication() ) {
1212 if ( !TestGSDI.getEvent( g_7_4_1, "1", "49" ).isSpeciationOrDuplication() ) {
1215 if ( !TestGSDI.getEvent( g_7_4_1, "1", "65" ).isSpeciation() ) {
1218 final Phylogeny g_7_4_2 = TestGSDI
1219 .createPhylogeny( "((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((("
1220 + "1[&&NHX:S=1],2[&&NHX:S=2]),3[&&NHX:S=3]),4[&&NHX:S=4]),5[&&NHX:S=5]),"
1221 + "6[&&NHX:S=6]),7[&&NHX:S=7]),8[&&NHX:S=8]),9[&&NHX:S=9]),10[&&NHX:S=10]),11[&&NHX:S=11]),"
1222 + "12[&&NHX:S=12]),13[&&NHX:S=13]),14[&&NHX:S=14]),15[&&NHX:S=15]),16[&&NHX:S=16]),17[&&NHX:S=17]),"
1223 + "18[&&NHX:S=18]),19[&&NHX:S=19]),20[&&NHX:S=20]),21[&&NHX:S=21]),22[&&NHX:S=22]),23[&&NHX:S=23]),"
1224 + "24[&&NHX:S=24]),25[&&NHX:S=25]),26[&&NHX:S=26]),27[&&NHX:S=27]),28[&&NHX:S=28]),29[&&NHX:S=29]),"
1225 + "30[&&NHX:S=30]),31[&&NHX:S=31]),32[&&NHX:S=32]),33[&&NHX:S=33]),34[&&NHX:S=34]),35[&&NHX:S=35]),"
1226 + "36[&&NHX:S=36]),37[&&NHX:S=37]),38[&&NHX:S=38]),39[&&NHX:S=39]),40[&&NHX:S=40]),41[&&NHX:S=41]),"
1227 + "42[&&NHX:S=42]),43[&&NHX:S=43]),44[&&NHX:S=44]),45[&&NHX:S=45]),46[&&NHX:S=46]),47[&&NHX:S=47]),"
1228 + "48[&&NHX:S=48]),49[&&NHX:S=49]),50[&&NHX:S=50]),51[&&NHX:S=51]),52[&&NHX:S=52]),53[&&NHX:S=53]),"
1229 + "54[&&NHX:S=54]),55[&&NHX:S=55]),56[&&NHX:S=56]),57[&&NHX:S=57]),58[&&NHX:S=58]),59[&&NHX:S=59]),"
1230 + "60[&&NHX:S=60]),61[&&NHX:S=61]),62[&&NHX:S=62]),63[&&NHX:S=63]),64[&&NHX:S=64]),65[&&NHX:S=65]),"
1231 + "66[&&NHX:S=66]),257[&&NHX:S=257]),258[&&NHX:S=258]),513[&&NHX:S=513]),514[&&NHX:S=514]),769[&&NHX:S=769]),770[&&NHX:S=770])" );
1232 final GSDI sdi7_4_2 = new GSDI( g_7_4_2, s_7_4, false );
1233 if ( sdi7_4_2.getDuplicationsSum() != 58 ) {
1236 if ( sdi7_4_2.getSpeciationOrDuplicationEventsSum() != 8 ) {
1239 if ( sdi7_4_2.getSpeciationsSum() != 5 ) {
1242 final String g2_0_ = "(([&&NHX:S=a1],[&&NHX:S=a2]),([&&NHX:S=o2],[&&NHX:S=o4]))";
1243 final Phylogeny g2_0p = TestGSDI.createPhylogeny( g2_0_ );
1244 g2_0.setRooted( true );
1245 final GSDI sdi2_0p = new GSDI( g2_0p, s2, false );
1246 if ( sdi2_0p.getDuplicationsSum() != 0 ) {
1250 final Phylogeny tol_143_ = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA + "tol_143.xml" )[ 0 ];
1251 final Phylogeny gene_tree_tax_code_4_ = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1252 + "gene_tree_tax_code_4.xml" )[ 0 ];
1253 final GSDI gsdi_143_4_1 = new GSDI( gene_tree_tax_code_4_.copy(), tol_143_.copy(), false, true, true );
1254 if ( gsdi_143_4_1.getDuplicationsSum() != 21 ) {
1257 if ( gsdi_143_4_1.getSpeciationsSum() != 28 ) {
1260 if ( gsdi_143_4_1.getSpeciationOrDuplicationEventsSum() != 6 ) {
1264 final Phylogeny gsdi_test_gene_tree_sn_wnt = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1265 + "gsdi_test_gene_tree_sn_wnt.xml" )[ 0 ];
1266 gsdi_test_gene_tree_sn_wnt.setRooted( true );
1267 final GSDI a = new GSDI( gsdi_test_gene_tree_sn_wnt.copy(), tol_143_.copy(), false, true, true );
1268 if ( a.getDuplicationsSum() != 33 ) {
1271 if ( a.getSpeciationsSum() != 31 ) {
1274 if ( a.getSpeciationOrDuplicationEventsSum() != 0 ) {
1277 if ( a.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) {
1280 if ( a.getMappedExternalSpeciesTreeNodes().size() != 26 ) {
1283 if ( a.getReMappedScientificNamesFromGeneTree().size() != 0 ) {
1287 final Phylogeny gsdi_test_species_tree_sn_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1288 + "gsdi_test_species_tree_sn.xml" )[ 0 ];
1289 final GSDI b = new GSDI( gsdi_test_gene_tree_sn_wnt.copy(),
1290 gsdi_test_species_tree_sn_xml.copy(),
1294 if ( b.getDuplicationsSum() != 8 ) {
1297 if ( b.getSpeciationsSum() != 2 ) {
1300 if ( b.getSpeciationOrDuplicationEventsSum() != 0 ) {
1303 if ( b.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) {
1306 if ( b.getMappedExternalSpeciesTreeNodes().size() != 2 ) {
1309 if ( b.getReMappedScientificNamesFromGeneTree().size() != 0 ) {
1312 if ( b.getStrippedExternalGeneTreeNodes().size() != 87 ) {
1315 if ( b.getStrippedSpeciesTreeNodes().size() != 17 ) {
1319 final Phylogeny gsdi_test_species_tree_sn_nh = TestGSDI
1320 .createPhylogeny( "((((((('Homo sapiens','Mus musculus')Euarchontoglires,'Petromyzon marinus')Vertebrata,'Nematostella vectensis')'Bilateria Cnidaria',(('Mycosphaerella graminicola','Mycosphaerella pini')Mycosphaerella,'Saccharomyces cerevisiae')'Pezizomycotina Saccharomycetales')Opisthokonta,('Plasmodium chabaudi','Plasmodium falciparum','Plasmodium yoelii yoelii')Plasmodium)Eukaryota,'Pyrococcus horikoshii')Neomura,(('Kineococcus radiotolerans','Kocuria rhizophila','Streptomyces coelicolor','Thermobifida fusca','Microlunatus phosphovorus'),'Bacteroides thetaiotaomicron'))'cellular organisms';" );
1321 PhylogenyMethods.transferNodeNameToField( gsdi_test_species_tree_sn_nh,
1322 PhylogenyMethods.PhylogenyNodeField.TAXONOMY_SCIENTIFIC_NAME,
1324 final GSDI c = new GSDI( gsdi_test_gene_tree_sn_wnt.copy(),
1325 gsdi_test_species_tree_sn_nh.copy(),
1329 if ( c.getDuplicationsSum() != 8 ) {
1332 if ( c.getSpeciationsSum() != 2 ) {
1335 if ( c.getSpeciationOrDuplicationEventsSum() != 0 ) {
1338 if ( c.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) {
1341 if ( c.getMappedExternalSpeciesTreeNodes().size() != 2 ) {
1344 if ( c.getReMappedScientificNamesFromGeneTree().size() != 0 ) {
1347 if ( c.getStrippedExternalGeneTreeNodes().size() != 87 ) {
1350 if ( c.getStrippedSpeciesTreeNodes().size() != 15 ) {
1354 final Phylogeny gsdi_test_gene_tree_codes_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1355 + "gsdi_test_gene_tree_codes.xml" )[ 0 ];
1356 final Phylogeny gsdi_test_species_tree_codes_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1357 + "gsdi_test_species_tree_codes.xml" )[ 0 ];
1358 final GSDI d = new GSDI( gsdi_test_gene_tree_codes_xml.copy(),
1359 gsdi_test_species_tree_codes_xml.copy(),
1363 if ( d.getDuplicationsSum() != 21 ) {
1366 if ( d.getSpeciationsSum() != 28 ) {
1369 if ( d.getSpeciationOrDuplicationEventsSum() != 6 ) {
1372 if ( d.getTaxCompBase() != TaxonomyComparisonBase.CODE ) {
1375 if ( d.getMappedExternalSpeciesTreeNodes().size() != 17 ) {
1378 if ( d.getReMappedScientificNamesFromGeneTree().size() != 0 ) {
1381 if ( d.getStrippedExternalGeneTreeNodes().size() != 12 ) {
1384 if ( d.getStrippedSpeciesTreeNodes().size() != 3 ) {
1388 final Phylogeny gsdi_test_gene_tree_sn_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1389 + "gsdi_test_gene_tree_sn.xml" )[ 0 ];
1390 final GSDI e = new GSDI( gsdi_test_gene_tree_sn_xml.copy(),
1391 gsdi_test_species_tree_sn_xml.copy(),
1395 if ( e.getDuplicationsSum() != 7 ) {
1398 if ( e.getSpeciationsSum() != 9 ) {
1401 if ( e.getSpeciationOrDuplicationEventsSum() != 1 ) {
1404 if ( e.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) {
1407 if ( e.getMappedExternalSpeciesTreeNodes().size() != 12 ) {
1410 if ( e.getReMappedScientificNamesFromGeneTree().size() != 8 ) {
1413 if ( e.getStrippedExternalGeneTreeNodes().size() != 3 ) {
1416 if ( e.getStrippedSpeciesTreeNodes().size() != 7 ) {
1420 catch ( final Exception e ) {
1421 e.printStackTrace( System.out );
1427 public static void main( final String[] args ) {
1428 if ( !TestGSDI.testGSDI_against_binary_gene_tree() ) {
1429 System.out.println( "binary failed" );
1431 if ( !TestGSDI.testGSDI_general() ) {
1432 System.out.println( "general failed" );
1435 System.out.println( "general OK" );
1437 // boolean success = test();
1439 // System.out.println( "OK" );
1442 // System.out.println( "failed" );