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