Mercurial > repos > drosofff > mi_rna_parser
comparison smRtools.py @ 5:59dfb33ca70e draft
Uploaded
author | drosofff |
---|---|
date | Mon, 23 Jun 2014 05:14:35 -0400 |
parents | 9f17e8fc1d28 |
children |
comparison
equal
deleted
inserted
replaced
4:ac8fd41b8c98 | 5:59dfb33ca70e |
---|---|
302 '''return a dictionary of number of reads by size (the keys)''' | 302 '''return a dictionary of number of reads by size (the keys)''' |
303 dicsize = {} | 303 dicsize = {} |
304 for offset in self.readDict: | 304 for offset in self.readDict: |
305 for size in self.readDict[offset]: | 305 for size in self.readDict[offset]: |
306 dicsize[size] = dicsize.get(size, 0) + 1 | 306 dicsize[size] = dicsize.get(size, 0) + 1 |
307 for offset in range (min(dicsize.keys()), max(dicsize.keys())+1): | |
308 dicsize[size] = dicsize.get(size, 0) # to fill offsets with null values | |
307 return dicsize | 309 return dicsize |
308 | 310 |
309 def statsizes (self, upstream_coord=None, downstream_coord=None): | 311 def statsizes (self, upstream_coord=None, downstream_coord=None): |
310 ''' migration to memory saving by specifying possible subcoordinates | 312 ''' migration to memory saving by specifying possible subcoordinates |
311 see the readcount method for further discussion''' | 313 see the readcount method for further discussion''' |
391 if readmap[offset][0] != 0: | 393 if readmap[offset][0] != 0: |
392 mylist.append("%s\t%s\t%s\t%s" % (self.gene, offset, -readmap[offset][0], "R") ) | 394 mylist.append("%s\t%s\t%s\t%s" % (self.gene, offset, -readmap[offset][0], "R") ) |
393 return mylist | 395 return mylist |
394 | 396 |
395 def readcoverage (self, upstream_coord=None, downstream_coord=None, windowName=None): | 397 def readcoverage (self, upstream_coord=None, downstream_coord=None, windowName=None): |
396 '''This method has not been tested yet 15-11-2013''' | 398 '''Use by MirParser tool''' |
397 upstream_coord = upstream_coord or 1 | 399 upstream_coord = upstream_coord or 1 |
398 downstream_coord = downstream_coord or self.size | 400 downstream_coord = downstream_coord or self.size |
399 windowName = windowName or "%s_%s_%s" % (self.gene, upstream_coord, downstream_coord) | 401 windowName = windowName or "%s_%s_%s" % (self.gene, upstream_coord, downstream_coord) |
400 forORrev_coverage = dict ([(i,0) for i in xrange(1, downstream_coord-upstream_coord+1)]) | 402 forORrev_coverage = dict ([(i,0) for i in xrange(1, downstream_coord-upstream_coord+1)]) |
401 totalforward = self.readcount(upstream_coord=upstream_coord, downstream_coord=downstream_coord, polarity="forward") | 403 totalforward = self.readcount(upstream_coord=upstream_coord, downstream_coord=downstream_coord, polarity="forward") |