comparison small_rna_maps.py @ 29:8b5695592784 draft

"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit c3d728b98db4987821feae40952d9797c97eaf5a"
author artbio
date Fri, 04 Oct 2019 04:33:53 -0400
parents 14adf24603b6
children 183bf49fe77c
comparison
equal deleted inserted replaced
28:14adf24603b6 29:8b5695592784
241 for pos in positions: 241 for pos in positions:
242 if not map_dictionary[(chrom, pos+1, 'F')]: 242 if not map_dictionary[(chrom, pos+1, 'F')]:
243 map_dictionary[(chrom, pos+1, 'F')] = [] 243 map_dictionary[(chrom, pos+1, 'F')] = []
244 for key in map_dictionary: 244 for key in map_dictionary:
245 coverage = self.bam_object.count_coverage( 245 coverage = self.bam_object.count_coverage(
246 reference=key[0], 246 contig=key[0],
247 start=key[1]-1, 247 start=key[1]-1,
248 end=key[1], 248 stop=key[1],
249 quality_threshold=quality) 249 quality_threshold=quality)
250 """ Add the 4 coverage values """ 250 """ Add the 4 coverage values """
251 coverage = [sum(x) for x in zip(*coverage)] 251 coverage = [sum(x) for x in zip(*coverage)]
252 coverage_dictionary[key] = coverage[0] 252 coverage_dictionary[key] = coverage[0]
253 self.write_table(coverage_dictionary, out) 253 self.write_table(coverage_dictionary, out)
296 for size in sizes: 296 for size in sizes:
297 strandness[polarity] += sizedic[chrom][polarity][size] 297 strandness[polarity] += sizedic[chrom][polarity][size]
298 sizeness[size] += sizedic[chrom][polarity][size] 298 sizeness[size] += sizedic[chrom][polarity][size]
299 Strandbias = strandness['F'] + strandness['R'] 299 Strandbias = strandness['F'] + strandness['R']
300 if Strandbias: 300 if Strandbias:
301 Strandbias = strandness['F'] / float(Strandbias) 301 Strandbias = round(strandness['F'] / float(Strandbias), 2)
302 else: 302 else:
303 Strandbias = 2 303 Strandbias = 2
304 Mean = numpy.mean(sizeness.values()) 304 Mean = numpy.mean(sizeness.values())
305 StDev = numpy.std(sizeness.values()) 305 StDev = numpy.std(sizeness.values())
306 for size in sizeness: 306 for size in sizeness:
311 for polarity in sorted(sizedic[chrom]): 311 for polarity in sorted(sizedic[chrom]):
312 for size in sizes: 312 for size in sizes:
313 try: 313 try:
314 line = [self.sample_name, chrom, polarity, size, 314 line = [self.sample_name, chrom, polarity, size,
315 sizedic[chrom][polarity][size], 315 sizedic[chrom][polarity][size],
316 Strandbias, sizeness[size]] 316 Strandbias, round(sizeness[size], 3)]
317 except KeyError: 317 except KeyError:
318 line = [self.sample_name, chrom, polarity, size, 0, 318 line = [self.sample_name, chrom, polarity, size, 0,
319 Strandbias, sizeness[size]] 319 Strandbias, round(sizeness[size], 3)]
320 line = [str(i) for i in line] 320 line = [str(i) for i in line]
321 out.write('\t'.join(line) + '\n') 321 out.write('\t'.join(line) + '\n')
322 322
323 def write_cluster_table(self, clustered_dic, out, bedpath): 323 def write_cluster_table(self, clustered_dic, out, bedpath):
324 ''' 324 '''