+++ /dev/null
-/* Copyright (c) 2009 Peter Troshin\r
- * \r
- * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 \r
- * \r
- * This library is free software; you can redistribute it and/or modify it under the terms of the\r
- * Apache License version 2 as published by the Apache Software Foundation\r
- * \r
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
- * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
- * License for more details.\r
- * \r
- * A copy of the license is in apache_license.txt. It is also available here:\r
- * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
- * \r
- * Any republication or derived work distributed in source code form\r
- * must include this copyright and license notice.\r
- */\r
-\r
-package compbio.runner.msa;\r
-\r
-import static org.testng.Assert.assertNotNull;\r
-import static org.testng.Assert.fail;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import javax.xml.bind.ValidationException;\r
-\r
-import org.apache.log4j.Level;\r
-import org.apache.log4j.Logger;\r
-import org.testng.annotations.BeforeMethod;\r
-import org.testng.annotations.Test;\r
-\r
-import compbio.engine.Configurator;\r
-import compbio.engine.SyncExecutor;\r
-import compbio.engine.client.ConfiguredExecutable;\r
-import compbio.engine.client.Executable.ExecProvider;\r
-import compbio.metadata.AllTestSuit;\r
-import compbio.metadata.JobExecutionException;\r
-import compbio.metadata.JobSubmissionException;\r
-import compbio.metadata.Option;\r
-import compbio.metadata.Parameter;\r
-import compbio.metadata.Preset;\r
-import compbio.metadata.PresetManager;\r
-import compbio.metadata.ResultNotAvailableException;\r
-import compbio.metadata.RunnerConfig;\r
-import compbio.runner.OptionCombinator;\r
-import compbio.runner.msa.Tcoffee;\r
-import compbio.util.Util;\r
-
-\r
-public class TcoffeeParametersTester {\r
-\r
- public static String test_outfile = "TO1381.tcoffee.out";\r
-\r
- private static Logger log = Logger\r
- .getLogger(AllTestSuit.RUNNER_TEST_LOGGER);\r
- static {\r
- log.setLevel(Level.INFO);\r
- }\r
-\r
- RunnerConfig<Tcoffee> tcoffeeConfig = compbio.runner.RunnerUtil.getSupportedOptions(Tcoffee.class);\r
- OptionCombinator tcoffeeOpc = null;\r
- PresetManager<Tcoffee> presets = compbio.runner.RunnerUtil.getPresets(Tcoffee.class);\r
-\r
- @BeforeMethod(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void setup() {\r
- tcoffeeOpc = new OptionCombinator(tcoffeeConfig);\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void testDefaultParameters() {\r
- Tcoffee tcoffee = new Tcoffee();\r
- tcoffee.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
-\r
- try {\r
- // For local execution use relavive\r
- ConfiguredExecutable<Tcoffee> confTcoffee = Configurator\r
- .configureExecutable(tcoffee, ExecProvider.Cluster);\r
- SyncExecutor sexecutor = Configurator.getSyncEngine(confTcoffee);\r
- sexecutor.executeJob();\r
- ConfiguredExecutable<?> al = sexecutor.waitForResult();\r
- assertNotNull(al.getResults());\r
- } catch (JobSubmissionException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (JobExecutionException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (ResultNotAvailableException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- }\r
- }\r
-\r
- @Test\r
- public void testConfiguration() {\r
- try {\r
- this.tcoffeeConfig.validate();\r
- } catch (ValidationException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (IllegalStateException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- }\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void testOptions() {\r
- test(tcoffeeOpc.getAllOptions());\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void testParameters() {\r
- List<Parameter<?>> params = tcoffeeOpc.getAllParameters();\r
- Collections.shuffle(params);\r
- test(params);\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void testArguments() {\r
- List<Option<?>> options = new ArrayList<Option<?>>(tcoffeeConfig\r
- .getOptions());\r
- options.addAll(tcoffeeOpc.getAllParameters());\r
- Collections.shuffle(options);\r
- test(options);\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void testConstrainedParametersMinValues() {\r
- Map<Parameter<?>, String> params = tcoffeeOpc\r
- .getAllConstrainedParametersWithBorderValues(true);\r
- test(params);\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void testConstrainedParametersMaxValues() {\r
- Map<Parameter<?>, String> params = tcoffeeOpc\r
- .getAllConstrainedParametersWithBorderValues(false);\r
- test(params);\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void testConstrainedParametersRandomValues() {\r
- for (int i = 0; i < 20; i++) {\r
- Map<Parameter<?>, String> params = tcoffeeOpc\r
- .getAllConstrainedParametersWithRandomValues();\r
- List<Parameter<?>> paramList = new ArrayList<Parameter<?>>(params\r
- .keySet());\r
- Collections.shuffle(paramList);\r
- List<Parameter<?>> subList = paramList.subList(0, Util\r
- .getRandomNumber(1, paramList.size()));\r
- List<String> args = tcoffeeOpc.parametersToCommandString(subList,\r
- params);\r
- singleTest(args);\r
- }\r
- }\r
-\r
- // TODO fix this!\r
- // This is due to incorrect installation of Blast with tcoffee mode\r
- // expresso.\r
- // It is either have to be fixed or removed\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void testPresets() {\r
- for (Preset<Tcoffee> p : presets.getPresets()) {\r
- singleTest(p.getOptions());\r
- }\r
- }\r
-\r
- void test(Map<Parameter<?>, String> paramValue) {\r
- List<Parameter<?>> paramList = new ArrayList<Parameter<?>>(paramValue\r
- .keySet());\r
- for (int i = 0; i < paramValue.size(); i++) {\r
- List<String> args = tcoffeeOpc.parametersToCommandString(paramList,\r
- paramValue);\r
- singleTest(args);\r
- Collections.shuffle(paramList);\r
- }\r
- log.info("NUMBER OF COBINATION TESTED: " + paramValue.size());\r
- }\r
-\r
- void test(List<? extends Option<?>> params) {\r
- for (int i = 0; i < params.size(); i++) {\r
- List<String> args = tcoffeeOpc.argumentsToCommandString(params);\r
- singleTest(args);\r
- Collections.shuffle(params);\r
- }\r
- log.info("NUMBER OF COBINATION TESTED: " + params.size());\r
- }\r
-\r
- void singleTest(List<String> params) {\r
- try {\r
- log.info("Using arguments: " + params);\r
- String input = AllTestSuit.test_input;\r
- if (params.contains("-mode rcoffee")) {\r
- input = AllTestSuit.test_input_dna;\r
- }\r
- Tcoffee tcoffee = new Tcoffee();\r
- tcoffee.setInput(input).setOutput(test_outfile);\r
-\r
- // For local execution use relative\r
- ConfiguredExecutable<Tcoffee> confTcoffee = Configurator\r
- .configureExecutable(tcoffee, ExecProvider.Local);\r
- // Add options to the executable\r
- confTcoffee.addParameters(params);\r
-\r
- SyncExecutor sexecutor = Configurator.getSyncEngine(confTcoffee,\r
- ExecProvider.Local);\r
- sexecutor.executeJob();\r
- ConfiguredExecutable<?> al = sexecutor.waitForResult();\r
- assertNotNull(al.getResults());\r
- /*\r
- * TODO File errors = new File(confMafft.getWorkDirectory(),\r
- * ExecutableWrapper.PROC_ERR_FILE); if (errors.length() != 0) {\r
- * log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors)); }\r
- * assertTrue("Run with arguments : " + params + " FAILED!", errors\r
- * .length() == 0);\r
- */\r
- } catch (JobSubmissionException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (JobExecutionException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (ResultNotAvailableException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- }\r
- }\r
-\r
-}\r