annotate SMART/Java/Python/getSizes.py @ 18:94ab73e8a190

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents 769e306b7933
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 #! /usr/bin/env python
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 # Copyright INRA-URGI 2009-2010
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 # This software is governed by the CeCILL license under French law and
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 # abiding by the rules of distribution of free software. You can use,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 # modify and/ or redistribute the software under the terms of the CeCILL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 # license as circulated by CEA, CNRS and INRIA at the following URL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 # "http://www.cecill.info".
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 # As a counterpart to the access to the source code and rights to copy,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 # modify and redistribute granted by the license, users are provided only
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 # with a limited warranty and the software's author, the holder of the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 # economic rights, and the successive licensors have only limited
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 # liability.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 # In this respect, the user's attention is drawn to the risks associated
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 # with loading, using, modifying and/or developing or reproducing the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 # software by the user in light of its specific status of free software,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 # that may mean that it is complicated to manipulate, and that also
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 # therefore means that it is reserved for developers and experienced
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 # professionals having in-depth computer knowledge. Users are therefore
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 # encouraged to load and test the software's suitability as regards their
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 # requirements in conditions enabling the security of their systems and/or
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 # data to be ensured and, more generally, to use and operate it in the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 # same conditions as regards security.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 # The fact that you are presently reading this means that you have had
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 # knowledge of the CeCILL license and that you accept its terms.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 import os, sys
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 from optparse import OptionParser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 from commons.core.parsing.FastaParser import FastaParser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 from commons.core.parsing.FastqParser import FastqParser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 from SMART.Java.Python.structure.TranscriptContainer import TranscriptContainer
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 from commons.core.parsing.GffParser import GffParser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 from SMART.Java.Python.misc.Progress import Progress
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 from SMART.Java.Python.misc.RPlotter import RPlotter
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 from SMART.Java.Python.misc import Utils
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 from commons.core.LoggerFactory import LoggerFactory
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 from commons.core.utils.RepetOptionParser import RepetOptionParser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44 LOG_DEPTH = "smart"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 class GetSizes(object):
18
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
47
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
48 def __init__(self, inFileName = None, inFormat=None, outFileName = None, query=None,xMax=None, xMin=None, verbosity = 0):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
49 self.inFileName = inFileName
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
50 self.inFormat= inFormat
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
51 self.outFileName = outFileName
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
52 self.query = query
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
53 self.xMax = xMax
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
54 self.xMin = xMin
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
55 self.xLab = "Size"
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
56 self.yLab = "# reads"
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
57 self.barplot = False
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
58 self._verbosity = verbosity
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
59 self.parser = None
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
60 self._log = LoggerFactory.createLogger("%s.%s" % (LOG_DEPTH, self.__class__.__name__), self._verbosity)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
61
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
62 def setAttributesFromCmdLine(self):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
63 description = "Usage: getSizes.py [options]\n\nGet Sizes v1.0.2: Get the sizes of a set of genomic coordinates. [Category: Visualization]\n"
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
64 epilog = ""
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
65 parser = RepetOptionParser(description = description, epilog = epilog)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
66 parser.add_option("-i", "--input", dest="inputFileName", action="store", default=None, type="string", help="input file [compulsory] [format: file in transcript or sequence format given by -f]")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
67 parser.add_option("-f", "--format", dest="format", action="store", default=None, type="string", help="format of the input [compulsory] [format: transcript or sequence file format]")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
68 parser.add_option("-q", "--query", dest="query", action="store", default=None, type="string", help="type to mesure [default: size] [format: choice (size, intron size, exon size, 1st exon size)]")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
69 parser.add_option("-o", "--output", dest="outputFileName", action="store", default=None, type="string", help="output file [format: output file in PNG format]")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
70 parser.add_option("-x", "--xMax", dest="xMax", action="store", default=None, type="int", help="maximum value on the x-axis to plot [format: int]")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
71 parser.add_option("-X", "--xMin", dest="xMin", action="store", default=None, type="int", help="minimum value on the x-axis to plot [format: int]")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
72 parser.add_option("-v", "--verbosity", dest="verbosity", action="store", default=1, type="int", help="trace level [format: int]")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
73 parser.add_option("-a", "--xLabel", dest="xLab", action="store", default="Size", type="string", help="x absis label name [format: string] [default: Size]")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
74 parser.add_option("-b", "--yLabel", dest="yLab", action="store", default="# reads", type="string", help="y absis label name [format: string] [default: Reads]")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
75 parser.add_option("-B", "--barplot", dest="barplot", action="store_true", default=False, help="use barplot representation [format: bool] [default: false]")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
76 options = parser.parse_args()[0]
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
77 self._setAttributesFromOptions(options)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
78
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
79 def _setAttributesFromOptions(self, options):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
80 self.setInFileName(options.inputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
81 self.setInFormat(options.format)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
82 self.setQuery(options.query)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
83 self.setOutFileName(options.outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
84 self.setXMax(options.xMax)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
85 self.setXMin(options.xMin)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
86 self.setxLab(options.xLab)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
87 self.setyLab(options.yLab)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
88 self.setBarplot(options.barplot)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
89 self.setVerbosity(options.verbosity)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
90
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
91 def setInFileName(self, inputFileName):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
92 self.inFileName = inputFileName
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
93
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
94 def setInFormat(self, inFormat):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
95 self.inFormat = inFormat
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
96
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
97 def setQuery(self, query):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
98 self.query = query
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
99
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
100 def setOutFileName(self, outFileName):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
101 self.outFileName = outFileName
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
102
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
103 def setXMax(self, xMax):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
104 self.xMax = xMax
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
105
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
106 def setXMin(self, xMin):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
107 self.xMin = xMin
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
108
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
109 def setxLab(self, xLab):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
110 self.xLab = xLab
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
111
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
112 def setyLab(self, yLab):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
113 self.yLab = yLab
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
114
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
115 def setBarplot(self, barplot):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
116 self.barplot = barplot
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
117
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
118 def setVerbosity(self, verbosity):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
119 self._verbosity = verbosity
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
120
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
121 def _checkOptions(self):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
122 if self.inFileName == None:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
123 self._logAndRaise("ERROR: Missing input file name")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
124 if self.inFormat == "fasta":
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
125 self.parser = FastaParser(self.inFileName, self._verbosity)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
126 elif self.inFormat == "fastq":
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
127 self.parser = FastqParser(self.inFileName, self._verbosity)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
128 else:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
129 self.parser = TranscriptContainer(self.inFileName, self.inFormat, self._verbosity)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
130
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
131 def _logAndRaise(self, errorMsg):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
132 self._log.error(errorMsg)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
133 raise Exception(errorMsg)
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134
18
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
135 def run(self):
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
136 LoggerFactory.setLevel(self._log, self._verbosity)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
137 self._checkOptions()
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
138 self._log.info("START getsizes")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
139 self._log.debug("Input file name: %s" % self.inFileName)
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140
18
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
141 nbItems = self.parser.getNbItems()
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
142 self._log.info( "%i items found" % (nbItems))
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
143
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
144 # treat items
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
145 progress = Progress(nbItems, "Analyzing sequences of %s" % (self.inFileName), self._verbosity)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
146 sizes = {}
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
147 minimum = 1000000000000
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
148 maximum = 0
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
149 sum = 0
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
150 number = 0
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
151 nbSubItems = 0
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
152 for item in self.parser.getIterator():
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
153 items = []
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
154 if self.query == "exon":
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
155 items = item.getExons()
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
156 elif self.query == "exon1":
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
157 if len(item.getExons()) > 1:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
158 item.sortExons()
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
159 items = [item.getExons()[0]]
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
160 elif self.query == "intron":
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
161 items = item.getIntrons()
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
162 else:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
163 items = [item, ]
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
164
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
165 for thisItem in items:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
166 try:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
167 nbElements = int(float(thisItem.getTagValue("nbElements")))
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
168 if nbElements == None:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
169 nbElements = 1
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
170 except:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
171 nbElements = 1
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
172 size = thisItem.getSize()
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
173 minimum = min(minimum, size)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
174 maximum = max(maximum, size)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
175
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
176 if size not in sizes:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
177 sizes[size] = nbElements
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
178 else:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
179 sizes[size] += nbElements
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
180 sum += size
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
181 nbSubItems += nbElements
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
182 number += 1
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
183 progress.inc()
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
184 progress.done()
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185
18
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
186 if self.outFileName != None:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
187 plotter = RPlotter(self.outFileName, self._verbosity)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
188 plotter.setFill(0)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
189 plotter.setMinimumX(self.xMin)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
190 plotter.setMaximumX(self.xMax)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
191 plotter.setXLabel(self.xLab)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
192 plotter.setYLabel(self.yLab)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
193 plotter.setBarplot(self.barplot)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
194 plotter.addLine(sizes)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
195 plotter.plot()
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
196
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
197 if nbSubItems == 0:
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
198 self._logAndRaise("No item found")
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
199
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
200 self.items = number
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
201 self.subItems = nbSubItems
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
202 self.nucleotides = sum
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
203 self.minAvgMedMax = Utils.getMinAvgMedMax(sizes)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
204
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
205 print "%d items" % (number)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
206 print "%d sub-items" % (nbSubItems)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
207 print "%d nucleotides" % (sum)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
208 print "min/avg/med/max transcripts: %d/%.2f/%.1f/%d" % Utils.getMinAvgMedMax(sizes)
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
209
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
210 self._log.info("END getsizes")
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213 if __name__ == "__main__":
18
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
214 iGetSizes = GetSizes()
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
215 iGetSizes.setAttributesFromCmdLine()
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
216 iGetSizes.run()
94ab73e8a190 Uploaded
m-zytnicki
parents: 6
diff changeset
217
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 #TODO: add two more options!!!!!!