comparison find_str.py @ 25:8d0b8a75350f draft

planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
author fubar
date Fri, 19 Jul 2024 06:41:18 +0000
parents 94c5f834c0cc
children 26e9575c2c83
comparison
equal deleted inserted replaced
24:94c5f834c0cc 25:8d0b8a75350f
19 bin = int(b[1] / winwidth) 19 bin = int(b[1] / winwidth)
20 d[bin] += nt 20 d[bin] += nt
21 dw = [ 21 dw = [
22 (name, (x * winwidth)+1, (x + 1) * winwidth, float(d[x])) 22 (name, (x * winwidth)+1, (x + 1) * winwidth, float(d[x]))
23 for x in range(nwin + 1) 23 for x in range(nwin + 1)
24 if (x + 1) * winwidth <= chrlen 24 if (x + 1) * winwidth <= chrlen - 1
25 ] 25 ]
26 return dw 26 return dw
27 27
28 28
29 def write_ssrs(args): 29 def write_ssrs(args):
40 specific = None 40 specific = None
41 if args.specific: 41 if args.specific:
42 specific = args.specific.upper().split(",") 42 specific = args.specific.upper().split(",")
43 fa = Fastx(args.fasta, uppercase=True) 43 fa = Fastx(args.fasta, uppercase=True)
44 for name, seq in fa: 44 for name, seq in fa:
45 chrlen = len(seq)
46 chrlens[name] = chrlen
45 cbed = [] 47 cbed = []
46 for ssr in pytrf.STRFinder( 48 for ssr in pytrf.STRFinder(
47 name, 49 name,
48 seq, 50 seq,
49 args.monomin, 51 args.monomin,
76 cbed.append(row) 78 cbed.append(row)
77 elif args.hexa and len(ssr.motif) == 6: 79 elif args.hexa and len(ssr.motif) == 6:
78 cbed.append(row) 80 cbed.append(row)
79 bed += cbed 81 bed += cbed
80 if args.bigwig: 82 if args.bigwig:
81 chrlen = len(seq)
82 chrlens[name] = chrlen
83 w = getDensity(name, cbed, chrlen, args.winwidth) 83 w = getDensity(name, cbed, chrlen, args.winwidth)
84 wig += w 84 wig += w
85 if args.bigwig: 85 if args.bigwig:
86 wig.sort() 86 wig.sort()
87 bw = pybigtools.open("temp.bw", "w") 87 bw = pybigtools.open("temp.bw", "w")
88 bw.write(chrlens, wig) 88 bw.write(chrlens, wig)
89 bw.close()
90 shutil.move("temp.bw", args.bed) 89 shutil.move("temp.bw", args.bed)
91 else: 90 else:
92 bed.sort() 91 bed.sort()
93 obed = ["%s\t%d\t%d\t%s_%d\t%d" % x for x in bed] 92 obed = ["%s\t%d\t%d\t%s_%d\t%d" % x for x in bed]
94 with open(args.bed, "w") as outbed: 93 with open(args.bed, "w") as outbed: