Mercurial > repos > galaxyp > map_peptides_to_bed
annotate map_peptides_to_bed.py @ 3:704ea6303c4c draft default tip
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
author | galaxyp |
---|---|
date | Tue, 07 Apr 2020 11:41:15 -0400 |
parents | db90662d26f9 |
children |
rev | line source |
---|---|
0
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
1 #!/usr/bin/env python |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
2 """ |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
3 # |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
4 #------------------------------------------------------------------------------ |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
5 # University of Minnesota |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
6 # Copyright 2014, Regents of the University of Minnesota |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
7 #------------------------------------------------------------------------------ |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
8 # Author: |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
9 # |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
10 # James E Johnson |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
11 # |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
12 #------------------------------------------------------------------------------ |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
13 Input: list of protein_accessions, peptide_sequence |
3
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
14 GFF3 with fasta |
0
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
15 Output: GFF3 of peptides |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
16 |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
17 Filter: Must cross splice boundary |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
18 """ |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
19 |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
20 import optparse |
3
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
21 import os.path |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
22 import sys |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
23 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
24 from Bio.Seq import ( |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
25 reverse_complement, |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
26 translate |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
27 ) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
28 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
29 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
30 class BedEntry(object): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
31 def __init__(self, line): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
32 self.line = line |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
33 try: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
34 fields = line.rstrip('\r\n').split('\t') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
35 (chrom, chromStart, chromEnd, name, score, strand, thickStart, thickEnd, itemRgb, blockCount, blockSizes, blockStarts) = fields[0:12] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
36 seq = fields[12] if len(fields) > 12 else None |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
37 self.chrom = chrom |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
38 self.chromStart = int(chromStart) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
39 self.chromEnd = int(chromEnd) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
40 self.name = name |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
41 self.score = int(score) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
42 self.strand = strand |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
43 self.thickStart = int(thickStart) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
44 self.thickEnd = int(thickEnd) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
45 self.itemRgb = itemRgb |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
46 self.blockCount = int(blockCount) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
47 self.blockSizes = [int(x) for x in blockSizes.split(',')] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
48 self.blockStarts = [int(x) for x in blockStarts.split(',')] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
49 self.seq = seq |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
50 except Exception as e: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
51 sys.stderr.write("Unable to read Bed entry %s \n" % e) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
52 exit(1) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
53 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
54 def __str__(self): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
55 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' % ( |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
56 self.chrom, self.chromStart, self.chromEnd, self.name, self.score, self.strand, self.thickStart, self.thickEnd, self.itemRgb, self.blockCount, |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
57 ','.join([str(x) for x in self.blockSizes]), |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
58 ','.join([str(x) for x in self.blockStarts]), |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
59 '\t%s' % self.seq if self.seq else '') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
60 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
61 def get_splice_junctions(self): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
62 splice_juncs = [] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
63 for i in range(self.blockCount - 1): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
64 splice_junc = "%s:%d_%d" % (self.chrom, self.chromStart + self.blockSizes[i], self.chromStart + self.blockStarts[i + 1]) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
65 splice_juncs.append(splice_junc) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
66 return splice_juncs |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
67 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
68 def get_exon_seqs(self): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
69 exons = [] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
70 for i in range(self.blockCount): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
71 # splice_junc = "%s:%d_%d" % (self.chrom, self.chromStart + self.blockSizes[i], self.chromStart + self.blockStarts[i+1]) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
72 exons.append(self.seq[self.blockStarts[i]:self.blockStarts[i] + self.blockSizes[i]]) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
73 if self.strand == '-': # reverse complement |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
74 exons.reverse() |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
75 for i, s in enumerate(exons): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
76 exons[i] = reverse_complement(s) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
77 return exons |
0
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
78 |
3
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
79 def get_spliced_seq(self): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
80 seq = ''.join(self.get_exon_seqs()) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
81 return seq |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
82 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
83 def get_translation(self, sequence=None): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
84 translation = None |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
85 seq = sequence if sequence else self.get_spliced_seq() |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
86 if seq: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
87 seqlen = int(len(seq) / 3) * 3 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
88 if seqlen >= 3: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
89 translation = translate(seq[:seqlen]) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
90 return translation |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
91 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
92 def get_translations(self): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
93 translations = [] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
94 seq = self.get_spliced_seq() |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
95 if seq: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
96 for i in range(3): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
97 translation = self.get_translation(sequence=seq[i:]) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
98 if translation: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
99 translations.append(translation) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
100 return translations |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
101 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
102 def get_subrange(self, tstart, tstop): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
103 """ |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
104 (start, end) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
105 """ |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
106 chromStart = self.chromStart |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
107 chromEnd = self.chromEnd |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
108 r = range(self.blockCount) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
109 if self.strand == '-': |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
110 r = list(r) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
111 r.reverse() |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
112 bStart = 0 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
113 for x in r: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
114 bEnd = bStart + self.blockSizes[x] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
115 # print >> sys.stderr, "%d chromStart: %d chromEnd: %s bStart: %s bEnd: %d\n" % (x, chromStart, chromEnd, bStart, bEnd) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
116 if bStart <= tstart < bEnd: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
117 if self.strand == '+': |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
118 chromStart = self.chromStart + self.blockStarts[x] + (tstart - bStart) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
119 else: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
120 chromEnd = self.chromStart + self.blockStarts[x] + self.blockSizes[x] - (tstart - bStart) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
121 if bStart <= tstop < bEnd: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
122 if self.strand == '+': |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
123 chromEnd = self.chromStart + self.blockStarts[x] + (tstop - bStart) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
124 else: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
125 chromStart = self.chromStart + self.blockStarts[x] + self.blockSizes[x] - (tstop - bStart) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
126 bStart += self.blockSizes[x] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
127 return(chromStart, chromEnd) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
128 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
129 def get_blocks(self, chromStart, chromEnd): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
130 """ |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
131 get the blocks for sub range |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
132 """ |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
133 tblockCount = 0 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
134 tblockSizes = [] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
135 tblockStarts = [] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
136 for x in range(self.blockCount): |
0
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
137 bStart = self.chromStart + self.blockStarts[x] |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
138 bEnd = bStart + self.blockSizes[x] |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
139 if bStart > chromEnd: |
3
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
140 break |
0
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
141 if bEnd < chromStart: |
3
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
142 continue |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
143 cStart = max(chromStart, bStart) |
0
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
144 tblockStarts.append(cStart - chromStart) |
3
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
145 tblockSizes.append(min(chromEnd, bEnd) - cStart) |
0
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
146 tblockCount += 1 |
3
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
147 sys.stderr.write("tblockCount: %d tblockStarts: %s tblockSizes: %s\n" % (tblockCount, tblockStarts, tblockSizes)) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
148 return (tblockCount, tblockSizes, tblockStarts) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
149 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
150 def get_filterd_translations(self, untrimmed=False, filtering=True, ignore_left_bp=0, ignore_right_bp=0): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
151 """ |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
152 [[start, end, seq, blockCount, blockSizes, blockStarts], [start, end, seq, blockCount, blockSizes, blockStarts], [start, end, seq, blockCount, blockSizes, blockStarts]] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
153 filter: ignore translation if stop codon in first exon after ignore_left_bp |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
154 """ |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
155 translations = [None, None, None, None, None, None] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
156 seq = self.get_spliced_seq() |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
157 ignore = int((ignore_left_bp if self.strand == '+' else ignore_right_bp) / 3) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
158 block_sum = sum(self.blockSizes) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
159 exon_sizes = self.blockSizes |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
160 if self.strand == '-': |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
161 exon_sizes.reverse() |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
162 splice_sites = [int(sum(exon_sizes[:x]) / 3) for x in range(1, len(exon_sizes))] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
163 sys.stderr.write("splice_sites: %s\n" % splice_sites) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
164 junc = splice_sites[0] if len(splice_sites) > 0 else exon_sizes[0] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
165 if seq: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
166 for i in range(3): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
167 translation = self.get_translation(sequence=seq[i:]) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
168 if translation: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
169 tstart = 0 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
170 tstop = len(translation) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
171 if not untrimmed: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
172 tstart = translation.rfind('*', 0, junc) + 1 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
173 stop = translation.find('*', junc) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
174 tstop = stop if stop >= 0 else len(translation) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
175 if filtering and tstart > ignore: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
176 continue |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
177 trimmed = translation[tstart:tstop] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
178 # get genomic locations for start and end |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
179 offset = (block_sum - i) % 3 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
180 sys.stderr.write("tstart: %d tstop: %d offset: %d\n" % (tstart, tstop, offset)) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
181 if self.strand == '+': |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
182 chromStart = self.chromStart + i + (tstart * 3) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
183 chromEnd = self.chromEnd - offset - (len(translation) - tstop) * 3 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
184 else: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
185 chromStart = self.chromStart + offset + (len(translation) - tstop) * 3 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
186 chromEnd = self.chromEnd - i - (tstart * 3) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
187 # get the blocks for this translation |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
188 tblockCount = 0 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
189 tblockSizes = [] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
190 tblockStarts = [] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
191 for x in range(self.blockCount): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
192 bStart = self.chromStart + self.blockStarts[x] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
193 bEnd = bStart + self.blockSizes[x] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
194 if bStart > chromEnd: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
195 break |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
196 if bEnd < chromStart: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
197 continue |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
198 cStart = max(chromStart, bStart) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
199 tblockStarts.append(cStart - chromStart) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
200 tblockSizes.append(min(chromEnd, bEnd) - cStart) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
201 tblockCount += 1 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
202 sys.stderr.write("tblockCount: %d tblockStarts: %s tblockSizes: %s\n" % (tblockCount, tblockStarts, tblockSizes)) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
203 translations[i] = [chromStart, chromEnd, trimmed, tblockCount, tblockSizes, tblockStarts] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
204 return translations |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
205 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
206 def get_seq_id(self, seqtype='unk:unk', reference='', frame=None): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
207 """ |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
208 # Ensembl fasta ID format |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
209 >ID SEQTYPE:STATUS LOCATION GENE TRANSCRIPT |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
210 >ENSP00000328693 pep:splice chromosome:NCBI35:1:904515:910768:1 gene:ENSG00000158815:transcript:ENST00000328693 gene_biotype:protein_coding transcript_biotype:protein_coding |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
211 """ |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
212 frame_name = '' |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
213 chromStart = self.chromStart |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
214 chromEnd = self.chromEnd |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
215 strand = 1 if self.strand == '+' else -1 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
216 if frame is not None: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
217 block_sum = sum(self.blockSizes) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
218 offset = (block_sum - frame) % 3 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
219 frame_name = '_' + str(frame + 1) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
220 if self.strand == '+': |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
221 chromStart += frame |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
222 chromEnd -= offset |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
223 else: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
224 chromStart += offset |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
225 chromEnd -= frame |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
226 location = "chromosome:%s:%s:%s:%s:%s" % (reference, self.chrom, chromStart, chromEnd, strand) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
227 seq_id = "%s%s %s %s" % (self.name, frame_name, seqtype, location) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
228 return seq_id |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
229 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
230 def get_line(self, start_offset=0, end_offset=0): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
231 if start_offset or end_offset: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
232 s_offset = start_offset if start_offset else 0 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
233 e_offset = end_offset if end_offset else 0 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
234 if s_offset > self.chromStart: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
235 s_offset = self.chromStart |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
236 chrStart = self.chromStart - s_offset |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
237 chrEnd = self.chromEnd + e_offset |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
238 blkSizes = self.blockSizes |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
239 blkSizes[0] += s_offset |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
240 blkSizes[-1] += e_offset |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
241 blkStarts = self.blockStarts |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
242 for i in range(1, self.blockCount): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
243 blkStarts[i] += s_offset |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
244 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])]] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
245 return '\t'.join(items) + '\n' |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
246 return self.line |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
247 |
0
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
248 |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
249 def __main__(): |
3
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
250 # Parse Command Line |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
251 parser = optparse.OptionParser() |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
252 parser.add_option('-t', '--translated_bed', dest='translated_bed', default=None, help='A bed file with added 13th column having a translation') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
253 parser.add_option('-i', '--input', dest='input', default=None, help='Tabular file with peptide_sequence column') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
254 parser.add_option('-p', '--peptide_column', type='int', dest='peptide_column', default=1, help='column ordinal with peptide sequence') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
255 parser.add_option('-n', '--name_column', type='int', dest='name_column', default=2, help='column ordinal with protein name') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
256 parser.add_option('-s', '--start_column', type='int', dest='start_column', default=None, help='column with peptide start position in protein') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
257 parser.add_option('-B', '--bed', dest='bed', default=None, help='Output a bed file with added 13th column having translation') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
258 # parser.add_option('-G', '--gff3', dest='gff', default=None, help='Output translations to a GFF3 file') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
259 # parser.add_option('-f', '--fasta', dest='fasta', default=None, help='Protein fasta') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
260 parser.add_option('-T', '--gffTags', dest='gffTags', action='store_true', default=False, help='Add #gffTags to bed output for IGV') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
261 parser.add_option('-d', '--debug', dest='debug', action='store_true', default=False, help='Turn on wrapper debugging to stderr') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
262 (options, args) = parser.parse_args() |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
263 # Input files |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
264 if options.input is not None: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
265 try: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
266 inputPath = os.path.abspath(options.input) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
267 inputFile = open(inputPath, 'r') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
268 except Exception as e: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
269 sys.stderr("failed: %s\n" % e) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
270 exit(2) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
271 else: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
272 inputFile = sys.stdin |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
273 inputBed = None |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
274 if options.translated_bed is not None: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
275 inputBed = open(os.path.abspath(options.translated_bed), 'r') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
276 peptide_column = options.peptide_column - 1 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
277 name_column = options.name_column - 1 if options.name_column else None |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
278 start_column = options.start_column - 1 if options.start_column else None |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
279 # Read in peptides |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
280 # peps[prot_name] = [seq] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
281 prot_peps = dict() |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
282 unassigned_peps = set() |
0
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
283 try: |
3
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
284 for i, line in enumerate(inputFile): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
285 # print >> sys.stderr, "%3d\t%s\n" % (i, line) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
286 if line.startswith('#'): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
287 continue |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
288 fields = line.rstrip('\r\n').split('\t') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
289 # print >> sys.stderr, "%3d\t%s\n" % (i, fields) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
290 if peptide_column < len(fields): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
291 peptide = fields[peptide_column] |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
292 prot_name = fields[name_column] if name_column is not None and name_column < len(fields) else None |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
293 if prot_name: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
294 offset = fields[start_column] if start_column is not None and start_column < len(fields) else -1 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
295 if prot_name not in prot_peps: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
296 prot_peps[prot_name] = dict() |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
297 prot_peps[prot_name][peptide] = offset |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
298 else: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
299 unassigned_peps.add(peptide) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
300 if options.debug: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
301 sys.stderr.write("prot_peps: %s\n" % prot_peps) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
302 sys.stderr.write("unassigned_peps: %s\n" % unassigned_peps) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
303 except Exception as e: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
304 sys.stderr.write("failed: Error reading %s - %s\n" % (options.input if options.input else 'stdin', e)) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
305 exit(1) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
306 # Output files |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
307 bed_fh = None |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
308 if options.bed: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
309 bed_fh = open(options.bed, 'w') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
310 bed_fh.write('track name="%s" type=bedDetail description="%s" \n' % ('novel_junction_peptides', 'test')) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
311 if options.gffTags: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
312 bed_fh.write('#gffTags\n') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
313 # if options.gff: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
314 # gff_fh = open(options.gff, 'w') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
315 # gff_fh.write("##gff-version 3.2.1\n") |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
316 # if options.reference: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
317 # gff_fh.write("##genome-build %s %s\n" % (options.refsource if options.refsource else 'unknown', options.reference)) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
318 try: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
319 for i, line in enumerate(inputBed): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
320 # print >> sys.stderr, "%3d:\t%s\n" % (i, line) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
321 if line.startswith('track'): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
322 continue |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
323 entry = BedEntry(line) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
324 if entry.name in prot_peps: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
325 for (peptide, offset) in prot_peps[entry.name].items(): |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
326 if offset < 0: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
327 offset = entry.seq.find(peptide) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
328 if options.debug: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
329 sys.stderr.write("%s\t%s\t%d\t%s\n" % (entry.name, peptide, offset, entry.seq)) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
330 if offset >= 0: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
331 tstart = offset * 3 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
332 tstop = tstart + len(peptide) * 3 |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
333 if options.debug: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
334 sys.stderr.write("%d\t%d\t%d\n" % (offset, tstart, tstop)) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
335 (pepStart, pepEnd) = entry.get_subrange(tstart, tstop) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
336 if options.debug: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
337 sys.stderr.write("%d\t%d\t%d\n" % (offset, pepStart, pepEnd)) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
338 if bed_fh: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
339 entry.thickStart = pepStart |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
340 entry.thickEnd = pepEnd |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
341 bedfields = str(entry).split('\t') |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
342 if options.gffTags: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
343 bedfields[3] = "ID=%s;Name=%s" % (entry.name, peptide) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
344 bed_fh.write("%s\t%s\t%s\n" % ('\t'.join(bedfields[:12]), peptide, entry.seq)) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
345 except Exception as e: |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
346 sys.stderr.write("failed: Error reading %s - %s\n" % (options.input if options.input else 'stdin', e)) |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
347 raise |
0
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
348 |
51f8f9041724
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit e04ed4b4960d6109a85c1cc68a2bf4931c8751ef-dirty
galaxyp
parents:
diff
changeset
|
349 |
3
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
350 if __name__ == "__main__": |
704ea6303c4c
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/map_peptides_to_bed commit 2a470e2c775a7427aa530e058510e4dc7b6d8e80"
galaxyp
parents:
1
diff
changeset
|
351 __main__() |