"rio" work + clean up
[jalview.git] / forester / java / src / org / forester / sdi / TestGSDI.java
1 // $Id:
2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
4 //
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 // All rights reserved
8 //
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.
13 //
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.
18 //
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
22 //
23 // Contact: phylosoft @ gmail . com
24 // WWW: www.phylosoft.org/forester
25
26 package org.forester.sdi;
27
28 import java.io.IOException;
29
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.SDIutil.TaxonomyComparisonBase;
39 import org.forester.util.ForesterUtil;
40
41 public final class TestGSDI {
42
43     private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" ) + ForesterUtil.getFileSeparator()
44                                                           + "test_data" + ForesterUtil.getFileSeparator();
45
46     public static void main( final String[] args ) {
47         if ( !TestGSDI.testGSDI_against_binary_gene_tree() ) {
48             System.out.println( "binary failed" );
49         }
50         if ( !TestGSDI.testGSDI_general() ) {
51             System.out.println( "general failed" );
52         }
53         if ( !TestGSDI.testGSDIR_general() ) {
54             System.out.println( "general re-rooting failed" );
55         }
56         else {
57             System.out.println( "OK" );
58         }
59         //        boolean success = test();
60         //        if ( success ) {
61         //            System.out.println( "OK" );
62         //        }
63         //        else {
64         //            System.out.println( "failed" );
65         //        }
66     }
67
68     public static boolean test() {
69         if ( !TestGSDI.testGSDI_general() ) {
70             return false;
71         }
72         if ( !TestGSDI.testGSDI_against_binary_gene_tree() ) {
73             return false;
74         }
75         if ( !TestGSDI.testGSDIR_general() ) {
76             return false;
77         }
78         return true;
79     }
80
81     private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
82         final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
83         p.setRooted( true );
84         return p;
85     }
86
87     private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
88         return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
89     }
90
91     private static boolean testGSDI_against_binary_gene_tree() {
92         try {
93             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
94             final String multi_species_2_str = "(((((([&&NHX:S=1],[&&NHX:S=2]),"
95                     + "([&&NHX:S=3],[&&NHX:S=4],[&&NHX:S=5])),"
96                     + "([&&NHX:S=6],[&&NHX:S=7],[&&NHX:S=8],[&&NHX:S=9])),"
97                     + "([&&NHX:S=10],[&&NHX:S=11])),"
98                     + "([&&NHX:S=12],[&&NHX:S=13],[&&NHX:S=14])),"
99                     + "([&&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])));";
100             final String gene_2_1_str = "(((((([&&NHX:S=1],[&&NHX:S=2])1_2,([&&NHX:S=3],[&&NHX:S=4])),"
101                     + "([&&NHX:S=6],[&&NHX:S=7])6_7_8_9)1_9,([&&NHX:S=10],[&&NHX:S=11])),"
102                     + "([&&NHX:S=12],[&&NHX:S=13])12_13_14)1_14,"
103                     + "([&&NHX:S=15],([&&NHX:S=21],[&&NHX:S=24])21_22_23_24)15_24);";
104             final Phylogeny multi_species_2 = factory.create( multi_species_2_str, new NHXParser() )[ 0 ];
105             final Phylogeny gene_2_1 = factory.create( gene_2_1_str, new NHXParser() )[ 0 ];
106             multi_species_2.setRooted( true );
107             gene_2_1.setRooted( true );
108             final GSDI sdi = new GSDI( gene_2_1, multi_species_2, false, false, false );
109             if ( sdi.getSpeciationOrDuplicationEventsSum() != 0 ) {
110                 return false;
111             }
112             if ( sdi.getDuplicationsSum() != 0 ) {
113                 return false;
114             }
115         }
116         catch ( final Exception e ) {
117             e.printStackTrace( System.out );
118             return false;
119         }
120         return true;
121     }
122
123     private static boolean testGSDI_general() {
124         try {
125             final String s2_ = "((" + "([&&NHX:S=a1],[&&NHX:S=a2],[&&NHX:S=a3],[&&NHX:S=a4]),"
126                     + "([&&NHX:S=b1],[&&NHX:S=b2],[&&NHX:S=b3],[&&NHX:S=b4]),"
127                     + "([&&NHX:S=c1],[&&NHX:S=c2],[&&NHX:S=c3],[&&NHX:S=c4]),"
128                     + "([&&NHX:S=d1],[&&NHX:S=d2],[&&NHX:S=d3],[&&NHX:S=d4])),("
129                     + "([&&NHX:S=e1],[&&NHX:S=e2],[&&NHX:S=e3],[&&NHX:S=e4]),"
130                     + "([&&NHX:S=f1],[&&NHX:S=f2],[&&NHX:S=f3],[&&NHX:S=f4]),"
131                     + "([&&NHX:S=g1],[&&NHX:S=g2],[&&NHX:S=g3],[&&NHX:S=g4]),"
132                     + "([&&NHX:S=h1],[&&NHX:S=h2],[&&NHX:S=h3],[&&NHX:S=h4])),("
133                     + "([&&NHX:S=i1],[&&NHX:S=i2],[&&NHX:S=i3],[&&NHX:S=i4]),"
134                     + "([&&NHX:S=j1],[&&NHX:S=j2],[&&NHX:S=j3],[&&NHX:S=j4]),"
135                     + "([&&NHX:S=k1],[&&NHX:S=k2],[&&NHX:S=k3],[&&NHX:S=k4]),"
136                     + "([&&NHX:S=l1],[&&NHX:S=l2],[&&NHX:S=l3],[&&NHX:S=l4])),("
137                     + "([&&NHX:S=m1],[&&NHX:S=m2],[&&NHX:S=m3],[&&NHX:S=m4]),"
138                     + "([&&NHX:S=n1],[&&NHX:S=n2],[&&NHX:S=n3],[&&NHX:S=n4]),"
139                     + "([&&NHX:S=o1],[&&NHX:S=o2],[&&NHX:S=o3],[&&NHX:S=o4]),"
140                     + "([&&NHX:S=p1],[&&NHX:S=p2],[&&NHX:S=p3],[&&NHX:S=p4])"
141                     + "),[&&NHX:S=x],[&&NHX:S=y],[&&NHX:S=z])";
142             final Phylogeny s2 = ParserBasedPhylogenyFactory.getInstance().create( s2_, new NHXParser() )[ 0 ];
143             s2.setRooted( true );
144             final String s1_ = "((([&&NHX:S=A2],[&&NHX:S=A1]),[&&NHX:S=B],[&&NHX:S=C]),[&&NHX:S=D])";
145             final Phylogeny s1 = ParserBasedPhylogenyFactory.getInstance().create( s1_, new NHXParser() )[ 0 ];
146             s1.setRooted( true );
147             final Phylogeny g1 = TestGSDI
148                     .createPhylogeny( "((((B[&&NHX:S=B],A1[&&NHX:S=A1]),C[&&NHX:S=C]),A2[&&NHX:S=A2]),D[&&NHX:S=D])" );
149             final GSDI sdi1 = new GSDI( g1, s1, false, false, false );
150             // Archaeopteryx.createApplication( g1 );
151             // Archaeopteryx.createApplication( s1 );
152             if ( sdi1.getDuplicationsSum() != 1 ) {
153                 return false;
154             }
155             if ( !PhylogenyMethods.calculateLCA( g1.getNode( "B" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
156                     .isSpeciation() ) {
157                 return false;
158             }
159             if ( !PhylogenyMethods.calculateLCA( g1.getNode( "C" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
160                     .isSpeciationOrDuplication() ) {
161                 return false;
162             }
163             if ( !( PhylogenyMethods.calculateLCA( g1.getNode( "A2" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
164                     .isDuplication() ) ) {
165                 return false;
166             }
167             if ( !PhylogenyMethods.calculateLCA( g1.getNode( "D" ), g1.getNode( "A1" ) ).getNodeData().getEvent()
168                     .isSpeciation() ) {
169                 return false;
170             }
171             final Phylogeny g2 = TestGSDI
172                     .createPhylogeny( "((((A2[&&NHX:S=A2],A1[&&NHX:S=A1]),B[&&NHX:S=B]),C[&&NHX:S=C]),D[&&NHX:S=D])" );
173             final GSDI sdi2 = new GSDI( g2, s1, false, false, false );
174             if ( sdi2.getDuplicationsSum() != 0 ) {
175                 return false;
176             }
177             if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "A2" ) ).getNodeData().getEvent()
178                     .isSpeciation() ) {
179                 return false;
180             }
181             if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "B" ) ).getNodeData().getEvent()
182                     .isSpeciation() ) {
183                 return false;
184             }
185             if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "C" ) ).getNodeData().getEvent()
186                     .isSpeciationOrDuplication() ) {
187                 return false;
188             }
189             if ( !PhylogenyMethods.calculateLCA( g2.getNode( "A1" ), g2.getNode( "D" ) ).getNodeData().getEvent()
190                     .isSpeciation() ) {
191                 return false;
192             }
193             final Phylogeny g3 = TestGSDI
194                     .createPhylogeny( "((((A2[&&NHX:S=A2],A1[&&NHX:S=A1]),C[&&NHX:S=C]),B[&&NHX:S=B]),D[&&NHX:S=D])" );
195             final GSDI sdi3 = new GSDI( g3, s1, false, false, false );
196             if ( sdi3.getDuplicationsSum() != 0 ) {
197                 return false;
198             }
199             if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "A2" ) ).getNodeData().getEvent()
200                     .isSpeciation() ) {
201                 return false;
202             }
203             if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "C" ) ).getNodeData().getEvent()
204                     .isSpeciation() ) {
205                 return false;
206             }
207             if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "B" ) ).getNodeData().getEvent()
208                     .isSpeciationOrDuplication() ) {
209                 return false;
210             }
211             if ( !PhylogenyMethods.calculateLCA( g3.getNode( "A1" ), g3.getNode( "D" ) ).getNodeData().getEvent()
212                     .isSpeciation() ) {
213                 return false;
214             }
215             final Phylogeny g4 = TestGSDI
216                     .createPhylogeny( "(((B[&&NHX:S=B],C1[&&NHX:S=C]),C2[&&NHX:S=C]),D[&&NHX:S=D])" );
217             final GSDI sdi4 = new GSDI( g4, s1, false, false, false );
218             if ( sdi4.getDuplicationsSum() != 1 ) {
219                 return false;
220             }
221             if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "C1" ) ).getNodeData().getEvent()
222                     .isSpeciation() ) {
223                 return false;
224             }
225             if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "C2" ) ).getNodeData().getEvent()
226                     .isDuplication() ) {
227                 return false;
228             }
229             if ( !PhylogenyMethods.calculateLCA( g4.getNode( "B" ), g4.getNode( "D" ) ).getNodeData().getEvent()
230                     .isSpeciation() ) {
231                 return false;
232             }
233             final Phylogeny g5 = TestGSDI
234                     .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]))" );
235             final GSDI sdi5 = new GSDI( g5, s1, false, false, false );
236             if ( sdi5.getDuplicationsSum() != 3 ) {
237                 return false;
238             }
239             if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "A1" ) ).getNodeData().getEvent()
240                     .isSpeciation() ) {
241                 return false;
242             }
243             if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "B" ) ).getNodeData().getEvent()
244                     .isDuplication() ) {
245                 return false;
246             }
247             if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D1" ), g5.getNode( "D2" ) ).getNodeData().getEvent()
248                     .isDuplication() ) {
249                 return false;
250             }
251             if ( !PhylogenyMethods.calculateLCA( g5.getNode( "D2" ), g5.getNode( "D3" ) ).getNodeData().getEvent()
252                     .isDuplication() ) {
253                 return false;
254             }
255             if ( !PhylogenyMethods.calculateLCA( g5.getNode( "C" ), g5.getNode( "D3" ) ).getNodeData().getEvent()
256                     .isSpeciation() ) {
257                 return false;
258             }
259             final Phylogeny species7 = TestGSDI.createPhylogeny( "(((((((([&&NHX:S=a1],[&&NHX:S=a2]),"
260                     + "([&&NHX:S=b1],[&&NHX:S=b2])),[&&NHX:S=x]),(([&&NHX:S=m1],[&&NHX:S=m2]),"
261                     + "([&&NHX:S=n1],[&&NHX:S=n2]))),(([&&NHX:S=i1],[&&NHX:S=i2]),"
262                     + "([&&NHX:S=j1],[&&NHX:S=j2]))),(([&&NHX:S=e1],[&&NHX:S=e2]),"
263                     + "([&&NHX:S=f1],[&&NHX:S=f2]))),[&&NHX:S=y]),[&&NHX:S=z])" );
264             final Phylogeny gene7_2 = TestGSDI
265                     .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])" );
266             gene7_2.setRooted( true );
267             final GSDI sdi7_2 = new GSDI( gene7_2, species7, false, false, false );
268             if ( sdi7_2.getDuplicationsSum() != 1 ) {
269                 return false;
270             }
271             if ( !TestGSDI.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
272                 return false;
273             }
274             if ( !TestGSDI.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
275                 return false;
276             }
277             if ( !TestGSDI.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
278                 return false;
279             }
280             if ( !TestGSDI.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
281                 return false;
282             }
283             if ( !TestGSDI.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
284                 return false;
285             }
286             if ( !TestGSDI.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
287                 return false;
288             }
289             if ( !TestGSDI.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
290                 return false;
291             }
292             if ( !TestGSDI.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
293                 return false;
294             }
295             if ( !TestGSDI.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
296                 return false;
297             }
298             final Phylogeny g2_0 = TestGSDI.createPhylogeny( "(m1[&&NHX:S=m1],m3[&&NHX:S=m3])" );
299             final GSDI sdi2_0 = new GSDI( g2_0, s2, false, false, false );
300             if ( sdi2_0.getDuplicationsSum() != 0 ) {
301                 return false;
302             }
303             if ( sdi2_0.getSpeciationOrDuplicationEventsSum() != 0 ) {
304                 return false;
305             }
306             if ( sdi2_0.getSpeciationsSum() != 1 ) {
307                 return false;
308             }
309             if ( !PhylogenyMethods.calculateLCA( g2_0.getNode( "m1" ), g2_0.getNode( "m3" ) ).getNodeData().getEvent()
310                     .isSpeciation() ) {
311                 return false;
312             }
313             final Phylogeny g2_1 = TestGSDI.createPhylogeny( "(e2[&&NHX:S=e2],h2[&&NHX:S=h2])" );
314             final GSDI sdi2_1 = new GSDI( g2_1, s2, false, false, false );
315             if ( sdi2_1.getDuplicationsSum() != 0 ) {
316                 return false;
317             }
318             if ( sdi2_1.getSpeciationOrDuplicationEventsSum() != 0 ) {
319                 return false;
320             }
321             if ( sdi2_1.getSpeciationsSum() != 1 ) {
322                 return false;
323             }
324             if ( !PhylogenyMethods.calculateLCA( g2_1.getNode( "e2" ), g2_1.getNode( "h2" ) ).getNodeData().getEvent()
325                     .isSpeciation() ) {
326                 return false;
327             }
328             final Phylogeny g2_2 = TestGSDI.createPhylogeny( "(e2[&&NHX:S=e2],p4[&&NHX:S=p4])" );
329             final GSDI sdi2_2 = new GSDI( g2_2, s2, false, false, false );
330             if ( sdi2_2.getDuplicationsSum() != 0 ) {
331                 return false;
332             }
333             if ( sdi2_2.getSpeciationOrDuplicationEventsSum() != 0 ) {
334                 return false;
335             }
336             if ( sdi2_2.getSpeciationsSum() != 1 ) {
337                 return false;
338             }
339             if ( !PhylogenyMethods.calculateLCA( g2_2.getNode( "e2" ), g2_2.getNode( "p4" ) ).getNodeData().getEvent()
340                     .isSpeciation() ) {
341                 return false;
342             }
343             final Phylogeny g2_3 = TestGSDI.createPhylogeny( "(e2a[&&NHX:S=e2],e2b[&&NHX:S=e2])" );
344             final GSDI sdi2_3 = new GSDI( g2_3, s2, false, false, false );
345             if ( sdi2_3.getDuplicationsSum() != 1 ) {
346                 return false;
347             }
348             if ( sdi2_3.getSpeciationOrDuplicationEventsSum() != 0 ) {
349                 return false;
350             }
351             if ( sdi2_3.getSpeciationsSum() != 0 ) {
352                 return false;
353             }
354             if ( !PhylogenyMethods.calculateLCA( g2_3.getNode( "e2a" ), g2_3.getNode( "e2b" ) ).getNodeData()
355                     .getEvent().isDuplication() ) {
356                 return false;
357             }
358             final Phylogeny g2_4 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],j4[&&NHX:S=j4]),i3[&&NHX:S=i3])" );
359             final GSDI sdi2_4 = new GSDI( g2_4, s2, false, false, false );
360             if ( sdi2_4.getDuplicationsSum() != 0 ) {
361                 return false;
362             }
363             if ( sdi2_4.getSpeciationOrDuplicationEventsSum() != 0 ) {
364                 return false;
365             }
366             if ( sdi2_4.getSpeciationsSum() != 2 ) {
367                 return false;
368             }
369             if ( !PhylogenyMethods.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "j4" ) ).getNodeData().getEvent()
370                     .isSpeciation() ) {
371                 return false;
372             }
373             if ( !PhylogenyMethods.calculateLCA( g2_4.getNode( "j1" ), g2_4.getNode( "i3" ) ).getNodeData().getEvent()
374                     .isSpeciation() ) {
375                 return false;
376             }
377             final Phylogeny g2_5 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],j4[&&NHX:S=j4]),f3[&&NHX:S=f3])" );
378             final GSDI sdi2_5 = new GSDI( g2_5, s2, false, false, false );
379             if ( sdi2_5.getDuplicationsSum() != 0 ) {
380                 return false;
381             }
382             if ( sdi2_5.getSpeciationOrDuplicationEventsSum() != 0 ) {
383                 return false;
384             }
385             if ( sdi2_5.getSpeciationsSum() != 2 ) {
386                 return false;
387             }
388             if ( !PhylogenyMethods.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "j4" ) ).getNodeData().getEvent()
389                     .isSpeciation() ) {
390                 return false;
391             }
392             if ( !PhylogenyMethods.calculateLCA( g2_5.getNode( "j1" ), g2_5.getNode( "f3" ) ).getNodeData().getEvent()
393                     .isSpeciation() ) {
394                 return false;
395             }
396             final Phylogeny g2_6 = TestGSDI.createPhylogeny( "((j3[&&NHX:S=j3],i4[&&NHX:S=i4]),f3[&&NHX:S=f3])" );
397             final GSDI sdi2_6 = new GSDI( g2_6, s2, false, false, false );
398             if ( sdi2_6.getDuplicationsSum() != 0 ) {
399                 return false;
400             }
401             if ( sdi2_6.getSpeciationOrDuplicationEventsSum() != 0 ) {
402                 return false;
403             }
404             if ( sdi2_6.getSpeciationsSum() != 2 ) {
405                 return false;
406             }
407             if ( !PhylogenyMethods.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "i4" ) ).getNodeData().getEvent()
408                     .isSpeciation() ) {
409                 return false;
410             }
411             if ( !PhylogenyMethods.calculateLCA( g2_6.getNode( "j3" ), g2_6.getNode( "f3" ) ).getNodeData().getEvent()
412                     .isSpeciation() ) {
413                 return false;
414             }
415             final Phylogeny g2_7 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],k1[&&NHX:S=k1]),i1[&&NHX:S=i1])" );
416             final GSDI sdi2_7 = new GSDI( g2_7, s2, false, false, false );
417             if ( sdi2_7.getDuplicationsSum() != 0 ) {
418                 return false;
419             }
420             if ( sdi2_7.getSpeciationOrDuplicationEventsSum() != 1 ) {
421                 return false;
422             }
423             if ( sdi2_7.getSpeciationsSum() != 1 ) {
424                 return false;
425             }
426             if ( !PhylogenyMethods.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "k1" ) ).getNodeData().getEvent()
427                     .isSpeciation() ) {
428                 return false;
429             }
430             if ( !PhylogenyMethods.calculateLCA( g2_7.getNode( "j1" ), g2_7.getNode( "i1" ) ).getNodeData().getEvent()
431                     .isSpeciationOrDuplication() ) {
432                 return false;
433             }
434             final Phylogeny g2_8 = TestGSDI.createPhylogeny( "(j1[&&NHX:S=j1],(k1[&&NHX:S=k1],i1[&&NHX:S=i1]))" );
435             final GSDI sdi2_8 = new GSDI( g2_8, s2, false, false, false );
436             if ( sdi2_8.getDuplicationsSum() != 0 ) {
437                 return false;
438             }
439             if ( sdi2_8.getSpeciationOrDuplicationEventsSum() != 1 ) {
440                 return false;
441             }
442             if ( sdi2_8.getSpeciationsSum() != 1 ) {
443                 return false;
444             }
445             if ( !PhylogenyMethods.calculateLCA( g2_8.getNode( "j1" ), g2_8.getNode( "k1" ) ).getNodeData().getEvent()
446                     .isSpeciationOrDuplication() ) {
447                 return false;
448             }
449             if ( !PhylogenyMethods.calculateLCA( g2_8.getNode( "k1" ), g2_8.getNode( "i1" ) ).getNodeData().getEvent()
450                     .isSpeciation() ) {
451                 return false;
452             }
453             final Phylogeny g2_9 = TestGSDI.createPhylogeny( "((j1[&&NHX:S=j1],k4[&&NHX:S=k4]),f2[&&NHX:S=f2])" );
454             final GSDI sdi2_9 = new GSDI( g2_9, s2, false, false, false );
455             if ( sdi2_9.getDuplicationsSum() != 0 ) {
456                 return false;
457             }
458             if ( sdi2_9.getSpeciationOrDuplicationEventsSum() != 0 ) {
459                 return false;
460             }
461             if ( sdi2_9.getSpeciationsSum() != 2 ) {
462                 return false;
463             }
464             if ( !TestGSDI.getEvent( g2_9, "j1", "k4" ).isSpeciation() ) {
465                 return false;
466             }
467             if ( !TestGSDI.getEvent( g2_9, "j1", "f2" ).isSpeciation() ) {
468                 return false;
469             }
470             final Phylogeny g2_10 = TestGSDI.createPhylogeny( "((m1[&&NHX:S=m1],k4[&&NHX:S=k4]),f2[&&NHX:S=f2])" );
471             final GSDI sdi2_10 = new GSDI( g2_10, s2, false, false, false );
472             if ( sdi2_10.getDuplicationsSum() != 0 ) {
473                 return false;
474             }
475             if ( sdi2_10.getSpeciationOrDuplicationEventsSum() != 1 ) {
476                 return false;
477             }
478             if ( sdi2_10.getSpeciationsSum() != 1 ) {
479                 return false;
480             }
481             if ( !TestGSDI.getEvent( g2_10, "m1", "k4" ).isSpeciation() ) {
482                 return false;
483             }
484             if ( !TestGSDI.getEvent( g2_10, "m1", "f2" ).isSpeciationOrDuplication() ) {
485                 return false;
486             }
487             final Phylogeny g2_11 = TestGSDI.createPhylogeny( "((m1[&&NHX:S=m1],k4[&&NHX:S=k4]),x[&&NHX:S=x])" );
488             final GSDI sdi2_11 = new GSDI( g2_11, s2, false, false, false );
489             if ( sdi2_11.getDuplicationsSum() != 0 ) {
490                 return false;
491             }
492             if ( sdi2_11.getSpeciationOrDuplicationEventsSum() != 1 ) {
493                 return false;
494             }
495             if ( sdi2_11.getSpeciationsSum() != 1 ) {
496                 return false;
497             }
498             if ( !TestGSDI.getEvent( g2_11, "m1", "k4" ).isSpeciation() ) {
499                 return false;
500             }
501             if ( !TestGSDI.getEvent( g2_11, "m1", "x" ).isSpeciationOrDuplication() ) {
502                 return false;
503             }
504             final Phylogeny g2_12 = TestGSDI.createPhylogeny( "(m1[&&NHX:S=m1],(k4[&&NHX:S=k4],x[&&NHX:S=x]))" );
505             final GSDI sdi2_12 = new GSDI( g2_12, s2, false, false, false );
506             if ( sdi2_12.getDuplicationsSum() != 0 ) {
507                 return false;
508             }
509             if ( sdi2_12.getSpeciationOrDuplicationEventsSum() != 1 ) {
510                 return false;
511             }
512             if ( sdi2_12.getSpeciationsSum() != 1 ) {
513                 return false;
514             }
515             if ( !TestGSDI.getEvent( g2_12, "x", "k4" ).isSpeciation() ) {
516                 return false;
517             }
518             if ( !TestGSDI.getEvent( g2_12, "m1", "x" ).isSpeciationOrDuplication() ) {
519                 return false;
520             }
521             final Phylogeny g2_13 = TestGSDI.createPhylogeny( "(x[&&NHX:S=x],(y[&&NHX:S=y],z[&&NHX:S=z]))" );
522             final GSDI sdi2_13 = new GSDI( g2_13, s2, false, false, false );
523             if ( sdi2_13.getDuplicationsSum() != 0 ) {
524                 return false;
525             }
526             if ( sdi2_13.getSpeciationOrDuplicationEventsSum() != 1 ) {
527                 return false;
528             }
529             if ( sdi2_13.getSpeciationsSum() != 1 ) {
530                 return false;
531             }
532             if ( !TestGSDI.getEvent( g2_13, "y", "z" ).isSpeciation() ) {
533                 return false;
534             }
535             if ( !TestGSDI.getEvent( g2_13, "x", "z" ).isSpeciationOrDuplication() ) {
536                 return false;
537             }
538             final Phylogeny g2_14 = TestGSDI.createPhylogeny( "(a1_1[&&NHX:S=a1],(b1[&&NHX:S=b1],a1[&&NHX:S=a1]))" );
539             final GSDI sdi2_14 = new GSDI( g2_14, s2, false, false, false );
540             if ( sdi2_14.getDuplicationsSum() != 1 ) {
541                 return false;
542             }
543             if ( sdi2_14.getSpeciationOrDuplicationEventsSum() != 0 ) {
544                 return false;
545             }
546             if ( sdi2_14.getSpeciationsSum() != 1 ) {
547                 return false;
548             }
549             if ( !TestGSDI.getEvent( g2_14, "b1", "a1" ).isSpeciation() ) {
550                 return false;
551             }
552             if ( !TestGSDI.getEvent( g2_14, "b1", "a1_1" ).isDuplication() ) {
553                 return false;
554             }
555             final Phylogeny g2_15 = TestGSDI.createPhylogeny( "(a2[&&NHX:S=a2],(b1[&&NHX:S=b1],a1[&&NHX:S=a1]))" );
556             final GSDI sdi2_15 = new GSDI( g2_15, s2, false, false, false );
557             if ( sdi2_15.getDuplicationsSum() != 1 ) {
558                 return false;
559             }
560             if ( sdi2_15.getSpeciationOrDuplicationEventsSum() != 0 ) {
561                 return false;
562             }
563             if ( sdi2_15.getSpeciationsSum() != 1 ) {
564                 return false;
565             }
566             if ( !TestGSDI.getEvent( g2_15, "b1", "a1" ).isSpeciation() ) {
567                 return false;
568             }
569             if ( !TestGSDI.getEvent( g2_15, "b1", "a2" ).isDuplication() ) {
570                 return false;
571             }
572             final Phylogeny g2_16 = TestGSDI.createPhylogeny( "(n2[&&NHX:S=n2],(j3[&&NHX:S=j3],n1[&&NHX:S=n1]))" );
573             final GSDI sdi2_16 = new GSDI( g2_16, s2, false, false, false );
574             if ( sdi2_16.getDuplicationsSum() != 1 ) {
575                 return false;
576             }
577             if ( sdi2_16.getSpeciationOrDuplicationEventsSum() != 0 ) {
578                 return false;
579             }
580             if ( sdi2_16.getSpeciationsSum() != 1 ) {
581                 return false;
582             }
583             if ( !TestGSDI.getEvent( g2_16, "j3", "n1" ).isSpeciation() ) {
584                 return false;
585             }
586             if ( !TestGSDI.getEvent( g2_16, "j3", "n2" ).isDuplication() ) {
587                 return false;
588             }
589             final Phylogeny g2_17 = TestGSDI.createPhylogeny( "(p4[&&NHX:S=p4],(j3[&&NHX:S=j3],n1[&&NHX:S=n1]))" );
590             final GSDI sdi2_17 = new GSDI( g2_17, s2, false, false, false );
591             if ( sdi2_17.getDuplicationsSum() != 1 ) {
592                 return false;
593             }
594             if ( sdi2_17.getSpeciationOrDuplicationEventsSum() != 0 ) {
595                 return false;
596             }
597             if ( sdi2_17.getSpeciationsSum() != 1 ) {
598                 return false;
599             }
600             if ( !TestGSDI.getEvent( g2_17, "j3", "n1" ).isSpeciation() ) {
601                 return false;
602             }
603             if ( !TestGSDI.getEvent( g2_17, "j3", "p4" ).isDuplication() ) {
604                 return false;
605             }
606             final Phylogeny g2_18 = TestGSDI
607                     .createPhylogeny( "((n11[&&NHX:S=n1],n12[&&NHX:S=n1]),(n13[&&NHX:S=n1],n14[&&NHX:S=n1]))" );
608             final GSDI sdi2_18 = new GSDI( g2_18, s2, false, false, false );
609             if ( sdi2_18.getDuplicationsSum() != 3 ) {
610                 return false;
611             }
612             if ( sdi2_18.getSpeciationOrDuplicationEventsSum() != 0 ) {
613                 return false;
614             }
615             if ( sdi2_18.getSpeciationsSum() != 0 ) {
616                 return false;
617             }
618             if ( !TestGSDI.getEvent( g2_18, "n11", "n12" ).isDuplication() ) {
619                 return false;
620             }
621             if ( !TestGSDI.getEvent( g2_18, "n13", "n14" ).isDuplication() ) {
622                 return false;
623             }
624             if ( !TestGSDI.getEvent( g2_18, "n11", "n13" ).isDuplication() ) {
625                 return false;
626             }
627             final Phylogeny g2_19 = TestGSDI
628                     .createPhylogeny( "((n11[&&NHX:S=n1],n21[&&NHX:S=n2]),(n12[&&NHX:S=n1],n22[&&NHX:S=n2]))" );
629             final GSDI sdi2_19 = new GSDI( g2_19, s2, false, false, false );
630             if ( sdi2_19.getDuplicationsSum() != 1 ) {
631                 return false;
632             }
633             if ( sdi2_19.getSpeciationOrDuplicationEventsSum() != 0 ) {
634                 return false;
635             }
636             if ( sdi2_19.getSpeciationsSum() != 2 ) {
637                 return false;
638             }
639             if ( !TestGSDI.getEvent( g2_19, "n11", "n21" ).isSpeciation() ) {
640                 return false;
641             }
642             if ( !TestGSDI.getEvent( g2_19, "n12", "n22" ).isSpeciation() ) {
643                 return false;
644             }
645             if ( !TestGSDI.getEvent( g2_19, "n11", "n12" ).isDuplication() ) {
646                 return false;
647             }
648             final Phylogeny g2_20 = TestGSDI
649                     .createPhylogeny( "((n11[&&NHX:S=n1],n2[&&NHX:S=n2]),(n12[&&NHX:S=n1],n3[&&NHX:S=n3]))" );
650             final GSDI sdi2_20 = new GSDI( g2_20, s2, false, false, false );
651             if ( sdi2_20.getDuplicationsSum() != 1 ) {
652                 return false;
653             }
654             if ( sdi2_20.getSpeciationOrDuplicationEventsSum() != 0 ) {
655                 return false;
656             }
657             if ( sdi2_20.getSpeciationsSum() != 2 ) {
658                 return false;
659             }
660             if ( !TestGSDI.getEvent( g2_20, "n11", "n2" ).isSpeciation() ) {
661                 return false;
662             }
663             if ( !TestGSDI.getEvent( g2_20, "n12", "n3" ).isSpeciation() ) {
664                 return false;
665             }
666             if ( !TestGSDI.getEvent( g2_20, "n11", "n12" ).isDuplication() ) {
667                 return false;
668             }
669             final Phylogeny g2_21 = TestGSDI
670                     .createPhylogeny( "((n1[&&NHX:S=n1],n2[&&NHX:S=n2]),(n3[&&NHX:S=n3],a1[&&NHX:S=a1]))" );
671             final GSDI sdi2_21 = new GSDI( g2_21, s2, false, false, false );
672             if ( sdi2_21.getDuplicationsSum() != 1 ) {
673                 return false;
674             }
675             if ( sdi2_21.getSpeciationOrDuplicationEventsSum() != 0 ) {
676                 return false;
677             }
678             if ( sdi2_21.getSpeciationsSum() != 2 ) {
679                 return false;
680             }
681             if ( !TestGSDI.getEvent( g2_21, "n1", "n2" ).isSpeciation() ) {
682                 return false;
683             }
684             if ( !TestGSDI.getEvent( g2_21, "n3", "a1" ).isSpeciation() ) {
685                 return false;
686             }
687             if ( !TestGSDI.getEvent( g2_21, "n2", "a1" ).isDuplication() ) {
688                 return false;
689             }
690             final Phylogeny g2_22 = TestGSDI
691                     .createPhylogeny( "((n1[&&NHX:S=n1],n2[&&NHX:S=n2]),(n3[&&NHX:S=n3],n4[&&NHX:S=n4]))" );
692             final GSDI sdi2_22 = new GSDI( g2_22, s2, false, false, false );
693             //Archaeopteryx.createApplication( g2_22 );
694             //Archaeopteryx.createApplication( s2 );
695             if ( sdi2_22.getDuplicationsSum() != 0 ) {
696                 return false;
697             }
698             if ( sdi2_22.getSpeciationOrDuplicationEventsSum() != 1 ) {
699                 return false;
700             }
701             if ( sdi2_22.getSpeciationsSum() != 2 ) {
702                 return false;
703             }
704             if ( !TestGSDI.getEvent( g2_22, "n1", "n2" ).isSpeciation() ) {
705                 return false;
706             }
707             if ( !TestGSDI.getEvent( g2_22, "n3", "n4" ).isSpeciation() ) {
708                 return false;
709             }
710             if ( !TestGSDI.getEvent( g2_22, "n1", "n3" ).isSpeciationOrDuplication() ) {
711                 return false;
712             }
713             final Phylogeny g2_23 = TestGSDI
714                     .createPhylogeny( "((a1[&&NHX:S=a1],b1[&&NHX:S=b1]),(c1[&&NHX:S=c1],d1[&&NHX:S=d1]))" );
715             final GSDI sdi2_23 = new GSDI( g2_23, s2, false, false, false );
716             if ( sdi2_23.getDuplicationsSum() != 0 ) {
717                 return false;
718             }
719             if ( sdi2_23.getSpeciationOrDuplicationEventsSum() != 1 ) {
720                 return false;
721             }
722             if ( sdi2_23.getSpeciationsSum() != 2 ) {
723                 return false;
724             }
725             if ( !TestGSDI.getEvent( g2_23, "a1", "b1" ).isSpeciation() ) {
726                 return false;
727             }
728             if ( !TestGSDI.getEvent( g2_23, "c1", "d1" ).isSpeciation() ) {
729                 return false;
730             }
731             if ( !TestGSDI.getEvent( g2_23, "a1", "c1" ).isSpeciationOrDuplication() ) {
732                 return false;
733             }
734             final Phylogeny g2_24 = TestGSDI
735                     .createPhylogeny( "((a1[&&NHX:S=a1],e1[&&NHX:S=e1]),(i1[&&NHX:S=i1],m1[&&NHX:S=m1]))" );
736             final GSDI sdi2_24 = new GSDI( g2_24, s2, false, false, false );
737             if ( sdi2_24.getDuplicationsSum() != 0 ) {
738                 return false;
739             }
740             if ( sdi2_24.getSpeciationOrDuplicationEventsSum() != 1 ) {
741                 return false;
742             }
743             if ( sdi2_24.getSpeciationsSum() != 2 ) {
744                 return false;
745             }
746             if ( !TestGSDI.getEvent( g2_24, "a1", "e1" ).isSpeciation() ) {
747                 return false;
748             }
749             if ( !TestGSDI.getEvent( g2_24, "i1", "m1" ).isSpeciation() ) {
750                 return false;
751             }
752             if ( !TestGSDI.getEvent( g2_24, "a1", "i1" ).isSpeciationOrDuplication() ) {
753                 return false;
754             }
755             final Phylogeny g2_25 = TestGSDI
756                     .createPhylogeny( "((a1[&&NHX:S=a1],a4[&&NHX:S=a4]),(b1[&&NHX:S=b1],c1[&&NHX:S=c1]))" );
757             final GSDI sdi2_25 = new GSDI( g2_25, s2, false, false, false );
758             if ( sdi2_25.getDuplicationsSum() != 0 ) {
759                 return false;
760             }
761             if ( sdi2_25.getSpeciationOrDuplicationEventsSum() != 1 ) {
762                 return false;
763             }
764             if ( sdi2_25.getSpeciationsSum() != 2 ) {
765                 return false;
766             }
767             if ( !TestGSDI.getEvent( g2_25, "a1", "a4" ).isSpeciation() ) {
768                 return false;
769             }
770             if ( !TestGSDI.getEvent( g2_25, "b1", "c1" ).isSpeciation() ) {
771                 return false;
772             }
773             if ( !TestGSDI.getEvent( g2_25, "a1", "b1" ).isSpeciationOrDuplication() ) {
774                 return false;
775             }
776             final Phylogeny g2_26 = TestGSDI
777                     .createPhylogeny( "(((a1[&&NHX:S=a1],a4[&&NHX:S=a4]),b1[&&NHX:S=b1]),e1[&&NHX:S=e1])" );
778             final GSDI sdi2_26 = new GSDI( g2_26, s2, false, false, false );
779             if ( sdi2_26.getDuplicationsSum() != 0 ) {
780                 return false;
781             }
782             if ( sdi2_26.getSpeciationOrDuplicationEventsSum() != 0 ) {
783                 return false;
784             }
785             if ( sdi2_26.getSpeciationsSum() != 3 ) {
786                 return false;
787             }
788             if ( !TestGSDI.getEvent( g2_26, "a1", "a4" ).isSpeciation() ) {
789                 return false;
790             }
791             if ( !TestGSDI.getEvent( g2_26, "a1", "b1" ).isSpeciation() ) {
792                 return false;
793             }
794             if ( !TestGSDI.getEvent( g2_26, "a1", "e1" ).isSpeciation() ) {
795                 return false;
796             }
797             final Phylogeny g2_27 = TestGSDI
798                     .createPhylogeny( "(((a1[&&NHX:S=a1],a4[&&NHX:S=a4]),b1[&&NHX:S=b1]),c1[&&NHX:S=c1])" );
799             final GSDI sdi2_27 = new GSDI( g2_27, s2, false, false, false );
800             if ( sdi2_27.getDuplicationsSum() != 0 ) {
801                 return false;
802             }
803             if ( sdi2_27.getSpeciationOrDuplicationEventsSum() != 1 ) {
804                 return false;
805             }
806             if ( sdi2_27.getSpeciationsSum() != 2 ) {
807                 return false;
808             }
809             if ( !TestGSDI.getEvent( g2_27, "a1", "a4" ).isSpeciation() ) {
810                 return false;
811             }
812             if ( !TestGSDI.getEvent( g2_27, "a1", "b1" ).isSpeciation() ) {
813                 return false;
814             }
815             if ( !TestGSDI.getEvent( g2_27, "a1", "c1" ).isSpeciationOrDuplication() ) {
816                 return false;
817             }
818             final Phylogeny g2_28 = TestGSDI
819                     .createPhylogeny( "(((a1[&&NHX:S=a1],b1[&&NHX:S=b1]),c1[&&NHX:S=c1]),e1[&&NHX:S=e1])" );
820             final GSDI sdi2_28 = new GSDI( g2_28, s2, false, false, false );
821             if ( sdi2_28.getDuplicationsSum() != 0 ) {
822                 return false;
823             }
824             if ( sdi2_28.getSpeciationOrDuplicationEventsSum() != 1 ) {
825                 return false;
826             }
827             if ( sdi2_28.getSpeciationsSum() != 2 ) {
828                 return false;
829             }
830             if ( !TestGSDI.getEvent( g2_28, "a1", "b1" ).isSpeciation() ) {
831                 return false;
832             }
833             if ( !TestGSDI.getEvent( g2_28, "a1", "c1" ).isSpeciationOrDuplication() ) {
834                 return false;
835             }
836             if ( !TestGSDI.getEvent( g2_28, "a1", "e1" ).isSpeciation() ) {
837                 return false;
838             }
839             final Phylogeny g2_29 = TestGSDI
840                     .createPhylogeny( "(((a1[&&NHX:S=a1],b1[&&NHX:S=b1]),c1[&&NHX:S=c1]),d1[&&NHX:S=d1])" );
841             final GSDI sdi2_29 = new GSDI( g2_29, s2, false, false, false );
842             if ( sdi2_29.getDuplicationsSum() != 0 ) {
843                 return false;
844             }
845             if ( sdi2_29.getSpeciationOrDuplicationEventsSum() != 2 ) {
846                 return false;
847             }
848             if ( sdi2_29.getSpeciationsSum() != 1 ) {
849                 return false;
850             }
851             if ( !TestGSDI.getEvent( g2_29, "a1", "b1" ).isSpeciation() ) {
852                 return false;
853             }
854             if ( !TestGSDI.getEvent( g2_29, "a1", "c1" ).isSpeciationOrDuplication() ) {
855                 return false;
856             }
857             if ( !TestGSDI.getEvent( g2_29, "a1", "d1" ).isSpeciationOrDuplication() ) {
858                 return false;
859             }
860             final Phylogeny g2_30 = TestGSDI
861                     .createPhylogeny( "(((a1[&&NHX:S=a1],b1[&&NHX:S=b1]),c1[&&NHX:S=c1]),a2[&&NHX:S=a2])" );
862             final GSDI sdi2_30 = new GSDI( g2_30, s2, false, false, false );
863             if ( sdi2_30.getDuplicationsSum() != 1 ) {
864                 return false;
865             }
866             if ( sdi2_30.getSpeciationOrDuplicationEventsSum() != 1 ) {
867                 return false;
868             }
869             if ( sdi2_30.getSpeciationsSum() != 1 ) {
870                 return false;
871             }
872             if ( !TestGSDI.getEvent( g2_30, "a1", "b1" ).isSpeciation() ) {
873                 return false;
874             }
875             if ( !TestGSDI.getEvent( g2_30, "a1", "c1" ).isSpeciationOrDuplication() ) {
876                 return false;
877             }
878             if ( !TestGSDI.getEvent( g2_30, "a1", "a2" ).isDuplication() ) {
879                 return false;
880             }
881             final Phylogeny g2_31 = TestGSDI
882                     .createPhylogeny( "(((a1[&&NHX:S=a1],b1[&&NHX:S=b1]),c1[&&NHX:S=c1]),c2[&&NHX:S=c2])" );
883             final GSDI sdi2_31 = new GSDI( g2_31, s2, false, false, false );
884             if ( sdi2_31.getDuplicationsSum() != 1 ) {
885                 return false;
886             }
887             if ( sdi2_31.getSpeciationOrDuplicationEventsSum() != 1 ) {
888                 return false;
889             }
890             if ( sdi2_31.getSpeciationsSum() != 1 ) {
891                 return false;
892             }
893             if ( !TestGSDI.getEvent( g2_31, "a1", "b1" ).isSpeciation() ) {
894                 return false;
895             }
896             if ( !TestGSDI.getEvent( g2_31, "a1", "c1" ).isSpeciationOrDuplication() ) {
897                 return false;
898             }
899             if ( !TestGSDI.getEvent( g2_31, "a1", "c2" ).isDuplication() ) {
900                 return false;
901             }
902             final Phylogeny g2_32 = TestGSDI
903                     .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])" );
904             final GSDI sdi2_32 = new GSDI( g2_32, s2, false, false, false );
905             if ( sdi2_32.getDuplicationsSum() != 0 ) {
906                 return false;
907             }
908             if ( sdi2_32.getSpeciationOrDuplicationEventsSum() != 7 ) {
909                 return false;
910             }
911             if ( sdi2_32.getSpeciationsSum() != 3 ) {
912                 return false;
913             }
914             if ( !TestGSDI.getEvent( g2_32, "a1", "a2" ).isSpeciation() ) {
915                 return false;
916             }
917             if ( !TestGSDI.getEvent( g2_32, "a1", "b1" ).isSpeciation() ) {
918                 return false;
919             }
920             if ( !TestGSDI.getEvent( g2_32, "a1", "c1" ).isSpeciationOrDuplication() ) {
921                 return false;
922             }
923             if ( !TestGSDI.getEvent( g2_32, "a1", "d1" ).isSpeciationOrDuplication() ) {
924                 return false;
925             }
926             if ( !TestGSDI.getEvent( g2_32, "a1", "x" ).isSpeciation() ) {
927                 return false;
928             }
929             if ( !TestGSDI.getEvent( g2_32, "a1", "p1" ).isSpeciationOrDuplication() ) {
930                 return false;
931             }
932             if ( !TestGSDI.getEvent( g2_32, "a1", "i1" ).isSpeciationOrDuplication() ) {
933                 return false;
934             }
935             if ( !TestGSDI.getEvent( g2_32, "a1", "e1" ).isSpeciationOrDuplication() ) {
936                 return false;
937             }
938             if ( !TestGSDI.getEvent( g2_32, "a1", "y" ).isSpeciationOrDuplication() ) {
939                 return false;
940             }
941             if ( !TestGSDI.getEvent( g2_32, "a1", "z" ).isSpeciationOrDuplication() ) {
942                 return false;
943             }
944             final Phylogeny g2_33 = TestGSDI
945                     .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])" );
946             final GSDI sdi2_33 = new GSDI( g2_33, s2, false, false, false );
947             if ( sdi2_33.getDuplicationsSum() != 1 ) {
948                 return false;
949             }
950             if ( sdi2_33.getSpeciationOrDuplicationEventsSum() != 7 ) {
951                 return false;
952             }
953             if ( sdi2_33.getSpeciationsSum() != 3 ) {
954                 return false;
955             }
956             if ( !TestGSDI.getEvent( g2_33, "a1", "a2" ).isSpeciation() ) {
957                 return false;
958             }
959             if ( !TestGSDI.getEvent( g2_33, "a1", "b1" ).isSpeciation() ) {
960                 return false;
961             }
962             if ( !TestGSDI.getEvent( g2_33, "a1", "c1" ).isSpeciationOrDuplication() ) {
963                 return false;
964             }
965             if ( !TestGSDI.getEvent( g2_33, "a1", "d1" ).isSpeciationOrDuplication() ) {
966                 return false;
967             }
968             if ( !TestGSDI.getEvent( g2_33, "a1", "x" ).isSpeciation() ) {
969                 return false;
970             }
971             if ( !TestGSDI.getEvent( g2_33, "a1", "p1" ).isSpeciationOrDuplication() ) {
972                 return false;
973             }
974             if ( !TestGSDI.getEvent( g2_33, "a1", "i1" ).isSpeciationOrDuplication() ) {
975                 return false;
976             }
977             if ( !TestGSDI.getEvent( g2_33, "a1", "k2" ).isDuplication() ) {
978                 return false;
979             }
980             if ( !TestGSDI.getEvent( g2_33, "a1", "e1" ).isSpeciationOrDuplication() ) {
981                 return false;
982             }
983             if ( !TestGSDI.getEvent( g2_33, "a1", "y" ).isSpeciationOrDuplication() ) {
984                 return false;
985             }
986             if ( !TestGSDI.getEvent( g2_33, "a1", "z" ).isSpeciationOrDuplication() ) {
987                 return false;
988             }
989             final Phylogeny g2_33_d = TestGSDI
990                     .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=?])" );
991             final GSDI sdi2_33_d = new GSDI( g2_33_d, s2, false, false, false );
992             if ( sdi2_33_d.getDuplicationsSum() != 3 ) {
993                 return false;
994             }
995             if ( sdi2_33_d.getSpeciationOrDuplicationEventsSum() != 14 ) {
996                 return false;
997             }
998             if ( sdi2_33_d.getSpeciationsSum() != 6 ) {
999                 return false;
1000             }
1001             final Phylogeny g2_34 = 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])" );
1003             final GSDI sdi2_34 = new GSDI( g2_34, s2, false, false, false );
1004             if ( sdi2_34.getDuplicationsSum() != 1 ) {
1005                 return false;
1006             }
1007             if ( sdi2_34.getSpeciationOrDuplicationEventsSum() != 1 ) {
1008                 return false;
1009             }
1010             if ( sdi2_34.getSpeciationsSum() != 2 ) {
1011                 return false;
1012             }
1013             if ( !TestGSDI.getEvent( g2_34, "n1_0", "n2_0" ).isSpeciation() ) {
1014                 return false;
1015             }
1016             if ( !TestGSDI.getEvent( g2_34, "n1_1", "n3_0" ).isSpeciation() ) {
1017                 return false;
1018             }
1019             if ( !TestGSDI.getEvent( g2_34, "n1_0", "n1_1" ).isDuplication() ) {
1020                 return false;
1021             }
1022             if ( !TestGSDI.getEvent( g2_34, "n1_0", "n4_0" ).isSpeciationOrDuplication() ) {
1023                 return false;
1024             }
1025             final Phylogeny g2_35 = TestGSDI
1026                     .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])" );
1027             final GSDI sdi2_35 = new GSDI( g2_35, s2, false, false, false );
1028             if ( sdi2_35.getDuplicationsSum() != 1 ) {
1029                 return false;
1030             }
1031             if ( sdi2_35.getSpeciationOrDuplicationEventsSum() != 1 ) {
1032                 return false;
1033             }
1034             if ( sdi2_35.getSpeciationsSum() != 3 ) {
1035                 return false;
1036             }
1037             if ( !TestGSDI.getEvent( g2_35, "n1_0", "n2_0" ).isSpeciation() ) {
1038                 return false;
1039             }
1040             if ( !TestGSDI.getEvent( g2_35, "n1_1", "n3_0" ).isSpeciation() ) {
1041                 return false;
1042             }
1043             if ( !TestGSDI.getEvent( g2_35, "n1_0", "n1_1" ).isDuplication() ) {
1044                 return false;
1045             }
1046             if ( !TestGSDI.getEvent( g2_35, "n1_0", "n4_0" ).isSpeciationOrDuplication() ) {
1047                 return false;
1048             }
1049             if ( !TestGSDI.getEvent( g2_35, "n1_0", "a1_0" ).isSpeciation() ) {
1050                 return false;
1051             }
1052             final Phylogeny g2_36 = TestGSDI
1053                     .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])" );
1054             final GSDI sdi2_36 = new GSDI( g2_36, s2, false, false, false );
1055             if ( sdi2_36.getDuplicationsSum() != 1 ) {
1056                 return false;
1057             }
1058             if ( sdi2_36.getSpeciationOrDuplicationEventsSum() != 1 ) {
1059                 return false;
1060             }
1061             if ( sdi2_36.getSpeciationsSum() != 2 ) {
1062                 return false;
1063             }
1064             if ( !TestGSDI.getEvent( g2_36, "a1_0", "b1_0" ).isSpeciation() ) {
1065                 return false;
1066             }
1067             if ( !TestGSDI.getEvent( g2_36, "a1_1", "c1_0" ).isSpeciation() ) {
1068                 return false;
1069             }
1070             if ( !TestGSDI.getEvent( g2_36, "a1_0", "c1_0" ).isDuplication() ) {
1071                 return false;
1072             }
1073             if ( !TestGSDI.getEvent( g2_36, "a1_0", "d1_0" ).isSpeciationOrDuplication() ) {
1074                 return false;
1075             }
1076             final Phylogeny g2_37 = TestGSDI
1077                     .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])" );
1078             final GSDI sdi2_37 = new GSDI( g2_37, s2, false, false, false );
1079             if ( sdi2_37.getDuplicationsSum() != 1 ) {
1080                 return false;
1081             }
1082             if ( sdi2_37.getSpeciationOrDuplicationEventsSum() != 1 ) {
1083                 return false;
1084             }
1085             if ( sdi2_37.getSpeciationsSum() != 2 ) {
1086                 return false;
1087             }
1088             if ( !TestGSDI.getEvent( g2_37, "a1_0", "b1_0" ).isSpeciation() ) {
1089                 return false;
1090             }
1091             if ( !TestGSDI.getEvent( g2_37, "a2_0", "c1_0" ).isSpeciation() ) {
1092                 return false;
1093             }
1094             if ( !TestGSDI.getEvent( g2_37, "a1_0", "c1_0" ).isDuplication() ) {
1095                 return false;
1096             }
1097             if ( !TestGSDI.getEvent( g2_37, "a1_0", "d1_0" ).isSpeciationOrDuplication() ) {
1098                 return false;
1099             }
1100             final Phylogeny g2_38 = TestGSDI
1101                     .createPhylogeny( "(((([&&NHX:S=n1],[&&NHX:S=n1]),([&&NHX:S=n1],[&&NHX:S=n1])),[&&NHX:S=n1]),[&&NHX:S=n1])" );
1102             final GSDI sdi2_38 = new GSDI( g2_38, s2, false, false, false );
1103             if ( sdi2_38.getDuplicationsSum() != 5 ) {
1104                 return false;
1105             }
1106             if ( sdi2_38.getSpeciationOrDuplicationEventsSum() != 0 ) {
1107                 return false;
1108             }
1109             if ( sdi2_38.getSpeciationsSum() != 0 ) {
1110                 return false;
1111             }
1112             final Phylogeny g2_100 = TestGSDI
1113                     .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])))" );
1114             final GSDI sdi2_100 = new GSDI( g2_100, s2, false, false, false );
1115             if ( sdi2_100.getDuplicationsSum() != 4 ) {
1116                 return false;
1117             }
1118             if ( sdi2_100.getSpeciationOrDuplicationEventsSum() != 0 ) {
1119                 return false;
1120             }
1121             if ( sdi2_100.getSpeciationsSum() != 4 ) {
1122                 return false;
1123             }
1124             if ( !TestGSDI.getEvent( g2_100, "e1", "f2" ).isSpeciation() ) {
1125                 return false;
1126             }
1127             if ( !TestGSDI.getEvent( g2_100, "d3", "g4" ).isSpeciation() ) {
1128                 return false;
1129             }
1130             if ( !TestGSDI.getEvent( g2_100, "e1", "d3" ).isDuplication() ) {
1131                 return false;
1132             }
1133             if ( !TestGSDI.getEvent( g2_100, "a1", "h2" ).isSpeciation() ) {
1134                 return false;
1135             }
1136             if ( !TestGSDI.getEvent( g2_100, "a1", "c3" ).isDuplication() ) {
1137                 return false;
1138             }
1139             if ( !TestGSDI.getEvent( g2_100, "i4", "b1" ).isSpeciation() ) {
1140                 return false;
1141             }
1142             if ( !TestGSDI.getEvent( g2_100, "a1", "i4" ).isDuplication() ) {
1143                 return false;
1144             }
1145             if ( !TestGSDI.getEvent( g2_100, "e1", "a1" ).isDuplication() ) {
1146                 return false;
1147             }
1148             final Phylogeny g2_101 = TestGSDI
1149                     .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])))" );
1150             final GSDI sdi2_101 = new GSDI( g2_101, s2, false, false, false );
1151             if ( sdi2_101.getDuplicationsSum() != 2 ) {
1152                 return false;
1153             }
1154             if ( sdi2_101.getSpeciationOrDuplicationEventsSum() != 1 ) {
1155                 return false;
1156             }
1157             if ( sdi2_101.getSpeciationsSum() != 5 ) {
1158                 return false;
1159             }
1160             if ( !TestGSDI.getEvent( g2_101, "e1", "f2" ).isSpeciation() ) {
1161                 return false;
1162             }
1163             if ( !TestGSDI.getEvent( g2_101, "d3", "g4" ).isSpeciation() ) {
1164                 return false;
1165             }
1166             if ( !TestGSDI.getEvent( g2_101, "e1", "d3" ).isDuplication() ) {
1167                 return false;
1168             }
1169             if ( !TestGSDI.getEvent( g2_101, "a1", "b2" ).isSpeciation() ) {
1170                 return false;
1171             }
1172             if ( !TestGSDI.getEvent( g2_101, "a1", "c3" ).isSpeciationOrDuplication() ) {
1173                 return false;
1174             }
1175             if ( !TestGSDI.getEvent( g2_101, "i4", "j1" ).isSpeciation() ) {
1176                 return false;
1177             }
1178             if ( !TestGSDI.getEvent( g2_101, "a1", "i4" ).isSpeciation() ) {
1179                 return false;
1180             }
1181             if ( !TestGSDI.getEvent( g2_101, "e1", "a1" ).isDuplication() ) {
1182                 return false;
1183             }
1184             final Phylogeny s_7_4 = DevelopmentTools.createBalancedPhylogeny( 7, 4 );
1185             DevelopmentTools.numberSpeciesInOrder( s_7_4 );
1186             final Phylogeny g_7_4_1 = TestGSDI
1187                     .createPhylogeny( "(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((("
1188                             + "1[&&NHX:S=1],2[&&NHX:S=2]),3[&&NHX:S=3]),4[&&NHX:S=4]),5[&&NHX:S=5]),"
1189                             + "6[&&NHX:S=6]),7[&&NHX:S=7]),8[&&NHX:S=8]),9[&&NHX:S=9]),10[&&NHX:S=10]),11[&&NHX:S=11]),"
1190                             + "12[&&NHX:S=12]),13[&&NHX:S=13]),14[&&NHX:S=14]),15[&&NHX:S=15]),16[&&NHX:S=16]),17[&&NHX:S=17]),"
1191                             + "18[&&NHX:S=18]),19[&&NHX:S=19]),20[&&NHX:S=20]),21[&&NHX:S=21]),22[&&NHX:S=22]),23[&&NHX:S=23]),"
1192                             + "24[&&NHX:S=24]),25[&&NHX:S=25]),26[&&NHX:S=26]),27[&&NHX:S=27]),28[&&NHX:S=28]),29[&&NHX:S=29]),"
1193                             + "30[&&NHX:S=30]),31[&&NHX:S=31]),32[&&NHX:S=32]),33[&&NHX:S=33]),34[&&NHX:S=34]),35[&&NHX:S=35]),"
1194                             + "36[&&NHX:S=36]),37[&&NHX:S=37]),38[&&NHX:S=38]),39[&&NHX:S=39]),40[&&NHX:S=40]),41[&&NHX:S=41]),"
1195                             + "42[&&NHX:S=42]),43[&&NHX:S=43]),44[&&NHX:S=44]),45[&&NHX:S=45]),46[&&NHX:S=46]),47[&&NHX:S=47]),"
1196                             + "48[&&NHX:S=48]),49[&&NHX:S=49]),50[&&NHX:S=50]),51[&&NHX:S=51]),52[&&NHX:S=52]),53[&&NHX:S=53]),"
1197                             + "54[&&NHX:S=54]),55[&&NHX:S=55]),56[&&NHX:S=56]),57[&&NHX:S=57]),58[&&NHX:S=58]),59[&&NHX:S=59]),"
1198                             + "60[&&NHX:S=60]),61[&&NHX:S=61]),62[&&NHX:S=62]),63[&&NHX:S=63]),64[&&NHX:S=64]),65[&&NHX:S=65])" );
1199             final GSDI sdi7_4_1 = new GSDI( g_7_4_1, s_7_4, false, false, false );
1200             if ( sdi7_4_1.getDuplicationsSum() != 54 ) {
1201                 return false;
1202             }
1203             if ( sdi7_4_1.getSpeciationOrDuplicationEventsSum() != 6 ) {
1204                 return false;
1205             }
1206             if ( sdi7_4_1.getSpeciationsSum() != 4 ) {
1207                 return false;
1208             }
1209             if ( !TestGSDI.getEvent( g_7_4_1, "1", "2" ).isSpeciation() ) {
1210                 return false;
1211             }
1212             if ( !TestGSDI.getEvent( g_7_4_1, "1", "3" ).isSpeciationOrDuplication() ) {
1213                 return false;
1214             }
1215             if ( !TestGSDI.getEvent( g_7_4_1, "1", "4" ).isSpeciationOrDuplication() ) {
1216                 return false;
1217             }
1218             if ( !TestGSDI.getEvent( g_7_4_1, "1", "5" ).isSpeciation() ) {
1219                 return false;
1220             }
1221             if ( !TestGSDI.getEvent( g_7_4_1, "1", "6" ).isDuplication() ) {
1222                 return false;
1223             }
1224             if ( !TestGSDI.getEvent( g_7_4_1, "1", "9" ).isSpeciationOrDuplication() ) {
1225                 return false;
1226             }
1227             if ( !TestGSDI.getEvent( g_7_4_1, "1", "13" ).isSpeciationOrDuplication() ) {
1228                 return false;
1229             }
1230             if ( !TestGSDI.getEvent( g_7_4_1, "1", "17" ).isSpeciation() ) {
1231                 return false;
1232             }
1233             if ( !TestGSDI.getEvent( g_7_4_1, "1", "33" ).isSpeciationOrDuplication() ) {
1234                 return false;
1235             }
1236             if ( !TestGSDI.getEvent( g_7_4_1, "1", "49" ).isSpeciationOrDuplication() ) {
1237                 return false;
1238             }
1239             if ( !TestGSDI.getEvent( g_7_4_1, "1", "65" ).isSpeciation() ) {
1240                 return false;
1241             }
1242             final Phylogeny g_7_4_2 = TestGSDI
1243                     .createPhylogeny( "((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((("
1244                             + "1[&&NHX:S=1],2[&&NHX:S=2]),3[&&NHX:S=3]),4[&&NHX:S=4]),5[&&NHX:S=5]),"
1245                             + "6[&&NHX:S=6]),7[&&NHX:S=7]),8[&&NHX:S=8]),9[&&NHX:S=9]),10[&&NHX:S=10]),11[&&NHX:S=11]),"
1246                             + "12[&&NHX:S=12]),13[&&NHX:S=13]),14[&&NHX:S=14]),15[&&NHX:S=15]),16[&&NHX:S=16]),17[&&NHX:S=17]),"
1247                             + "18[&&NHX:S=18]),19[&&NHX:S=19]),20[&&NHX:S=20]),21[&&NHX:S=21]),22[&&NHX:S=22]),23[&&NHX:S=23]),"
1248                             + "24[&&NHX:S=24]),25[&&NHX:S=25]),26[&&NHX:S=26]),27[&&NHX:S=27]),28[&&NHX:S=28]),29[&&NHX:S=29]),"
1249                             + "30[&&NHX:S=30]),31[&&NHX:S=31]),32[&&NHX:S=32]),33[&&NHX:S=33]),34[&&NHX:S=34]),35[&&NHX:S=35]),"
1250                             + "36[&&NHX:S=36]),37[&&NHX:S=37]),38[&&NHX:S=38]),39[&&NHX:S=39]),40[&&NHX:S=40]),41[&&NHX:S=41]),"
1251                             + "42[&&NHX:S=42]),43[&&NHX:S=43]),44[&&NHX:S=44]),45[&&NHX:S=45]),46[&&NHX:S=46]),47[&&NHX:S=47]),"
1252                             + "48[&&NHX:S=48]),49[&&NHX:S=49]),50[&&NHX:S=50]),51[&&NHX:S=51]),52[&&NHX:S=52]),53[&&NHX:S=53]),"
1253                             + "54[&&NHX:S=54]),55[&&NHX:S=55]),56[&&NHX:S=56]),57[&&NHX:S=57]),58[&&NHX:S=58]),59[&&NHX:S=59]),"
1254                             + "60[&&NHX:S=60]),61[&&NHX:S=61]),62[&&NHX:S=62]),63[&&NHX:S=63]),64[&&NHX:S=64]),65[&&NHX:S=65]),"
1255                             + "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])" );
1256             final GSDI sdi7_4_2 = new GSDI( g_7_4_2, s_7_4, false, false, false );
1257             if ( sdi7_4_2.getDuplicationsSum() != 58 ) {
1258                 return false;
1259             }
1260             if ( sdi7_4_2.getSpeciationOrDuplicationEventsSum() != 8 ) {
1261                 return false;
1262             }
1263             if ( sdi7_4_2.getSpeciationsSum() != 5 ) {
1264                 return false;
1265             }
1266             final String g2_0_ = "(([&&NHX:S=a1],[&&NHX:S=a2]),([&&NHX:S=o2],[&&NHX:S=o4]))";
1267             final Phylogeny g2_0p = TestGSDI.createPhylogeny( g2_0_ );
1268             g2_0.setRooted( true );
1269             final GSDI sdi2_0p = new GSDI( g2_0p, s2, false, false, false );
1270             if ( sdi2_0p.getDuplicationsSum() != 0 ) {
1271                 return false;
1272             }
1273             //--
1274             final Phylogeny tol_143_ = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA + "tol_143.xml" )[ 0 ];
1275             final Phylogeny gene_tree_tax_code_4_ = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1276                     + "gene_tree_tax_code_4.xml" )[ 0 ];
1277             final GSDI gsdi_143_4_1 = new GSDI( gene_tree_tax_code_4_.copy(), tol_143_.copy(), false, true, true );
1278             if ( gsdi_143_4_1.getDuplicationsSum() != 21 ) {
1279                 return false;
1280             }
1281             if ( gsdi_143_4_1.getSpeciationsSum() != 28 ) {
1282                 return false;
1283             }
1284             if ( gsdi_143_4_1.getSpeciationOrDuplicationEventsSum() != 6 ) {
1285                 return false;
1286             }
1287             //--
1288             final Phylogeny gsdi_test_gene_tree_sn_wnt = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1289                     + "gsdi_test_gene_tree_sn_wnt.xml" )[ 0 ];
1290             gsdi_test_gene_tree_sn_wnt.setRooted( true );
1291             final GSDI a = new GSDI( gsdi_test_gene_tree_sn_wnt.copy(), tol_143_.copy(), false, true, true );
1292             if ( a.getDuplicationsSum() != 33 ) {
1293                 return false;
1294             }
1295             if ( a.getSpeciationsSum() != 31 ) {
1296                 return false;
1297             }
1298             if ( a.getSpeciationOrDuplicationEventsSum() != 0 ) {
1299                 return false;
1300             }
1301             if ( a.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) {
1302                 return false;
1303             }
1304             if ( a.getMappedExternalSpeciesTreeNodes().size() != 26 ) {
1305                 return false;
1306             }
1307             if ( a.getReMappedScientificNamesFromGeneTree().size() != 0 ) {
1308                 return false;
1309             }
1310             //--
1311             final Phylogeny gsdi_test_species_tree_sn_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1312                     + "gsdi_test_species_tree_sn.xml" )[ 0 ];
1313             final GSDI b = new GSDI( gsdi_test_gene_tree_sn_wnt.copy(),
1314                                      gsdi_test_species_tree_sn_xml.copy(),
1315                                      false,
1316                                      true,
1317                                      true );
1318             if ( b.getDuplicationsSum() != 8 ) {
1319                 return false;
1320             }
1321             if ( b.getSpeciationsSum() != 2 ) {
1322                 return false;
1323             }
1324             if ( b.getSpeciationOrDuplicationEventsSum() != 0 ) {
1325                 return false;
1326             }
1327             if ( b.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) {
1328                 return false;
1329             }
1330             if ( b.getMappedExternalSpeciesTreeNodes().size() != 2 ) {
1331                 return false;
1332             }
1333             if ( b.getReMappedScientificNamesFromGeneTree().size() != 0 ) {
1334                 return false;
1335             }
1336             if ( b.getStrippedExternalGeneTreeNodes().size() != 87 ) {
1337                 return false;
1338             }
1339             if ( b.getStrippedSpeciesTreeNodes().size() != 17 ) {
1340                 return false;
1341             }
1342             //--
1343             final Phylogeny gsdi_test_species_tree_sn_nh = TestGSDI
1344                     .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';" );
1345             PhylogenyMethods.transferNodeNameToField( gsdi_test_species_tree_sn_nh,
1346                                                       PhylogenyMethods.PhylogenyNodeField.TAXONOMY_SCIENTIFIC_NAME,
1347                                                       true );
1348             final GSDI c = new GSDI( gsdi_test_gene_tree_sn_wnt.copy(),
1349                                      gsdi_test_species_tree_sn_nh.copy(),
1350                                      false,
1351                                      true,
1352                                      true );
1353             if ( c.getDuplicationsSum() != 8 ) {
1354                 return false;
1355             }
1356             if ( c.getSpeciationsSum() != 2 ) {
1357                 return false;
1358             }
1359             if ( c.getSpeciationOrDuplicationEventsSum() != 0 ) {
1360                 return false;
1361             }
1362             if ( c.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) {
1363                 return false;
1364             }
1365             if ( c.getMappedExternalSpeciesTreeNodes().size() != 2 ) {
1366                 return false;
1367             }
1368             if ( c.getReMappedScientificNamesFromGeneTree().size() != 0 ) {
1369                 return false;
1370             }
1371             if ( c.getStrippedExternalGeneTreeNodes().size() != 87 ) {
1372                 return false;
1373             }
1374             if ( c.getStrippedSpeciesTreeNodes().size() != 15 ) {
1375                 return false;
1376             }
1377             //--
1378             final Phylogeny gsdi_test_gene_tree_codes_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1379                     + "gsdi_test_gene_tree_codes.xml" )[ 0 ];
1380             final Phylogeny gsdi_test_species_tree_codes_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1381                     + "gsdi_test_species_tree_codes.xml" )[ 0 ];
1382             final GSDI d = new GSDI( gsdi_test_gene_tree_codes_xml.copy(),
1383                                      gsdi_test_species_tree_codes_xml.copy(),
1384                                      false,
1385                                      true,
1386                                      true );
1387             if ( d.getDuplicationsSum() != 21 ) {
1388                 return false;
1389             }
1390             if ( d.getSpeciationsSum() != 28 ) {
1391                 return false;
1392             }
1393             if ( d.getSpeciationOrDuplicationEventsSum() != 6 ) {
1394                 return false;
1395             }
1396             if ( d.getTaxCompBase() != TaxonomyComparisonBase.CODE ) {
1397                 return false;
1398             }
1399             if ( d.getMappedExternalSpeciesTreeNodes().size() != 17 ) {
1400                 return false;
1401             }
1402             if ( d.getReMappedScientificNamesFromGeneTree().size() != 0 ) {
1403                 return false;
1404             }
1405             if ( d.getStrippedExternalGeneTreeNodes().size() != 12 ) {
1406                 return false;
1407             }
1408             if ( d.getStrippedSpeciesTreeNodes().size() != 3 ) {
1409                 return false;
1410             }
1411             //--
1412             final Phylogeny gsdi_test_gene_tree_sn_xml = ParserUtils.readPhylogenies( PATH_TO_TEST_DATA
1413                     + "gsdi_test_gene_tree_sn.xml" )[ 0 ];
1414             final GSDI e = new GSDI( gsdi_test_gene_tree_sn_xml.copy(),
1415                                      gsdi_test_species_tree_sn_xml.copy(),
1416                                      false,
1417                                      true,
1418                                      true );
1419             if ( e.getDuplicationsSum() != 7 ) {
1420                 return false;
1421             }
1422             if ( e.getSpeciationsSum() != 9 ) {
1423                 return false;
1424             }
1425             if ( e.getSpeciationOrDuplicationEventsSum() != 1 ) {
1426                 return false;
1427             }
1428             if ( e.getTaxCompBase() != TaxonomyComparisonBase.SCIENTIFIC_NAME ) {
1429                 return false;
1430             }
1431             if ( e.getMappedExternalSpeciesTreeNodes().size() != 12 ) {
1432                 return false;
1433             }
1434             if ( e.getReMappedScientificNamesFromGeneTree().size() != 8 ) {
1435                 return false;
1436             }
1437             if ( e.getStrippedExternalGeneTreeNodes().size() != 3 ) {
1438                 return false;
1439             }
1440             if ( e.getStrippedSpeciesTreeNodes().size() != 7 ) {
1441                 return false;
1442             }
1443         }
1444         catch ( final Exception e ) {
1445             e.printStackTrace( System.out );
1446             return false;
1447         }
1448         return true;
1449     }
1450
1451     private static boolean testGSDIR_general() {
1452         try {
1453             final String s1str = "(((([&&NHX:S=HUMAN],([&&NHX:S=MOUSE],[&&NHX:S=RAT])),([&&NHX:S=CAEEL],[&&NHX:S=CAEBR])),[&&NHX:S=YEAST]),[&&NHX:S=ARATH])";
1454             final Phylogeny s1 = ParserBasedPhylogenyFactory.getInstance().create( s1str, new NHXParser() )[ 0 ];
1455             s1.setRooted( true );
1456             final Phylogeny g1 = TestGSDI
1457                     .createPhylogeny( "(HUMAN[&&NHX:S=HUMAN],(RAT[&&NHX:S=RAT],(CAEEL[&&NHX:T=:S=CAEEL],YEAST[&&NHX:S=YEAST])))" );
1458             final GSDIR sdi1 = new GSDIR( g1.copy(), s1.copy(), false, false );
1459             if ( sdi1.getMinDuplicationsSum() != 0 ) {
1460                 return false;
1461             }
1462             final Phylogeny g2 = TestGSDI
1463                     .createPhylogeny( "(((HUMAN[&&NHX:S=HUMAN],RAT[&&NHX:S=RAT]),CAEEL[&&NHX:T=:S=CAEEL]),YEAST[&&NHX:S=YEAST])" );
1464             final GSDIR sdi2 = new GSDIR( g2.copy(), s1.copy(), false, false );
1465             if ( sdi2.getMinDuplicationsSum() != 0 ) {
1466                 return false;
1467             }
1468             final Phylogeny g3 = TestGSDI
1469                     .createPhylogeny( "(RAT[&&NHX:S=RAT],HUMAN[&&NHX:S=HUMAN],(YEAST[&&NHX:S=YEAST],CAEEL[&&NHX:T=:S=CAEEL]))" );
1470             final GSDIR sdi3 = new GSDIR( g3.copy(), s1.copy(), false, false );
1471             if ( sdi3.getMinDuplicationsSum() != 0 ) {
1472                 return false;
1473             }
1474             final Phylogeny g4 = TestGSDI
1475                     .createPhylogeny( "(((((MOUSE[&&NHX:S=MOUSE],[&&NHX:S=RAT]),[&&NHX:S=HUMAN]),([&&NHX:S=ARATH],[&&NHX:S=YEAST])),[&&NHX:S=CAEEL]),[&&NHX:S=CAEBR])" );
1476             final GSDIR sdi4 = new GSDIR( g4.copy(), s1.copy(), false, false );
1477             if ( sdi4.getMinDuplicationsSum() != 0 ) {
1478                 return false;
1479             }
1480         }
1481         catch ( final Exception e ) {
1482             e.printStackTrace( System.out );
1483             return false;
1484         }
1485         return true;
1486     }
1487 }