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