2 * Copyright (c) 2011 Peter Troshin JAva Bioinformatics Analysis Web Services
\r
3 * (JABAWS) @version: 2.0 This library is free software; you can redistribute it
\r
4 * and/or modify it under the terms of the Apache License version 2 as published
\r
5 * by the Apache Software Foundation This library is distributed in the hope
\r
6 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
\r
7 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
8 * Apache License for more details. A copy of the license is in
\r
9 * apache_license.txt. It is also available here:
\r
10 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt Any republication or
\r
11 * derived work distributed in source code form must include this copyright and
\r
15 package compbio.runner.disorder;
\r
17 import java.io.File;
\r
18 import java.io.FileInputStream;
\r
19 import java.io.FileNotFoundException;
\r
20 import java.io.IOException;
\r
21 import java.io.InputStream;
\r
23 import java.util.Map;
\r
24 import java.util.Set;
\r
26 import org.apache.log4j.Logger;
\r
29 import compbio.data.sequence.Score;
\r
30 import compbio.data.sequence.SequenceUtil;
\r
31 import compbio.data.sequence.UnknownFileFormatException;
\r
33 import compbio.engine.client.Executable;
\r
34 import compbio.engine.client.PipedExecutable;
\r
35 import compbio.engine.client.SkeletalExecutable;
\r
36 import compbio.metadata.Limit;
\r
37 import compbio.metadata.LimitsManager;
\r
38 import compbio.metadata.ResultNotAvailableException;
\r
39 import compbio.runner.Util;
\r
42 * DisEMBL.py smooth_frame peak_frame join_frame fold_coils fold_hotloops
\r
43 * fold_rem465 sequence_file print
\r
45 * 'A default run would be: ./DisEMBL.py 8 8 4 1.2 1.4 1.2 fasta_file > out'
\r
47 * This version of DisEMBL is 1.4 (latest available for download in Feb 2011)
\r
48 * capable of outputting raw values
\r
50 * The values of the parameters are hard coded in DisEMBL.py script.
\r
51 * smooth_frame=8 peak_frame=8 join_frame=4 fold_coils=1.2 fold_hotloops=1.4
\r
54 * Changing these values are not recommended by developers, apart from smoothing window.
\r
55 * However, 5 orders of magnitude changes in this parameter does not change the output
\r
56 * so allowing this change also seems pointless. Finally, the binary, DisEMBL depends on
\r
57 * - Tisean is not happy with arbitruary changes to these values, so changing them can
\r
61 * This is not a standard DisEMBL! The script has been modified!
\r
64 public class Disembl extends SkeletalExecutable<Disembl>
\r
66 PipedExecutable<Disembl> {
\r
68 private static Logger log = Logger.getLogger(Disembl.class);
\r
70 // Cache for Limits information
\r
71 private static LimitsManager<Disembl> limits;
\r
73 public static final String KEY_VALUE_SEPARATOR = Util.SPACE;
\r
75 /* The parameter list there must not contain same values! */
\r
77 // remove default input to prevent it to appear in the parameters list
\r
78 // that could happen if the parameters are set first
\r
79 // super.setInput("");
\r
82 @SuppressWarnings("unchecked")
\r
83 public Map<String, Set<Score>> getResults(String workDirectory)
\r
84 throws ResultNotAvailableException {
\r
86 InputStream inStream = null;
\r
87 Map<String, Set<Score>> results= null;
\r
89 inStream = new FileInputStream(new File(workDirectory,
\r
91 results = SequenceUtil.removeSequences(SequenceUtil.readDisembl(inStream));
\r
93 } catch (FileNotFoundException e) {
\r
94 log.error(e.getMessage(), e.getCause());
\r
95 throw new ResultNotAvailableException(e);
\r
96 } catch (IOException e) {
\r
97 log.error(e.getMessage(), e.getCause());
\r
98 throw new ResultNotAvailableException(e);
\r
99 } catch (UnknownFileFormatException e) {
\r
100 log.error(e.getMessage(), e.getCause());
\r
101 throw new ResultNotAvailableException(e);
\r
102 } catch (NullPointerException e) {
\r
103 log.error(e.getMessage(), e.getCause());
\r
104 throw new ResultNotAvailableException(e);
\r
111 public Disembl setInput(String inFile) {
\r
112 super.setInput(inFile);
\r
113 cbuilder.setLast(inFile);
\r
118 public Limit<Disembl> getLimit(String presetName) {
\r
119 if (limits == null) {
\r
120 limits = getLimits();
\r
123 Limit<Disembl> limit = null;
\r
124 if (limits != null) {
\r
125 // this returns default limit if preset is undefined!
\r
126 limit = limits.getLimitByName(presetName);
\r
128 // If limit is not defined for a particular preset, then return default
\r
130 if (limit == null) {
\r
131 log.debug("Limit for the preset " + presetName
\r
132 + " is not found. Using default");
\r
133 limit = limits.getDefaultLimit();
\r
139 public LimitsManager<Disembl> getLimits() {
\r
140 // synchronise on static field
\r
141 synchronized (log) {
\r
142 if (limits == null) {
\r
143 limits = Util.getLimits(this.getClass());
\r
150 public Class<? extends Executable<?>> getType() {
\r
151 return this.getClass();
\r