comparison small_rna_maps.py @ 31:f82badb66c34 draft

"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit 7e2694ed482bd75245793e2cfe0b5277233047c3"
author artbio
date Sun, 06 Oct 2019 21:11:19 -0400
parents 183bf49fe77c
children f2e7ad3058e8
comparison
equal deleted inserted replaced
30:183bf49fe77c 31:f82badb66c34
235 coverage_dictionary = dict() 235 coverage_dictionary = dict()
236 for chrom in self.chromosomes: 236 for chrom in self.chromosomes:
237 coverage_dictionary[(chrom, 1, 'F')] = 0 237 coverage_dictionary[(chrom, 1, 'F')] = 0
238 coverage_dictionary[(chrom, self.chromosomes[chrom], 'F')] = 0 238 coverage_dictionary[(chrom, self.chromosomes[chrom], 'F')] = 0
239 for read in self.bam_object.fetch(chrom): 239 for read in self.bam_object.fetch(chrom):
240 positions = read.positions # a list of covered positions 240 positions = sorted(read.positions) # list of covered positions
241 # add flanking position at 0 to join
242 # the base line when plotting graph
243 flanking = []
244 for i in range(len(positions)-1):
245 right = positions[i+1]
246 left = positions[i]
247 if positions[i+1] - positions[i] > 2:
248 flanking.insert(0, right-1)
249 flanking.insert(0, left+1)
250 elif positions[i+1] - positions[i] == 2:
251 flanking.insert(0, left+1)
252 positions = sorted(positions + flanking)
253 if positions[0] > 0:
254 positions.insert(0, positions[0]-1)
255 if positions[-1] < self.chromosomes[chrom] - 1:
256 positions.append(positions[-1]+1)
241 for pos in positions: 257 for pos in positions:
242 if not map_dictionary[(chrom, pos+1, 'F')]: 258 if not map_dictionary[(chrom, pos+1, 'F')]:
243 map_dictionary[(chrom, pos+1, 'F')] = [] 259 map_dictionary[(chrom, pos+1, 'F')] = []
244 for key in map_dictionary: 260 for key in map_dictionary:
245 if 'R' in key: 261 if 'R' in key: