New Linux binaries for ViennaRNA
[jabaws.git] / runner / compbio / runner / disorder / GlobPlot.java
1 /*\r
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
12  * license notice.\r
13  */\r
14 \r
15 package compbio.runner.disorder;\r
16 \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
22 \r
23 import org.apache.log4j.Logger;\r
24 \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.PipedExecutable;\r
29 import compbio.engine.client.SkeletalExecutable;\r
30 import compbio.metadata.ResultNotAvailableException;\r
31 import compbio.runner.Util;\r
32 \r
33 /**\r
34  * ./GlobPipe.py SmoothFrame DOMjoinFrame DOMpeakFrame DISjoinFrame DISpeakFrame\r
35  * \r
36  * FASTAfile' Optimised for ELM: ./GlobPlot.py 10 8 75 8 8 sequence_file'\r
37  * Webserver settings: ./GlobPlot.py 10 15 74 4 5 sequence_file'\r
38  * \r
39  * Hard-coded values are 10 15 74 4 5.\r
40  * \r
41  * Changing these values are not recommended by developers, apart from smoothing\r
42  * window. However, the binary, GlobPlot depends on - Tisean which is not happy\r
43  * with arbitrary changes to these values, so changing them can lead to\r
44  * problems. May be we can offer preset?\r
45  * \r
46  * This is not a standard GlobPlot! The script has been modified!\r
47  * \r
48  */\r
49 public class GlobPlot extends SkeletalExecutable<GlobPlot>\r
50                 implements\r
51                         PipedExecutable<GlobPlot> {\r
52 \r
53         private static Logger log = Logger.getLogger(GlobPlot.class);\r
54 \r
55         public static final String KEY_VALUE_SEPARATOR = Util.SPACE;\r
56 \r
57         /* The parameter list there must not contain same values! */\r
58         public GlobPlot() {\r
59                 // remove default input to prevent it to appear in the parameters list\r
60                 // that could happen if the parameters are set first\r
61                 // super.setInput("");\r
62         }\r
63 \r
64         @Override\r
65         @SuppressWarnings("unchecked")\r
66         public ScoreManager getResults(String workDirectory)\r
67                         throws ResultNotAvailableException {\r
68 \r
69                 InputStream inStream = null;\r
70                 ScoreManager results = null;\r
71                 // How about getting ranges?\r
72                 try {\r
73                         inStream = new FileInputStream(new File(workDirectory, getOutput()));\r
74                         results = ScoreManager.newInstance(SequenceUtil\r
75                                         .readGlobPlot(inStream));\r
76                         inStream.close();\r
77                 } catch (FileNotFoundException e) {\r
78                         log.error(e.getMessage(), e.getCause());\r
79                         throw new ResultNotAvailableException(e);\r
80                 } catch (IOException e) {\r
81                         log.error(e.getMessage(), e.getCause());\r
82                         throw new ResultNotAvailableException(e);\r
83                 } catch (UnknownFileFormatException e) {\r
84                         log.error(e.getMessage(), e.getCause());\r
85                         throw new ResultNotAvailableException(e);\r
86                 } catch (NullPointerException e) {\r
87                         log.error(e.getMessage(), e.getCause());\r
88                         throw new ResultNotAvailableException(e);\r
89                 }\r
90 \r
91                 return results;\r
92         }\r
93 \r
94         @Override\r
95         public GlobPlot setInput(String inFile) {\r
96                 super.setInput(inFile);\r
97                 cbuilder.setLast(inFile);\r
98                 return this;\r
99         }\r
100 \r
101         @SuppressWarnings("unchecked")\r
102         @Override\r
103         public Class<GlobPlot> getType() {\r
104                 return (Class<GlobPlot>) this.getClass();\r
105         }\r
106 \r
107 }\r