2 * Copyright (c) 2009 Peter Troshin JAva Bioinformatics Analysis Web Services
\r
3 * (JABAWS) @version: 1.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.FileNotFoundException;
\r
18 import java.io.IOException;
\r
19 import java.util.Arrays;
\r
21 import org.apache.log4j.Logger;
\r
23 import compbio.data.sequence.Alignment;
\r
24 import compbio.data.sequence.UnknownFileFormatException;
\r
25 import compbio.engine.client.Executable;
\r
26 import compbio.engine.client.PipedExecutable;
\r
27 import compbio.engine.client.SkeletalExecutable;
\r
28 import compbio.metadata.Limit;
\r
29 import compbio.metadata.LimitsManager;
\r
30 import compbio.metadata.ResultNotAvailableException;
\r
31 import compbio.runner.Util;
\r
36 * DisEMBL.py smooth_frame peak_frame join_frame fold_coils fold_hotloops
\r
37 * fold_rem465 sequence_file print 'A default run would be: ./DisEMBL.py 8
\r
38 * 8 4 1.2 1.4 1.2 fasta_file > out' new DisEMBL is at
\r
39 * /homes/pvtroshin/soft/DisEMBL-1.4raw
\r
41 * This is not a standard DisEMBL! The script has been modified! DisEMBL.py
\r
42 * smooth_frame peak_frame join_frame fold_coils fold_hotloops fold_rem465
\r
43 * [mode] < fasta_file > out print
\r
45 * 'A default run would be: ./DisEMBL.py 8 8 4 1.2 1.4 1.2 < fasta_file'
\r
46 * print 'Mode: "default"(nothing) or "scores" which will give scores per
\r
47 * residue in TAB separated format'
\r
49 public class Disembl extends SkeletalExecutable<Disembl> implements
\r
50 PipedExecutable<Disembl> {
\r
52 private static Logger log = Logger.getLogger(Disembl.class);
\r
54 // Cache for Limits information
\r
55 private static LimitsManager<Disembl> limits;
\r
57 public static final String KEY_VALUE_SEPARATOR = Util.SPACE;
\r
60 // remove default input to prevent it to appear in the parameters list
\r
61 // that could happen if the parameters are set first
\r
62 // super.setInput("");
\r
63 addParameters(Arrays.asList("8", "8", "4", "1.2", "1.4", "1.2",
\r
67 @SuppressWarnings("unchecked")
\r
68 public Alignment getResults(String workDirectory)
\r
69 throws ResultNotAvailableException {
\r
71 return Util.readClustalFile(workDirectory, getOutput());
\r
72 } catch (FileNotFoundException e) {
\r
73 log.error(e.getMessage(), e.getCause());
\r
74 throw new ResultNotAvailableException(e);
\r
75 } catch (IOException e) {
\r
76 log.error(e.getMessage(), e.getCause());
\r
77 throw new ResultNotAvailableException(e);
\r
78 } catch (UnknownFileFormatException e) {
\r
79 log.error(e.getMessage(), e.getCause());
\r
80 throw new ResultNotAvailableException(e);
\r
81 } catch (NullPointerException e) {
\r
82 log.error(e.getMessage(), e.getCause());
\r
83 throw new ResultNotAvailableException(e);
\r
88 public Disembl setInput(String inFile) {
\r
89 super.setInput(inFile);
\r
90 cbuilder.setLast(inFile);
\r
95 public Limit<Disembl> getLimit(String presetName) {
\r
96 if (limits == null) {
\r
97 limits = getLimits();
\r
100 Limit<Disembl> limit = null;
\r
101 if (limits != null) {
\r
102 // this returns default limit if preset is undefined!
\r
103 limit = limits.getLimitByName(presetName);
\r
105 // If limit is not defined for a particular preset, then return default
\r
107 if (limit == null) {
\r
108 log.debug("Limit for the preset " + presetName
\r
109 + " is not found. Using default");
\r
110 limit = limits.getDefaultLimit();
\r
116 public LimitsManager<Disembl> getLimits() {
\r
117 // synchronise on static field
\r
118 synchronized (log) {
\r
119 if (limits == null) {
\r
120 limits = Util.getLimits(this.getClass());
\r
127 public Class<? extends Executable<?>> getType() {
\r
128 return this.getClass();
\r