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