annotate translate_bed_sequences.py @ 2:4221664a2bd0 draft default tip

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
author galaxyp
date Tue, 07 Apr 2020 11:45:53 -0400
parents d723eb657f1d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
1 #!/usr/bin/env python
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
2 """
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
3 #
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
4 #------------------------------------------------------------------------------
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
5 # University of Minnesota
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
6 # Copyright 2014, Regents of the University of Minnesota
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
7 #------------------------------------------------------------------------------
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
8 # Author:
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
9 #
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
10 # James E Johnson
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
11 #
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
12 #------------------------------------------------------------------------------
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
13
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
14 Input: BED file (12 column) + 13th sequence column appended by extract_genomic_dna
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
15 Output: Fasta of 3-frame translations of the spliced sequence
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
16 """
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
17
2
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
18 import optparse
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
19 import os.path
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
20 import sys
0
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
21 import tempfile
2
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
22
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
23 from Bio.Seq import (
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
24 reverse_complement,
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
25 translate
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
26 )
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
27
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
28
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
29 class BedEntry(object):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
30 def __init__(self, line):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
31 self.line = line
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
32 try:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
33 fields = line.rstrip('\r\n').split('\t')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
34 (chrom, chromStart, chromEnd, name, score, strand, thickStart, thickEnd, itemRgb, blockCount, blockSizes, blockStarts) = fields[0:12]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
35 seq = fields[12] if len(fields) > 12 else None
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
36 self.chrom = chrom
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
37 self.chromStart = int(chromStart)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
38 self.chromEnd = int(chromEnd)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
39 self.name = name
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
40 self.score = int(score)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
41 self.strand = strand
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
42 self.thickStart = int(thickStart)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
43 self.thickEnd = int(thickEnd)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
44 self.itemRgb = itemRgb
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
45 self.blockCount = int(blockCount)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
46 self.blockSizes = [int(x) for x in blockSizes.split(',')]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
47 self.blockStarts = [int(x) for x in blockStarts.split(',')]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
48 self.seq = seq
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
49 except Exception as e:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
50 sys.stderr.write("Unable to read Bed entry %s\n" % e)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
51 exit(1)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
52
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
53 def __str__(self):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
54 return '%s\t%d\t%d\t%s\t%d\t%s\t%d\t%d\t%s\t%d\t%s\t%s%s' % (
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
55 self.chrom, self.chromStart, self.chromEnd, self.name, self.score, self.strand, self.thickStart, self.thickEnd, self.itemRgb, self.blockCount,
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
56 ','.join([str(x) for x in self.blockSizes]),
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
57 ','.join([str(x) for x in self.blockStarts]),
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
58 '\t%s' % self.seq if self.seq else '')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
59
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
60 def get_splice_junctions(self):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
61 splice_juncs = []
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
62 for i in range(self.blockCount - 1):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
63 splice_junc = "%s:%d_%d" % (self.chrom, self.chromStart + self.blockSizes[i], self.chromStart + self.blockStarts[i + 1])
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
64 splice_juncs.append(splice_junc)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
65 return splice_juncs
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
66
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
67 def get_exon_seqs(self):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
68 exons = []
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
69 for i in range(self.blockCount):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
70 # splice_junc = "%s:%d_%d" % (self.chrom, self.chromStart + self.blockSizes[i], self.chromStart + self.blockStarts[i+1])
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
71 exons.append(self.seq[self.blockStarts[i]:self.blockStarts[i] + self.blockSizes[i]])
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
72 if self.strand == '-': # reverse complement
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
73 exons.reverse()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
74 for i, s in enumerate(exons):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
75 exons[i] = reverse_complement(s)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
76 return exons
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
77
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
78 def get_spliced_seq(self):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
79 seq = ''.join(self.get_exon_seqs())
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
80 return seq
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
81
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
82 def get_translation(self, sequence=None):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
83 translation = None
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
84 seq = sequence if sequence else self.get_spliced_seq()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
85 if seq:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
86 seqlen = int(len(seq) / 3) * 3
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
87 if seqlen >= 3:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
88 translation = translate(seq[:seqlen])
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
89 return translation
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
90
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
91 def get_translations(self):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
92 translations = []
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
93 seq = self.get_spliced_seq()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
94 if seq:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
95 for i in range(3):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
96 translation = self.get_translation(sequence=seq[i:])
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
97 if translation:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
98 translations.append(translation)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
99 return translations
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
100
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
101 def get_subrange(self, tstart, tstop):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
102 """
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
103 (start, end)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
104 """
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
105 chromStart = self.chromStart
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
106 chromEnd = self.chromEnd
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
107 r = range(self.blockCount)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
108 if self.strand == '-':
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
109 r = list(r)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
110 r.reverse()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
111 bStart = 0
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
112 for x in r:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
113 bEnd = bStart + self.blockSizes[x]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
114 if bStart <= tstart < bEnd:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
115 if self.strand == '+':
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
116 chromStart = self.chromStart + self.blockStarts[x] + (tstart - bStart)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
117 else:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
118 chromEnd = self.chromStart + self.blockStarts[x] + (tstart - bStart)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
119 if bStart <= tstop < bEnd:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
120 if self.strand == '+':
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
121 chromEnd = self.chromStart + self.blockStarts[x] + (tstop - bStart)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
122 else:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
123 chromStart = self.chromStart + self.blockStarts[x] + self.blockSizes[x] - (tstop - bStart)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
124 bStart += self.blockSizes[x]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
125 return(chromStart, chromEnd)
0
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
126
2
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
127 def get_blocks(self, chromStart, chromEnd):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
128 """
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
129 get the blocks for sub range
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
130 """
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
131 tblockCount = 0
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
132 tblockSizes = []
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
133 tblockStarts = []
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
134 for x in range(self.blockCount):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
135 bStart = self.chromStart + self.blockStarts[x]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
136 bEnd = bStart + self.blockSizes[x]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
137 if bStart > chromEnd:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
138 break
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
139 if bEnd < chromStart:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
140 continue
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
141 cStart = max(chromStart, bStart)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
142 tblockStarts.append(cStart - chromStart)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
143 tblockSizes.append(min(chromEnd, bEnd) - cStart)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
144 tblockCount += 1
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
145 # print >> sys.stderr, "tblockCount: %d tblockStarts: %s tblockSizes: %s" % (tblockCount, tblockStarts, tblockSizes)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
146 return (tblockCount, tblockSizes, tblockStarts)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
147
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
148 def get_filterd_translations(self, untrimmed=False, filtering=True, ignore_left_bp=0, ignore_right_bp=0, debug=False):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
149 """
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
150 [(start, end, seq, blockCount, blockSizes, blockStarts), (start, end, seq, blockCount, blockSizes, blockStarts), (start, end, seq, blockCount, blockSizes, blockStarts)]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
151 filter: ignore translation if stop codon in first exon after ignore_left_bp
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
152 """
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
153 translations = [None, None, None, None, None, None]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
154 seq = self.get_spliced_seq()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
155 ignore = int((ignore_left_bp if self.strand == '+' else ignore_right_bp) / 3)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
156 block_sum = sum(self.blockSizes)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
157 exon_sizes = [x for x in self.blockSizes]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
158 if self.strand == '-':
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
159 exon_sizes.reverse()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
160 splice_sites = [int(sum(exon_sizes[:x]) / 3) for x in range(1, len(exon_sizes))]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
161 if debug:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
162 sys.stderr.write("splice_sites: %s\n" % splice_sites)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
163 junc = splice_sites[0] if len(splice_sites) > 0 else exon_sizes[0]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
164 if seq:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
165 for i in range(3):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
166 translation = self.get_translation(sequence=seq[i:])
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
167 if translation:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
168 tstart = 0
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
169 tstop = len(translation)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
170 offset = (block_sum - i) % 3
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
171 if debug:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
172 sys.stderr.write("frame: %d\ttstart: %d tstop: %d offset: %d\t%s\n" % (i, tstart, tstop, offset, translation))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
173 if not untrimmed:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
174 tstart = translation.rfind('*', 0, junc) + 1
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
175 stop = translation.find('*', junc)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
176 tstop = stop if stop >= 0 else len(translation)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
177 offset = (block_sum - i) % 3
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
178 trimmed = translation[tstart:tstop]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
179 if debug:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
180 sys.stderr.write("frame: %d\ttstart: %d tstop: %d offset: %d\t%s\n" % (i, tstart, tstop, offset, trimmed))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
181 if filtering and tstart > ignore:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
182 continue
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
183 # get genomic locations for start and end
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
184 if self.strand == '+':
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
185 chromStart = self.chromStart + i + (tstart * 3)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
186 chromEnd = self.chromEnd - offset - (len(translation) - tstop) * 3
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
187 else:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
188 chromStart = self.chromStart + offset + (len(translation) - tstop) * 3
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
189 chromEnd = self.chromEnd - i - (tstart * 3)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
190 # get the blocks for this translation
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
191 (tblockCount, tblockSizes, tblockStarts) = self.get_blocks(chromStart, chromEnd)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
192 translations[i] = (chromStart, chromEnd, trimmed, tblockCount, tblockSizes, tblockStarts)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
193 if debug:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
194 sys.stderr.write("tblockCount: %d tblockStarts: %s tblockSizes: %s\n" % (tblockCount, tblockStarts, tblockSizes))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
195 # translations[i] = (chromStart, chromEnd, trimmed, tblockCount, tblockSizes, tblockStarts)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
196 return translations
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
197
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
198 def get_seq_id(self, seqtype='unk:unk', reference='', frame=None):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
199 """
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
200 # Ensembl fasta ID format
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
201 >ID SEQTYPE:STATUS LOCATION GENE TRANSCRIPT
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
202 >ENSP00000328693 pep:splice chromosome:NCBI35:1:904515:910768:1 gene:ENSG00000158815:transcript:ENST00000328693 gene_biotype:protein_coding transcript_biotype:protein_coding
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
203 """
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
204 frame_name = ''
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
205 chromStart = self.chromStart
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
206 chromEnd = self.chromEnd
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
207 strand = 1 if self.strand == '+' else -1
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
208 if frame is not None:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
209 block_sum = sum(self.blockSizes)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
210 offset = (block_sum - frame) % 3
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
211 frame_name = '_' + str(frame + 1)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
212 if self.strand == '+':
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
213 chromStart += frame
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
214 chromEnd -= offset
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
215 else:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
216 chromStart += offset
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
217 chromEnd -= frame
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
218 location = "chromosome:%s:%s:%s:%s:%s" % (reference, self.chrom, chromStart, chromEnd, strand)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
219 seq_id = "%s%s %s %s" % (self.name, frame_name, seqtype, location)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
220 return seq_id
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
221
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
222 def get_line(self, start_offset=0, end_offset=0):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
223 if start_offset or end_offset:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
224 s_offset = start_offset if start_offset else 0
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
225 e_offset = end_offset if end_offset else 0
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
226 if s_offset > self.chromStart:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
227 s_offset = self.chromStart
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
228 chrStart = self.chromStart - s_offset
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
229 chrEnd = self.chromEnd + e_offset
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
230 blkSizes = self.blockSizes
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
231 blkSizes[0] += s_offset
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
232 blkSizes[-1] += e_offset
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
233 blkStarts = self.blockStarts
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
234 for i in range(1, self.blockCount):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
235 blkStarts[i] += s_offset
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
236 items = [str(x) for x in [self.chrom, chrStart, chrEnd, self.name, self.score, self.strand, self.thickStart, self.thickEnd, self.itemRgb, self.blockCount, ','.join([str(x) for x in blkSizes]), ','.join([str(x) for x in blkStarts])]]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
237 return '\t'.join(items) + '\n'
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
238 return self.line
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
239
0
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
240
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
241 def __main__():
2
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
242 # Parse Command Line
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
243 parser = optparse.OptionParser()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
244 parser.add_option('-i', '--input', dest='input', help='BED file (tophat junctions.bed) with sequence column added')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
245 parser.add_option('-o', '--output', dest='output', help='Translations of spliced sequence')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
246 parser.add_option('-b', '--bed_format', dest='bed_format', action='store_true', default=False, help='Append translations to bed file instead of fasta')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
247 parser.add_option('-D', '--fa_db', dest='fa_db', default=None, help='Prefix DB identifier for fasta ID line, e.g. generic')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
248 parser.add_option('-s', '--fa_sep', dest='fa_sep', default='|', help='fasta ID separator defaults to pipe char, e.g. generic|ProtID|description')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
249 parser.add_option('-B', '--bed', dest='bed', default=None, help='Output a bed file with added 13th column having translation')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
250 parser.add_option('-G', '--gff3', dest='gff', default=None, help='Output translations to a GFF3 file')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
251 parser.add_option('-S', '--seqtype', dest='seqtype', default='pep:splice', help='SEQTYPE:STATUS for fasta ID line')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
252 parser.add_option('-P', '--id_prefix', dest='id_prefix', default='', help='prefix for the sequence ID')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
253 parser.add_option('-R', '--reference', dest='reference', default=None, help='Genome Reference Name for fasta ID location ')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
254 parser.add_option('-r', '--refsource', dest='refsource', default=None, help='Source for Genome Reference, e.g. Ensembl, UCSC, or NCBI')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
255 parser.add_option('-Q', '--score_name', dest='score_name', default=None, help='include in the fasta ID line score_name:score ')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
256 parser.add_option('-l', '--leading_bp', dest='leading_bp', type='int', default=None, help='leading number of base pairs to ignore when filtering')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
257 parser.add_option('-t', '--trailing_bp', dest='trailing_bp', type='int', default=None, help='trailing number of base pairs to ignore when filtering')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
258 parser.add_option('-U', '--unfiltered', dest='filtering', action='store_false', default=True, help='Do NOT filterout translation with stop codon in the first exon')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
259 parser.add_option('-u', '--untrimmed', dest='untrimmed', action='store_true', default=False, help='Do NOT trim from splice site to stop codon')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
260 parser.add_option('-L', '--min_length', dest='min_length', type='int', default=None, help='Minimun length (to first stop codon)')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
261 parser.add_option('-M', '--max_stop_codons', dest='max_stop_codons', type='int', default=None, help='Filter out translations with more than max_stop_codons')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
262 parser.add_option('-d', '--debug', dest='debug', action='store_true', default=False, help='Turn on wrapper debugging to stdout')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
263 (options, args) = parser.parse_args()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
264 # Input files
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
265 if options.input is not None:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
266 try:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
267 inputPath = os.path.abspath(options.input)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
268 inputFile = open(inputPath, 'r')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
269 except Exception as e:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
270 sys.stderr.write("failed: %s\n" % e)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
271 exit(2)
0
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
272 else:
2
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
273 inputFile = sys.stdin
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
274 # Output files
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
275 bed_fh = None
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
276 gff_fh = None
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
277 gff_fa_file = None
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
278 gff_fa = None
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
279 outFile = None
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
280 if options.output is None:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
281 # write to stdout
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
282 outFile = sys.stdout
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
283 if options.gff:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
284 gff_fa_file = tempfile.NamedTemporaryFile(prefix='gff_fasta_', suffix=".fa", dir=os.getcwd()).name
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
285 gff_fa = open(gff_fa_file, 'w')
0
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
286 else:
2
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
287 try:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
288 outPath = os.path.abspath(options.output)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
289 outFile = open(outPath, 'w')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
290 except Exception as e:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
291 sys.stderr.write("failed: %s\n" % e)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
292 exit(3)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
293 if options.gff:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
294 gff_fa_file = outPath
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
295 if options.bed:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
296 bed_fh = open(options.bed, 'w')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
297 bed_fh.write('track name="%s" description="%s" \n' % ('novel_junctioni_translations', 'test'))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
298 if options.gff:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
299 gff_fh = open(options.gff, 'w')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
300 gff_fh.write("##gff-version 3.2.1\n")
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
301 if options.reference:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
302 gff_fh.write("##genome-build %s %s\n" % (options.refsource if options.refsource else 'unknown', options.reference))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
303 leading_bp = 0
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
304 trailing_bp = 0
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
305 if options.leading_bp:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
306 if options.leading_bp >= 0:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
307 leading_bp = options.leading_bp
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
308 else:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
309 sys.stderr.write("failed: leading_bp must be positive\n")
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
310 exit(5)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
311 if options.trailing_bp:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
312 if options.trailing_bp >= 0:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
313 trailing_bp = options.trailing_bp
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
314 else:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
315 sys.stderr.write("failed: trailing_bp must be positive\n")
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
316 exit(5)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
317 # Scan bed file
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
318 try:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
319 for i, line in enumerate(inputFile):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
320 if line.startswith('track'):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
321 if outFile and options.bed_format:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
322 outFile.write(line)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
323 continue
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
324 entry = BedEntry(line)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
325 strand = 1 if entry.strand == '+' else -1
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
326 translations = entry.get_translations()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
327 if options.debug:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
328 exon_seqs = entry.get_exon_seqs()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
329 exon_sizes = [len(seq) for seq in exon_seqs]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
330 splice_sites = [int(sum(exon_sizes[:x]) / 3) for x in range(1, len(exon_sizes))]
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
331 sys.stderr.write("%s\n" % entry.name)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
332 sys.stderr.write("%s\n" % line.rstrip('\r\n'))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
333 sys.stderr.write("exons: %s\n" % exon_seqs)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
334 sys.stderr.write("%s\n" % splice_sites)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
335 for i, translation in enumerate(translations):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
336 sys.stderr.write("frame %d: %s\n" % (i + 1, translation))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
337 sys.stderr.write("splice: %s\n" % (''.join(['^' if int(((j * 3) + i) / 3) in splice_sites else '-' for j in range(len(translation))])))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
338 sys.stderr.write("\n")
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
339 if options.bed_format:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
340 tx_entry = "%s\t%s\n" % (line.rstrip('\r\n'), '\t'.join(translations))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
341 outFile.write(tx_entry)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
342 else:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
343 translations = entry.get_filterd_translations(untrimmed=options.untrimmed, filtering=options.filtering, ignore_left_bp=leading_bp, ignore_right_bp=trailing_bp, debug=options.debug)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
344 for i, tx in enumerate(translations):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
345 if tx:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
346 (chromStart, chromEnd, translation, blockCount, blockSizes, blockStarts) = tx
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
347 if options.min_length is not None and len(translation) < options.min_length:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
348 continue
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
349 if options.max_stop_codons is not None and translation.count('*') > options.max_stop_codons:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
350 continue
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
351 frame_name = '_%s' % (i + 1)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
352 pep_id = "%s%s%s" % (options.id_prefix, entry.name, frame_name)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
353 if bed_fh:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
354 bed_fh.write('%s\t%d\t%d\t%s\t%d\t%s\t%d\t%d\t%s\t%d\t%s\t%s\t%s\n' % (str(entry.chrom), chromStart, chromEnd, pep_id, entry.score, entry.strand, chromStart, chromEnd, entry.itemRgb, blockCount, ','.join([str(x) for x in blockSizes]), ','.join([str(x) for x in blockStarts]), translation))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
355 location = "chromosome:%s:%s:%s:%s:%s" % (options.reference, entry.chrom, chromStart, chromEnd, strand)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
356 score = " %s:%s" % (options.score_name, entry.score) if options.score_name else ''
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
357 seq_description = "%s %s%s" % (options.seqtype, location, score)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
358 seq_id = "%s " % pep_id
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
359 if options.fa_db:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
360 seq_id = "%s%s%s%s" % (options.fa_db, options.fa_sep, pep_id, options.fa_sep)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
361 fa_id = "%s%s" % (seq_id, seq_description)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
362 fa_entry = ">%s\n%s\n" % (fa_id, translation)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
363 outFile.write(fa_entry)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
364 if gff_fh:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
365 if gff_fa:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
366 gff_fa.write(fa_entry)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
367 gff_fh.write("##sequence-region %s %d %d\n" % (entry.chrom, chromStart + 1, chromEnd - 1))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
368 gff_fh.write("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%d\tID=%s\n" % (entry.chrom, 'splice_junc', 'gene', chromStart + 1, chromEnd - 1, entry.score, entry.strand, 0, pep_id))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
369 for x in range(blockCount):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
370 start = chromStart + blockStarts[x] + 1
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
371 end = start + blockSizes[x] - 1
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
372 phase = (3 - sum(blockSizes[:x]) % 3) % 3
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
373 gff_fh.write("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%d\tParent=%s;ID=%s_%d\n" % (entry.chrom, 'splice_junc', 'CDS', start, end, entry.score, entry.strand, phase, pep_id, pep_id, x))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
374 # ##gff-version 3
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
375 # ##sequence-region 19 1 287484
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
376 # 19 MassSpec peptide 282299 287484 10.0 - 0 ID=TEARLSFYSGHSSFGMYCMVFLALYVQ
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
377 # 19 MassSpec CDS 287474 287484 . - 0 Parent=TEARLSFYSGHSSFGMYCMVFLALYVQ;transcript_id=ENST00000269812
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
378 # 19 MassSpec CDS 282752 282809 . - 1 Parent=TEARLSFYSGHSSFGMYCMVFLALYVQ;transcript_id=ENST00000269812
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
379 # 19 MassSpec CDS 282299 282310 . - 0 Parent=TEARLSFYSGHSSFGMYCMVFLALYVQ;transcript_id=ENST00000269812
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
380 if bed_fh:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
381 bed_fh.close()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
382 if gff_fh:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
383 if gff_fa:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
384 gff_fa.close()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
385 else:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
386 outFile.close()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
387 gff_fa = open(gff_fa_file, 'r')
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
388 gff_fh.write("##FASTA\n")
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
389 for i, line in enumerate(gff_fa):
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
390 gff_fh.write(line)
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
391 gff_fh.close()
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
392 except Exception as e:
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
393 sys.stderr.write("failed: Error reading %s - %s\n" % (options.input if options.input else 'stdin', e))
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
394 raise
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
395 exit(1)
0
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
396
d723eb657f1d planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff changeset
397
2
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
398 if __name__ == "__main__":
4221664a2bd0 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/translate_bed_sequences commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents: 0
diff changeset
399 __main__()