annotate SMART/Java/Python/plot.py @ 58:5f5c9b74c2dd

Uploaded
author m-zytnicki
date Fri, 07 Feb 2014 11:53:36 -0500
parents 169d364ddd91
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
1 #! /usr/bin/env python
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
2 #
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
3 # Copyright INRA-URGI 2009-2010
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
4 #
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
5 # This software is governed by the CeCILL license under French law and
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
6 # abiding by the rules of distribution of free software. You can use,
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
7 # modify and/ or redistribute the software under the terms of the CeCILL
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
8 # license as circulated by CEA, CNRS and INRIA at the following URL
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
9 # "http://www.cecill.info".
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
10 #
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
11 # As a counterpart to the access to the source code and rights to copy,
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
12 # modify and redistribute granted by the license, users are provided only
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
13 # with a limited warranty and the software's author, the holder of the
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
14 # economic rights, and the successive licensors have only limited
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
15 # liability.
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
16 #
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
17 # In this respect, the user's attention is drawn to the risks associated
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
18 # with loading, using, modifying and/or developing or reproducing the
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
19 # software by the user in light of its specific status of free software,
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
20 # that may mean that it is complicated to manipulate, and that also
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
21 # therefore means that it is reserved for developers and experienced
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
22 # professionals having in-depth computer knowledge. Users are therefore
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
23 # encouraged to load and test the software's suitability as regards their
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
24 # requirements in conditions enabling the security of their systems and/or
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
25 # data to be ensured and, more generally, to use and operate it in the
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
26 # same conditions as regards security.
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
27 #
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
28 # The fact that you are presently reading this means that you have had
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
29 # knowledge of the CeCILL license and that you accept its terms.
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
30 #
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
31
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
32 """
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
33 Plot the data from the data files
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
34 """
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
35
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
36 import os, re, math
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
37 from optparse import OptionParser
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
38 from SMART.Java.Python.structure.TranscriptContainer import TranscriptContainer
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
39 from SMART.Java.Python.misc.RPlotter import RPlotter
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
40 from SMART.Java.Python.misc.Progress import Progress
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
41 from commons.core.utils.FileUtils import FileUtils
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
42
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
43 class Plot(object):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
44
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
45 def __init__(self, verbosity):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
46 self.verbosity = verbosity
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
47 self.keep = False
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
48
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
49 def keepTmpFiles(self, boolean):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
50 self.keep = boolean
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
51
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
52 def setShape(self, shape):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
53 self.shape = shape
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
54
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
55 def setInputFileName(self, fileName, format):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
56 self.parser = TranscriptContainer(fileName, format, self.verbosity)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
57
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
58 def setXData(self, tag, default):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
59 self.x = tag
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
60 self.xDefault = default
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
61
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
62 def setYData(self, tag, default):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
63 self.y = tag
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
64 self.yDefault = default
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
65
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
66 def setZData(self, tag, default):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
67 self.z = tag
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
68 self.zDefault = default
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
69
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
70 def setNbBars(self, nbBars):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
71 self.nbBars = nbBars
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
72
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
73 def setOutputFileName(self, fileName):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
74 self.outputFileName = fileName
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
75
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
76 def setRegression(self, regression):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
77 self.regression = regression
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
78
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
79 def setLog(self, log):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
80 self.log = log
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
81
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
82 def createPlotter(self):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
83 self.plotter = RPlotter(self.outputFileName, self.verbosity, self.keep)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
84 if self.shape == "barplot":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
85 self.plotter.setBarplot(True)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
86 elif self.shape == "line":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
87 pass
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
88 elif self.shape == "points":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
89 self.plotter.setPoints(True)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
90 elif self.shape == "heatPoints":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
91 self.plotter.setHeatPoints(True)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
92 else:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
93 raise Exception("Do not understand shape '%s'\n" % (self.shape))
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
94
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
95 self.plotter.setLog(self.log)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
96 self.plotter.setRegression(self.regression)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
97
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
98 def getValues(self, transcript):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
99 x = transcript.getTagValue(self.x)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
100 y = None
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
101 z = None
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
102 if self.y != None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
103 y = transcript.getTagValue(self.y)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
104 if self.z != None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
105 z = transcript.getTagValue(self.z)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
106 if x == None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
107 if self.xDefault != None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
108 x = self.xDefault
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
109 else:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
110 raise Exception("Error! Transcript %s do not have the x-tag %s\n" % (transcript, self.x))
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
111 if self.y != None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
112 if y == None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
113 if self.yDefault != None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
114 y = self.yDefault
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
115 else:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
116 raise Exception("Error! Transcript %s do not have the y-tag %s\n" % (transcript, self.y))
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
117 if self.z != None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
118 if z == None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
119 if self.zDefault != None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
120 z = self.zDefault
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
121 else:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
122 raise Exception("Error! Transcript %s do not have the z-tag %s\n" % (transcript, self.z))
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
123 x = float(x)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
124 if self.y != None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
125 y = float(y)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
126 if self.z != None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
127 z = float(z)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
128 return (x, y, z)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
129
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
130 def correctPointsToBarplot(self, line):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
131 minValue = int(math.floor(min(line.keys())))
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
132 maxValue = int(math.ceil(max(line.keys())))
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
133 step = (maxValue - minValue) / self.nbBars
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
134 values = dict([i * step + minValue, 0] for i in range(0, self.nbBars))
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
135 top = (self.nbBars - 1) * step + minValue
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
136 for key, value in line.iteritems():
46
169d364ddd91 Uploaded
m-zytnicki
parents: 38
diff changeset
137 newKey = min(top, int(math.floor((key - minValue) / float(maxValue - minValue) * self.nbBars)) * step + minValue)
38
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
138 values[newKey] += value
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
139 return values
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
140
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
141 def parseFile(self):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
142 line = {}
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
143 heatLine = {}
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
144
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
145 cpt = 1
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
146 for transcript in self.parser.getIterator():
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
147 x, y, z = self.getValues(transcript)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
148 name = transcript.name
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
149 if name == "unnamed transcript":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
150 name = "transcript %d" % (cpt)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
151 cpt += 1
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
152 if self.shape in ("points", "heatPoints"):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
153 line[name] = (x, y)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
154 if self.shape == "heatPoints":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
155 heatLine[name] = z
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
156 if self.shape == "line":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
157 line[x] = y
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
158 if self.shape == "barplot":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
159 line[x] = line.get(x, 0) + 1
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
160 if self.shape == "barplot":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
161 line = self.correctPointsToBarplot(line)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
162 self.plotter.setXLabel(self.x)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
163 if self.y != None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
164 self.plotter.setYLabel(self.y)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
165 else:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
166 self.plotter.setYLabel("Count")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
167 self.plotter.addLine(line)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
168 if self.shape == "heatPoints":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
169 self.plotter.addHeatLine(heatLine)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
170 self.plotter.plot()
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
171
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
172 def close(self):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
173 if self.regression:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
174 print self.plotter.getCorrelationData()
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
175 if self.shape == "points":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
176 rho = self.plotter.getSpearmanRho()
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
177 if rho == None:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
178 print "Cannot compute Spearman rho."
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
179 else:
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
180 print "Spearman rho: %f" % (rho)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
181
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
182 def run(self):
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
183 self.createPlotter()
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
184 self.parseFile()
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
185 self.close()
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
186
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
187
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
188 if __name__ == "__main__":
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
189
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
190 # parse command line
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
191 description = "Plot v1.0.2: Plot some information from a list of transcripts. [Category: Visualization]"
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
192
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
193 parser = OptionParser(description = description)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
194 parser.add_option("-i", "--input", dest="inputFileName", action="store", type="string", help="input file [compulsory] [format: file in transcript format given by -f]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
195 parser.add_option("-f", "--format", dest="format", action="store", type="string", help="format of the input [compulsory] [format: transcript file format]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
196 parser.add_option("-x", "--x", dest="x", action="store", type="string", help="tag for the x value [format: string]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
197 parser.add_option("-y", "--y", dest="y", action="store", type="string", help="tag for the y value [format: string]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
198 parser.add_option("-z", "--z", dest="z", action="store", default=None, type="string", help="tag for the z value [format: string]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
199 parser.add_option("-X", "--xDefault", dest="xDefault", action="store", default=None, type="float", help="value for x when tag is not present [format: float]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
200 parser.add_option("-Y", "--yDefault", dest="yDefault", action="store", default=None, type="float", help="value for y when tag is not present [format: float]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
201 parser.add_option("-Z", "--zDefault", dest="zDefault", action="store", default=None, type="float", help="value for z when tag is not present [format: float]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
202 parser.add_option("-o", "--output", dest="outputFileName", action="store", type="string", help="output file names [format: output file in PNG format]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
203 parser.add_option("-s", "--shape", dest="shape", action="store", default="barplot", type="string", help="shape of the plot [format: choice (barplot, line, points, heatPoints)]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
204 parser.add_option("-n", "--nbBars", dest="nbBars", action="store", default=2, type="int", help="number of bars in barplot [format: int]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
205 parser.add_option("-k", "--keep", dest="keep", action="store_true", default=False, help="keep temporary files [format: bool]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
206 parser.add_option("-r", "--regression", dest="regression", action="store_true", default=False, help="plot regression line (in 'points' format) [format: bool]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
207 parser.add_option("-l", "--log", dest="log", action="store", default="y", type="string", help="use log on x- or y-axis (write 'x', 'y' or 'xy') [format: string]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
208 parser.add_option("-v", "--verbosity", dest="verbosity", action="store", default=1, type="int", help="trace level [format: int]")
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
209 (options, args) = parser.parse_args()
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
210
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
211 plot = Plot(options.verbosity)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
212 plot.setInputFileName(options.inputFileName, options.format)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
213 plot.setOutputFileName(options.outputFileName)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
214 plot.setXData(options.x, options.xDefault)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
215 plot.setYData(options.y, options.yDefault)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
216 plot.setZData(options.z, options.zDefault)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
217 plot.setShape(options.shape)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
218 plot.setNbBars(options.nbBars)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
219 plot.setRegression(options.regression)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
220 plot.setLog(options.log)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
221 plot.keepTmpFiles(options.keep)
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
222 plot.run()
2c0c0a89fad7 Uploaded
m-zytnicki
parents:
diff changeset
223