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 org.apache.log4j.Logger;
\r
25 import compbio.data.sequence.ScoreManager;
\r
26 import compbio.data.sequence.SequenceUtil;
\r
27 import compbio.data.sequence.UnknownFileFormatException;
\r
28 import compbio.engine.client.Executable;
\r
29 import compbio.engine.client.PipedExecutable;
\r
30 import compbio.engine.client.SkeletalExecutable;
\r
31 import compbio.metadata.Limit;
\r
32 import compbio.metadata.LimitsManager;
\r
33 import compbio.metadata.ResultNotAvailableException;
\r
34 import compbio.runner.Util;
\r
37 * ./GlobPipe.py SmoothFrame DOMjoinFrame DOMpeakFrame DISjoinFrame DISpeakFrame
\r
39 * FASTAfile' Optimised for ELM: ./GlobPlot.py 10 8 75 8 8 sequence_file'
\r
40 * Webserver settings: ./GlobPlot.py 10 15 74 4 5 sequence_file'
\r
42 * Hard-coded values are 10 15 74 4 5.
\r
44 * Changing these values are not recommended by developers, apart from smoothing
\r
45 * window. However, the binary, GlobPlot depends on - Tisean which is not happy
\r
46 * with arbitrary changes to these values, so changing them can lead to
\r
47 * problems. May be we can offer preset?
\r
49 * This is not a standard GlobPlot! The script has been modified!
\r
52 public class GlobPlot extends SkeletalExecutable<GlobPlot>
\r
54 PipedExecutable<GlobPlot> {
\r
56 private static Logger log = Logger.getLogger(GlobPlot.class);
\r
58 // Cache for Limits information
\r
59 private static LimitsManager<GlobPlot> limits;
\r
61 public static final String KEY_VALUE_SEPARATOR = Util.SPACE;
\r
63 /* The parameter list there must not contain same values! */
\r
65 // remove default input to prevent it to appear in the parameters list
\r
66 // that could happen if the parameters are set first
\r
67 // super.setInput("");
\r
70 @SuppressWarnings("unchecked")
\r
71 public ScoreManager getResults(String workDirectory)
\r
72 throws ResultNotAvailableException {
\r
74 InputStream inStream = null;
\r
75 ScoreManager results = null;
\r
76 // How about getting ranges?
\r
78 inStream = new FileInputStream(new File(workDirectory, getOutput()));
\r
79 results = ScoreManager.newInstance(SequenceUtil
\r
80 .readGlobPlot(inStream));
\r
82 } catch (FileNotFoundException e) {
\r
83 log.error(e.getMessage(), e.getCause());
\r
84 throw new ResultNotAvailableException(e);
\r
85 } catch (IOException e) {
\r
86 log.error(e.getMessage(), e.getCause());
\r
87 throw new ResultNotAvailableException(e);
\r
88 } catch (UnknownFileFormatException e) {
\r
89 log.error(e.getMessage(), e.getCause());
\r
90 throw new ResultNotAvailableException(e);
\r
91 } catch (NullPointerException e) {
\r
92 log.error(e.getMessage(), e.getCause());
\r
93 throw new ResultNotAvailableException(e);
\r
100 public GlobPlot setInput(String inFile) {
\r
101 super.setInput(inFile);
\r
102 cbuilder.setLast(inFile);
\r
107 public Limit<GlobPlot> getLimit(String presetName) {
\r
108 if (limits == null) {
\r
109 limits = getLimits();
\r
112 Limit<GlobPlot> limit = null;
\r
113 if (limits != null) {
\r
114 // this returns default limit if preset is undefined!
\r
115 limit = limits.getLimitByName(presetName);
\r
117 // If limit is not defined for a particular preset, then return default
\r
119 if (limit == null) {
\r
120 log.debug("Limit for the preset " + presetName
\r
121 + " is not found. Using default");
\r
122 limit = limits.getDefaultLimit();
\r
128 public LimitsManager<GlobPlot> getLimits() {
\r
129 // synchronise on static field
\r
130 synchronized (log) {
\r
131 if (limits == null) {
\r
132 limits = Util.getLimits(this.getClass());
\r
139 public Class<? extends Executable<?>> getType() {
\r
140 return this.getClass();
\r