1 /* Copyright (c) 2011 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.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
24 import java.util.List;
\r
26 import org.apache.log4j.Logger;
\r
28 import compbio.data.sequence.Alignment;
\r
29 import compbio.data.sequence.UnknownFileFormatException;
\r
31 import compbio.engine.client.PipedExecutable;
\r
32 import compbio.engine.client.SkeletalExecutable;
\r
33 import compbio.metadata.ResultNotAvailableException;
\r
34 import compbio.runner.RunnerUtil;
\r
41 public class Mafft extends SkeletalExecutable<Mafft> implements PipedExecutable<Mafft> {
\r
43 * TODO get rid of piping: Mafft now supports --out option for output file.
\r
44 * Multi-threading supported with e.g. "thread 4" only for Linux, so JABAWS
\r
45 * will not support it for now, it also need editing of mafft makefile
\r
48 private static Logger log = Logger.getLogger(Mafft.class);
\r
50 private static String autoOption = "--auto";
\r
52 private final String MATRIX_PAR_NAME = "--aamatrix";
\r
54 public static final String KEY_VALUE_SEPARATOR = " ";
\r
57 // remove default input to prevent it to appear in the parameters list
\r
58 // that could happen if the parameters are set first
\r
59 // super.setInput("");
\r
60 addParameters(Arrays.asList("--clustalout", autoOption));
\r
63 @SuppressWarnings("unchecked")
\r
64 public Alignment getResults(String workDirectory)
\r
65 throws ResultNotAvailableException {
\r
67 return RunnerUtil.readClustalFile(workDirectory, getOutput());
\r
68 } catch (FileNotFoundException e) {
\r
69 log.error(e.getMessage(), e.getCause());
\r
70 throw new ResultNotAvailableException(e);
\r
71 } catch (IOException e) {
\r
72 log.error(e.getMessage(), e.getCause());
\r
73 throw new ResultNotAvailableException(e);
\r
74 } catch (UnknownFileFormatException e) {
\r
75 log.error(e.getMessage(), e.getCause());
\r
76 throw new ResultNotAvailableException(e);
\r
77 } catch (NullPointerException e) {
\r
78 log.error(e.getMessage(), e.getCause());
\r
79 throw new ResultNotAvailableException(e);
\r
84 public Mafft setInput(String inFile) {
\r
85 super.setInput(inFile);
\r
86 cbuilder.setLast(inFile);
\r
91 * Mafft input must always be the last parameter!
\r
94 public Mafft addParameters(List<String> parameters) {
\r
95 cbuilder.addParams(parameters);
\r
96 cbuilder.removeParam(autoOption);
\r
102 @SuppressWarnings("unchecked")
\r
104 public Class<Mafft> getType() {
\r
105 return (Class<Mafft>) this.getClass();
\r