Mercurial > repos > jjohnson > bed_to_protein_map
annotate bed_to_protein_map.py @ 0:4702e7f629bb draft default tip
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
author | jjohnson |
---|---|
date | Mon, 20 Nov 2017 14:58:18 -0500 |
parents | |
children |
rev | line source |
---|---|
0
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
1 #!/usr/bin/env python |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
2 """ |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
3 """ |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
4 import sys |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
5 import os.path |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
6 import optparse |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
7 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
8 """ |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
9 X 276352 291629 ENST00000430923 20 + 284187 291629 80,80,80 5 42,148,137,129,131 0,7814,12380,14295,15146 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
10 X 304749 318819 ENST00000326153 20 - 305073 318787 80,80,80 10 448,153,149,209,159,68,131,71,138,381 0,2610,2982,6669,8016,9400,10140,10479,12164,13689 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
11 grep ENST bed_to_protein_map.py | grep -v grep | ./bed_to_protein_map.py |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
12 """ |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
13 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
14 def __main__(): |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
15 #Parse Command Line |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
16 parser = optparse.OptionParser() |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
17 #I/O |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
18 parser.add_option( '-i', '--input', dest='input', default=None, help='Tabular file with peptide_sequence column' ) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
19 parser.add_option( '-c', '--column', type='int', dest='column', default=1, help='column ordinal with Ensembl transcript ID' ) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
20 parser.add_option( '-g', '--gtf', dest='gtf', default=None, help='GTF gene model file. Used to annotate NSJ peptide entries.') |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
21 parser.add_option( '-2', '--twobit', dest='twobit', default=None, help='Reference genome in UCSC twobit format') |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
22 parser.add_option( '-C', '--coding', dest='coding', action='store_true', default=False, help='Output coding BED line') |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
23 parser.add_option( '-o', '--output', dest='output', default=None, help='The output bed (else write to stdout)' ) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
24 parser.add_option( '-s', '--sqlitedb', dest='sqlitedb', default=None, help='The sqlitedb' ) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
25 parser.add_option( '--debug', dest='debug', action='store_true', default=False, help='Print debugging messages') |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
26 (options, args) = parser.parse_args() |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
27 ##INPUTS## |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
28 if options.input != None: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
29 try: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
30 inputPath = os.path.abspath(options.input) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
31 inputFile = open(inputPath, 'r') |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
32 except Exception, e: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
33 print >> sys.stderr, "failed: %s" % e |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
34 exit(2) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
35 else: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
36 inputFile = sys.stdin |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
37 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
38 if options.output != None: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
39 try: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
40 outputPath = os.path.abspath(options.output) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
41 outputFile = open(outputPath, 'w') |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
42 except Exception, e: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
43 print >> sys.stderr, "failed: %s" % e |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
44 exit(3) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
45 else: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
46 outputFile = sys.stdout |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
47 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
48 dbFile = None |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
49 if options.sqlitedb != None: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
50 try: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
51 dbPath = os.path.abspath(options.sqlitedb) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
52 dbFile = open(dbPath, 'w') |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
53 except Exception, e: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
54 print >> sys.stderr, "failed: %s" % e |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
55 exit(3) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
56 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
57 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
58 try: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
59 for linenum,line in enumerate(inputFile): |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
60 if options.debug: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
61 print >> sys.stderr, "%d: %s\n" % (linenum,line) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
62 if line.startswith('#'): |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
63 continue |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
64 if line.strip() == '': |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
65 continue |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
66 fields = line.rstrip('\r\n').split('\t') |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
67 if len(fields) < 12: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
68 print >> sys.stderr, "%d: %s\n" % (linenum,line) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
69 continue |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
70 (chrom,_chromStart,_chromEnd,name,score,strand,_thickStart,_thickEnd,itemRgb,_blockCount,blockSizes,blockStarts) = fields[0:12] |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
71 chromStart = int(_chromStart) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
72 chromEnd = int(_chromEnd) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
73 thickStart = int(_thickStart) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
74 thickEnd = int(_thickEnd) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
75 blockCount = int(_blockCount) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
76 blockSizes = [int(x) for x in blockSizes.split(',')] |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
77 blockStarts = [int(x) for x in blockStarts.split(',')] |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
78 if strand == '+': |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
79 cds_start = 0 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
80 cds_end = 0 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
81 for i in range(blockCount): |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
82 start = chromStart + blockStarts[i] |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
83 end = start + blockSizes[i] |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
84 if end < thickStart: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
85 continue |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
86 if start > thickEnd: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
87 break |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
88 if start < thickStart: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
89 start = thickStart |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
90 if end > thickEnd: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
91 end = thickEnd |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
92 cds_end = cds_start + (end - start) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
93 ##dbFile.write('%s\t%s\t%d\t%d\t%s\t%d\t%d\n' % (name,chrom,start,end,strand,cds_start,cds_end)) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
94 outputFile.write('%s\t%s\t%d\t%d\t%s\t%d\t%d\n' % (name,chrom,start,end,strand,cds_start,cds_end)) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
95 cds_start = cds_end |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
96 elif strand == '-': |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
97 cds_start = 0 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
98 cds_end = 0 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
99 for i in reversed(range(blockCount)): |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
100 start = chromStart + blockStarts[i] |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
101 end = start + blockSizes[i] |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
102 if end < thickStart: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
103 break |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
104 if start > thickEnd: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
105 continue |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
106 if start < thickStart: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
107 start = thickStart |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
108 if end > thickEnd: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
109 end = thickEnd |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
110 cds_end = cds_start + (end - start) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
111 outputFile.write('%s\t%s\t%d\t%d\t%s\t%d\t%d\n' % (name,chrom,start,end,strand,cds_start,cds_end)) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
112 cds_start = cds_end |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
113 pass |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
114 except Exception, e: |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
115 print >> sys.stderr, "failed: %s" % e |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
116 exit(1) |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
117 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
118 |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
119 if __name__ == "__main__" : __main__() |
4702e7f629bb
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/bed_to_protein_map commit 38e8d0e983c3aa314e13bdc9ea98f4a728b7772c-dirty
jjohnson
parents:
diff
changeset
|
120 |