2 package org.forester.clade_analysis;
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;
13 public class CladeAnalysisDemo {
15 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" ) + ForesterUtil.getFileSeparator()
16 + "test_data" + ForesterUtil.getFileSeparator();
18 public static void main( final String[] args ) {
19 boolean failed = false;
21 if ( !testCladeAnalysis1() ) {
22 System.out.println( "Demo 1 failed" );
25 if ( !testCladeAnalysis2() ) {
26 System.out.println( "Demo 2 failed" );
30 if ( !testCladeAnalysis3() ) {
31 System.out.println( "Demo 3 failed" );
35 if ( !testCladeAnalysis4() ) {
36 System.out.println( "Demo 4 failed" );
40 if ( !testCladeAnalysis5() ) {
41 System.out.println( "Demo 5 failed" );
45 if ( !testCladeAnalysis6() ) {
46 System.out.println( "Demo 6 failed" );
50 if ( !testCladeAnalysis7() ) {
51 System.out.println( "Demo 7 failed" );
55 if ( !testCladeAnalysis8() ) {
56 System.out.println( "Demo 8 failed" );
60 if ( !testCladeAnalysis9() ) {
61 System.out.println( "Demo 9 failed" );
67 System.out.println( "OK" );
70 System.out.println( "NOT OK" );
80 private static boolean testCladeAnalysis1() {
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 );
88 System.out.println( "DEMO 1:" );
89 System.out.println( "+++++++" );
90 System.out.print( res.toString() );
91 System.out.println( "------------------------- " );
94 catch ( final Exception e ) {
95 e.printStackTrace( System.out );
101 private static boolean testCladeAnalysis2() {
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 );
109 System.out.println( "DEMO 2:" );
110 System.out.println( "+++++++" );
111 System.out.print( res.toString() );
112 System.out.println( "------------------------- " );
113 System.out.println();
115 catch ( final Exception e ) {
116 e.printStackTrace( System.out );
122 private static boolean testCladeAnalysis3() {
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 );
130 System.out.println( "DEMO 3:" );
131 System.out.println( "+++++++" );
132 System.out.print( res.toString() );
133 System.out.println( "------------------------- " );
134 System.out.println();
136 catch ( final Exception e ) {
137 e.printStackTrace( System.out );
144 private static boolean testCladeAnalysis4() {
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 );
152 System.out.println( "DEMO 4:" );
153 System.out.println( "+++++++" );
154 System.out.print( res.toString() );
155 System.out.println( "------------------------- " );
156 System.out.println();
158 catch ( final Exception e ) {
159 e.printStackTrace( System.out );
165 private static boolean testCladeAnalysis5() {
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 );
173 System.out.println( "DEMO 5:" );
174 System.out.println( "+++++++" );
175 System.out.print( res.toString() );
176 System.out.println( "------------------------- " );
177 System.out.println();
179 catch ( final Exception e ) {
180 e.printStackTrace( System.out );
186 private static boolean testCladeAnalysis6() {
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 );
194 System.out.println( "DEMO 6:" );
195 System.out.println( "+++++++" );
196 System.out.print( res.toString() );
197 System.out.println( "------------------------- " );
198 System.out.println();
200 catch ( final Exception e ) {
201 e.printStackTrace( System.out );
207 private static boolean testCladeAnalysis7() {
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 );
215 System.out.println( "DEMO 7:" );
216 System.out.println( "+++++++" );
217 System.out.print( res.toString() );
218 System.out.println( "------------------------- " );
219 System.out.println();
221 catch ( final Exception e ) {
222 e.printStackTrace( System.out );
228 private static boolean testCladeAnalysis8() {
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 );
236 System.out.println( "DEMO 8:" );
237 System.out.println( "+++++++" );
238 System.out.print( res.toString() );
239 System.out.println( "------------------------- " );
240 System.out.println();
242 catch ( final Exception e ) {
243 e.printStackTrace( System.out );
249 private static boolean testCladeAnalysis9() {
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 );
257 System.out.println( "DEMO 9:" );
258 System.out.println( "+++++++" );
259 System.out.print( res.toString() );
260 System.out.println( "------------------------- " );
261 System.out.println();
263 catch ( final Exception e ) {
264 e.printStackTrace( System.out );