in progress...
[jalview.git] / forester / java / src / org / forester / clade_analysis / CladeAnalysisDemo.java
1
2 package org.forester.clade_analysis;
3
4 import java.io.File;
5
6 import org.forester.io.parsers.PhylogenyParser;
7 import org.forester.io.parsers.util.ParserUtils;
8 import org.forester.phylogeny.Phylogeny;
9 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
10 import org.forester.phylogeny.factories.PhylogenyFactory;
11 import org.forester.util.ForesterUtil;
12
13 public class CladeAnalysisDemo {
14
15     private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" ) + ForesterUtil.getFileSeparator()
16             + "test_data" + ForesterUtil.getFileSeparator();
17
18     public static void main( final String[] args ) {
19         boolean failed = false;
20        
21         if ( !testCladeAnalysis1() ) {
22             System.out.println( "Demo 1 failed" );
23             failed = true;
24         }
25         if ( !testCladeAnalysis2() ) {
26             System.out.println( "Demo 2 failed" );
27             failed = true;
28         }
29         
30         if ( !testCladeAnalysis3() ) {
31             System.out.println( "Demo 3 failed" );
32             failed = true;
33         }
34         
35         if ( !testCladeAnalysis4() ) {
36             System.out.println( "Demo 4 failed" );
37             failed = true;
38         }
39         
40         if ( !testCladeAnalysis5() ) {
41             System.out.println( "Demo 5 failed" );
42             failed = true;
43         }
44         
45         if ( !testCladeAnalysis6() ) {
46             System.out.println( "Demo 6 failed" );
47             failed = true;
48         }
49         
50         if ( !testCladeAnalysis7() ) {
51             System.out.println( "Demo 7 failed" );
52             failed = true;
53         }
54         
55         if ( !testCladeAnalysis8() ) {
56             System.out.println( "Demo 8 failed" );
57             failed = true;
58         }
59         
60         if ( !testCladeAnalysis9() ) {
61             System.out.println( "Demo 9 failed" );
62             failed = true;
63         }
64      
65        
66         if ( !failed ) {
67             System.out.println( "OK" );
68         }
69         else {
70             System.out.println( "NOT OK" );
71         }
72     }
73
74
75     
76     
77
78     
79
80     private static boolean testCladeAnalysis1() {
81         try {
82             final File in = new File( PATH_TO_TEST_DATA + "cladinator_demo_1.xml" );
83             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
84             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( in, true );
85             final Phylogeny p1 = factory.create( in, pp )[ 0 ];
86             ResultMulti res = AnalysisMulti.execute( p1, 0.5 );
87             
88             System.out.println( "DEMO 1:" );
89             System.out.println( "+++++++" );
90             System.out.print( res.toString() );
91             System.out.println( "------------------------- " );
92             System.out.println();
93         }
94         catch ( final Exception e ) {
95             e.printStackTrace( System.out );
96             return false;
97         }
98         return true;
99     }
100     
101     private static boolean testCladeAnalysis2() {
102         try {
103             final File in = new File( PATH_TO_TEST_DATA + "cladinator_demo_2.xml" );
104             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
105             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( in, true );
106             final Phylogeny p1 = factory.create( in, pp )[ 0 ];
107             ResultMulti res = AnalysisMulti.execute( p1, 0.5 );
108             
109             System.out.println( "DEMO 1:" );
110             System.out.println( "+++++++" );
111             System.out.print( res.toString() );
112             System.out.println( "------------------------- " );
113             System.out.println();
114         }
115         catch ( final Exception e ) {
116             e.printStackTrace( System.out );
117             return false;
118         }
119         return true;
120     }
121     
122     private static boolean testCladeAnalysis3() {
123         try {
124             final File in = new File( PATH_TO_TEST_DATA + "cladinator_demo_3.xml" );
125             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
126             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( in, true );
127             final Phylogeny p1 = factory.create( in, pp )[ 0 ];
128             ResultMulti res = AnalysisMulti.execute( p1, 0.5 );
129             
130             System.out.println( "DEMO 3:" );
131             System.out.println( "+++++++" );
132             System.out.print( res.toString() );
133             System.out.println( "------------------------- " );
134             System.out.println();
135         }
136         catch ( final Exception e ) {
137             e.printStackTrace( System.out );
138             return false;
139         }
140         return true;
141     }
142
143     
144     private static boolean testCladeAnalysis4() {
145         try {
146             final File in = new File( PATH_TO_TEST_DATA + "cladinator_demo_4.xml" );
147             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
148             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( in, true );
149             final Phylogeny p1 = factory.create( in, pp )[ 0 ];
150             ResultMulti res = AnalysisMulti.execute( p1, 0.5 );
151             
152             System.out.println( "DEMO 4:" );
153             System.out.println( "+++++++" );
154             System.out.print( res.toString() );
155             System.out.println( "------------------------- " );
156             System.out.println();
157         }
158         catch ( final Exception e ) {
159             e.printStackTrace( System.out );
160             return false;
161         }
162         return true;
163     }
164     
165     private static boolean testCladeAnalysis5() {
166         try {
167             final File in = new File( PATH_TO_TEST_DATA + "cladinator_demo_5.xml" );
168             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
169             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( in, true );
170             final Phylogeny p1 = factory.create( in, pp )[ 0 ];
171             ResultMulti res = AnalysisMulti.execute( p1, 0.5 );
172             
173             System.out.println( "DEMO 5:" );
174             System.out.println( "+++++++" );
175             System.out.print( res.toString() );
176             System.out.println( "------------------------- " );
177             System.out.println();
178         }
179         catch ( final Exception e ) {
180             e.printStackTrace( System.out );
181             return false;
182         }
183         return true;
184     }
185     
186     private static boolean testCladeAnalysis6() {
187         try {
188             final File in = new File( PATH_TO_TEST_DATA + "cladinator_demo_6.xml" );
189             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
190             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( in, true );
191             final Phylogeny p1 = factory.create( in, pp )[ 0 ];
192             ResultMulti res = AnalysisMulti.execute( p1, 0.5 );
193             
194             System.out.println( "DEMO 6:" );
195             System.out.println( "+++++++" );
196             System.out.print( res.toString() );
197             System.out.println( "------------------------- " );
198             System.out.println();
199         }
200         catch ( final Exception e ) {
201             e.printStackTrace( System.out );
202             return false;
203         }
204         return true;
205     }
206     
207     private static boolean testCladeAnalysis7() {
208         try {
209             final File in = new File( PATH_TO_TEST_DATA + "cladinator_demo_7.xml" );
210             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
211             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( in, true );
212             final Phylogeny p1 = factory.create( in, pp )[ 0 ];
213             ResultMulti res = AnalysisMulti.execute( p1, 0.5 );
214             
215             System.out.println( "DEMO 7:" );
216             System.out.println( "+++++++" );
217             System.out.print( res.toString() );
218             System.out.println( "------------------------- " );
219             System.out.println();
220         }
221         catch ( final Exception e ) {
222             e.printStackTrace( System.out );
223             return false;
224         }
225         return true;
226     }
227     
228     private static boolean testCladeAnalysis8() {
229         try {
230             final File in = new File( PATH_TO_TEST_DATA + "cladinator_demo_8.xml" );
231             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
232             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( in, true );
233             final Phylogeny p1 = factory.create( in, pp )[ 0 ];
234             ResultMulti res = AnalysisMulti.execute( p1, 0.5 );
235             
236             System.out.println( "DEMO 8:" );
237             System.out.println( "+++++++" );
238             System.out.print( res.toString() );
239             System.out.println( "------------------------- " );
240             System.out.println();
241         }
242         catch ( final Exception e ) {
243             e.printStackTrace( System.out );
244             return false;
245         }
246         return true;
247     }
248     
249     private static boolean testCladeAnalysis9() {
250         try {
251             final File in = new File( PATH_TO_TEST_DATA + "cladinator_demo_9.xml" );
252             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
253             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( in, true );
254             final Phylogeny p1 = factory.create( in, pp )[ 0 ];
255             ResultMulti res = AnalysisMulti.execute( p1, 0.5 );
256             
257             System.out.println( "DEMO 9:" );
258             System.out.println( "+++++++" );
259             System.out.print( res.toString() );
260             System.out.println( "------------------------- " );
261             System.out.println();
262         }
263         catch ( final Exception e ) {
264             e.printStackTrace( System.out );
265             return false;
266         }
267         return true;
268     }
269
270  
271 }