Some lost files
[proteocache.git] / testsrc / compbio / metadata / OptionCombinatorTester.java
1 /* Copyright (c) 2009 Peter Troshin\r
2  *  \r
3  *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \r
4  * \r
5  *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
6  *  Apache License version 2 as published by the Apache Software Foundation\r
7  * \r
8  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
9  *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
10  *  License for more details.\r
11  * \r
12  *  A copy of the license is in apache_license.txt. It is also available here:\r
13  * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
14  * \r
15  * Any republication or derived work distributed in source code form\r
16  * must include this copyright and license notice.\r
17  */\r
18 \r
19 package compbio.metadata;\r
20 \r
21 import static org.testng.Assert.fail;\r
22 \r
23 import java.io.File;\r
24 import java.io.FileInputStream;\r
25 import java.io.FileNotFoundException;\r
26 \r
27 import javax.xml.bind.JAXBException;\r
28 \r
29 import org.testng.annotations.BeforeMethod;\r
30 import org.testng.annotations.Test;\r
31 \r
32 import compbio.engine.conf.RunnerConfigMarshaller;\r
33 import compbio.metadata.RunnerConfig;\r
34 import compbio.runner.OptionCombinator;\r
35 import compbio.runner.msa.ClustalW;\r
36 import compbio.runner.msa.Mafft;\r
37 import compbio.runner.msa.Muscle;\r
38 \r
39 public class OptionCombinatorTester {\r
40 \r
41         static final String mafftConfigFile = AllTestSuit.TEST_DATA_PATH\r
42                         + "MafftParameters.xml";\r
43 \r
44         static final String muscleConfigFile = AllTestSuit.TEST_DATA_PATH\r
45                         + "MuscleParameters.xml";\r
46 \r
47         static final String clustalConfigFile = AllTestSuit.TEST_DATA_PATH\r
48                         + "ClustalParameters.xml";\r
49 \r
50         RunnerConfig<Mafft> mafftConfig = null;\r
51         RunnerConfig<Mafft> muscleConfig = null;\r
52         RunnerConfig<Mafft> clustalConfig = null;\r
53 \r
54         @BeforeMethod\r
55         @SuppressWarnings("unchecked")\r
56         void setup() {\r
57                 try {\r
58                         RunnerConfigMarshaller<Mafft> mf = new RunnerConfigMarshaller<Mafft>(\r
59                                         RunnerConfig.class);\r
60                         mafftConfig = mf.read(\r
61                                         new FileInputStream(new File(mafftConfigFile)),\r
62                                         RunnerConfig.class);\r
63                         RunnerConfigMarshaller<Muscle> musclemarsh = new RunnerConfigMarshaller<Muscle>(\r
64                                         RunnerConfig.class);\r
65                         muscleConfig = musclemarsh.read(new FileInputStream(new File(\r
66                                         muscleConfigFile)), RunnerConfig.class);\r
67 \r
68                         RunnerConfigMarshaller<ClustalW> clustalmarsh = new RunnerConfigMarshaller<ClustalW>(\r
69                                         RunnerConfig.class);\r
70                         clustalConfig = clustalmarsh.read(new FileInputStream(new File(\r
71                                         clustalConfigFile)), RunnerConfig.class);\r
72 \r
73                 } catch (FileNotFoundException e) {\r
74                         e.printStackTrace();\r
75                         fail(e.getMessage());\r
76                 } catch (JAXBException e) {\r
77                         e.printStackTrace();\r
78                         fail(e.getMessage());\r
79                 }\r
80         }\r
81 \r
82         @Test\r
83         public void testgetAllOptions() {\r
84                 OptionCombinator opc = new OptionCombinator(mafftConfig);\r
85                 System.out.println(opc.getOptionsAtRandom());\r
86                 OptionCombinator muscleOpc = new OptionCombinator(muscleConfig);\r
87                 System.out.println("Mucle " + muscleOpc.getOptionsAtRandom());\r
88                 OptionCombinator clustalOpc = new OptionCombinator(clustalConfig);\r
89                 System.out.println("Clustal " + clustalOpc.getOptionsAtRandom());\r
90 \r
91         }\r
92 \r
93         @Test\r
94         public void testgetAllParameters() {\r
95                 OptionCombinator opc = new OptionCombinator(mafftConfig);\r
96                 System.out.println(opc.getAllParameters());\r
97                 OptionCombinator muscleOpc = new OptionCombinator(muscleConfig);\r
98                 System.out.println("Muscle : " + muscleOpc.getAllParameters());\r
99                 OptionCombinator clustalOpc = new OptionCombinator(clustalConfig);\r
100                 System.out.println("Clustal : " + clustalOpc.getAllParameters());\r
101         }\r
102 }\r