Mercurial > repos > fubar > microsatbed
annotate find_str.py @ 28:4cb6cc083620 draft
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
| author | fubar | 
|---|---|
| date | Fri, 19 Jul 2024 22:32:44 +0000 | 
| parents | 26e9575c2c83 | 
| children | efc775ab30fe | 
| rev | line source | 
|---|---|
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 1 import argparse | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 2 import shutil | 
| 26 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 3 import subprocess | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 4 | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 5 import pybigtools | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 6 import pytrf # 1.3.0 | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 7 from pyfastx import Fastx # 0.5.2 | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 8 | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 9 """ | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 10 Allows all STR or those for a subset of motifs to be written to a bed file | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 11 Designed to build some of the microsatellite tracks from https://github.com/arangrhie/T2T-Polish/tree/master/pattern for the VGP. | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 12 """ | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 13 | 
| 24 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 14 | 
| 23 
45f690db0eaf
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
20diff
changeset | 15 def getDensity(name, bed, chrlen, winwidth): | 
| 24 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 16 nwin = int(chrlen / winwidth) | 
| 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 17 d = [0.0 for x in range(nwin + 1)] | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 18 for b in bed: | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 19 nt = b[5] | 
| 24 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 20 bin = int(b[1] / winwidth) | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 21 d[bin] += nt | 
| 24 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 22 dw = [ | 
| 26 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 23 (name, (x * winwidth), ((x + 1) * winwidth) - 1, float(d[x])) | 
| 24 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 24 for x in range(nwin + 1) | 
| 26 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 25 if (x + 1) * winwidth <= chrlen | 
| 24 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 26 ] | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 27 return dw | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 28 | 
| 24 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 29 | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 30 def write_ssrs(args): | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 31 """ | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 32 The integers in the call change the minimum repeats for mono-, di-, tri-, tetra-, penta-, hexa-nucleotide repeats | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 33 ssrs = pytrf.STRFinder(name, seq, 10, 6, 4, 3, 3, 3) | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 34 NOTE: Dinucleotides GA and AG are reported separately by https://github.com/marbl/seqrequester. | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 35 The reversed pair STRs are about as common in the documentation sample. | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 36 Sequence read bias might be influenced by GC density or some other specific motif. | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 37 """ | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 38 bed = [] | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 39 wig = [] | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 40 chrlens = {} | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 41 specific = None | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 42 if args.specific: | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 43 specific = args.specific.upper().split(",") | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 44 fa = Fastx(args.fasta, uppercase=True) | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 45 for name, seq in fa: | 
| 25 
8d0b8a75350f
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
24diff
changeset | 46 chrlen = len(seq) | 
| 
8d0b8a75350f
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
24diff
changeset | 47 chrlens[name] = chrlen | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 48 cbed = [] | 
| 19 
db5523378e5c
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
17diff
changeset | 49 for ssr in pytrf.STRFinder( | 
| 24 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 50 name, | 
| 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 51 seq, | 
| 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 52 args.monomin, | 
| 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 53 args.dimin, | 
| 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 54 args.trimin, | 
| 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 55 args.tetramin, | 
| 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 56 args.pentamin, | 
| 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 57 args.hexamin, | 
| 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 58 ): | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 59 row = ( | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 60 ssr.chrom, | 
| 19 
db5523378e5c
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
17diff
changeset | 61 ssr.start, | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 62 ssr.end, | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 63 ssr.motif, | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 64 ssr.repeat, | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 65 ssr.length, | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 66 ) | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 67 # pytrf reports a 1 based start position so start-1 fixes the bed interval lengths | 
| 19 
db5523378e5c
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
17diff
changeset | 68 if args.specific and ssr.motif in specific: | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 69 cbed.append(row) | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 70 elif args.mono and len(ssr.motif) == 1: | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 71 cbed.append(row) | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 72 elif args.di and len(ssr.motif) == 2: | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 73 cbed.append(row) | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 74 elif args.tri and len(ssr.motif) == 3: | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 75 cbed.append(row) | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 76 elif args.tetra and len(ssr.motif) == 4: | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 77 cbed.append(row) | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 78 elif args.penta and len(ssr.motif) == 5: | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 79 cbed.append(row) | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 80 elif args.hexa and len(ssr.motif) == 6: | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 81 cbed.append(row) | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 82 if args.bigwig: | 
| 24 
94c5f834c0cc
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
23diff
changeset | 83 w = getDensity(name, cbed, chrlen, args.winwidth) | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 84 wig += w | 
| 26 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 85 bed += cbed | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 86 if args.bigwig: | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 87 wig.sort() | 
| 26 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 88 bedg = ['%s %d %d %.3f' % x for x in wig] | 
| 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 89 # bedg.insert(0,'track type=bedGraph') https://genomebrowser.wustl.edu/goldenPath/help/bigWig.html | 
| 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 90 with open("temp.bedg", "w") as bw: | 
| 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 91 bw.write('\n'.join(bedg)) | 
| 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 92 chroms = ["%s\t%s" % (x, chrlens[x]) for x in chrlens.keys()] | 
| 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 93 with open("temp.chromlen", "w") as cl: | 
| 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 94 cl.write('\n'.join(chroms)) | 
| 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 95 cmd = ["bedGraphToBigWig", "temp.bedg", "temp.chromlen", "temp.bw" ] | 
| 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 96 subprocess.run(cmd) | 
| 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 97 #bw = pybigtools.open("temp.bw", "w") | 
| 
26e9575c2c83
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
25diff
changeset | 98 #bw.write(chrlens, wig) | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 99 shutil.move("temp.bw", args.bed) | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 100 else: | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 101 bed.sort() | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 102 obed = ["%s\t%d\t%d\t%s_%d\t%d" % x for x in bed] | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 103 with open(args.bed, "w") as outbed: | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 104 outbed.write("\n".join(obed)) | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 105 outbed.write("\n") | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 106 | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 107 | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 108 if __name__ == "__main__": | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 109 parser = argparse.ArgumentParser() | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 110 a = parser.add_argument | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 111 a("--di", action="store_true") | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 112 a("--tri", action="store_true") | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 113 a("--tetra", action="store_true") | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 114 a("--penta", action="store_true") | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 115 a("--hexa", action="store_true") | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 116 a("--mono", action="store_true") | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 117 a("--dimin", default=2, type=int) | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 118 a("--trimin", default=2, type=int) | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 119 a("--tetramin", default=2, type=int) | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 120 a("--pentamin", default=2, type=int) | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 121 a("--hexamin", default=2, type=int) | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 122 a("--monomin", default=2, type=int) | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 123 a("-f", "--fasta", default="humsamp.fa") | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 124 a("-b", "--bed", default="humsamp.bed") | 
| 20 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 125 a("--bigwig", action="store_true") | 
| 
410144c7b2d6
planemo upload for repository https://github.com/fubar2/microsatbed commit d952bc313f408735456747c3d33e09a3170c8f59-dirty
 fubar parents: 
19diff
changeset | 126 a("--winwidth", default=128, type=int) | 
| 1 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 127 a("--specific", default=None) | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 128 a("--minreps", default=2, type=int) | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 129 args = parser.parse_args() | 
| 
1085e094cf5f
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/microsatbed commit 7ceb6658309a7ababe622b5d92e729e5470e22f0-dirty
 fubar parents: diff
changeset | 130 write_ssrs(args) | 
