1 /* Copyright (c) 2009 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0
\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
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
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
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
19 package compbio.runner.msa;
\r
21 import java.io.FileNotFoundException;
\r
22 import java.io.IOException;
\r
23 import java.util.Arrays;
\r
25 import org.apache.log4j.Logger;
\r
27 import compbio.data.sequence.Alignment;
\r
28 import compbio.data.sequence.UnknownFileFormatException;
\r
29 import compbio.engine.client.SkeletalExecutable;
\r
30 import compbio.metadata.ResultNotAvailableException;
\r
31 import compbio.runner.Util;
\r
33 public class ClustalO extends SkeletalExecutable<ClustalO> {
\r
35 private static Logger log = Logger.getLogger(ClustalO.class);
\r
36 private static final String EXEC_STAT_FILE = "stat.log";
\r
37 private static final String TREE_FILE_EXT = ".dnd";
\r
39 public static final String KEY_VALUE_SEPARATOR = "=";
\r
43 * --auto Set options automatically (might overwrite some of your options)
\r
45 * --threads=<n> Number of processors to use
\r
47 * -l, --log=<file> Log all non-essential output to this file
\r
50 super(KEY_VALUE_SEPARATOR);
\r
51 addParameters(Arrays.asList("--outfmt=clustal", "-v", "--log="
\r
53 // set default in, outs and err files
\r
54 this.setInput(super.inputFile);
\r
55 this.setOutput(super.outputFile);
\r
56 this.setError(super.errorFile);
\r
60 public ClustalO setOutput(String outFile) {
\r
61 super.setOutput(outFile);
\r
62 cbuilder.setParam("--outfile=" + outFile);
\r
67 public ClustalO setInput(String inFile) {
\r
68 super.setInput(inFile);
\r
69 cbuilder.setParam("--infile=" + inFile);
\r
73 @SuppressWarnings("unchecked")
\r
74 public Alignment getResults(String workDirectory)
\r
75 throws ResultNotAvailableException {
\r
77 return Util.readClustalFile(workDirectory, getOutput());
\r
78 } catch (FileNotFoundException e) {
\r
79 log.error(e.getMessage(), e.getCause());
\r
80 throw new ResultNotAvailableException(e);
\r
81 } catch (IOException e) {
\r
82 log.error(e.getMessage(), e.getCause());
\r
83 throw new ResultNotAvailableException(e);
\r
84 } catch (UnknownFileFormatException e) {
\r
85 log.error(e.getMessage(), e.getCause());
\r
86 throw new ResultNotAvailableException(e);
\r
87 } catch (NullPointerException e) {
\r
88 log.error(e.getMessage(), e.getCause());
\r
89 throw new ResultNotAvailableException(e);
\r
93 public static String getStatFile() {
\r
94 return EXEC_STAT_FILE;
\r
97 @SuppressWarnings("unchecked")
\r
99 public Class<ClustalO> getType() {
\r
100 return (Class<ClustalO>) this.getClass();
\r