Mercurial > repos > galaxyp > peptide_genomic_coordinate
annotate peptide_genomic_coordinate.py @ 0:5f49ffce52cb draft
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
author | galaxyp |
---|---|
date | Wed, 03 Apr 2019 04:04:18 -0400 |
parents | |
children | cb0378d2d487 |
rev | line source |
---|---|
0
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
1 #!/usr/bin/env python |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
2 # |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
3 # Author: Praveen Kumar |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
4 # University of Minnesota |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
5 # |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
6 # Get peptide's genomic coordinate from the protein's genomic mapping sqlite file (which is derived from the https://toolshed.g2.bx.psu.edu/view/galaxyp/translate_bed/038ecf54cbec) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
7 # |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
8 # python peptideGenomicCoordinate.py <peptide_list> <mz_to_sqlite DB> <genomic mapping file DB> <output.bed> |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
9 # |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
10 import sys |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
11 import sqlite3 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
12 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
13 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
14 def main(): |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
15 conn = sqlite3.connect(sys.argv[2]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
16 c = conn.cursor() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
17 c.execute("DROP table if exists novel") |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
18 conn.commit() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
19 c.execute("CREATE TABLE novel(peptide text)") |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
20 pepfile = open(sys.argv[1],"r") |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
21 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
22 pep_seq = [] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
23 for seq in pepfile.readlines(): |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
24 seq = seq.strip() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
25 pep_seq.append(tuple([seq])) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
26 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
27 c.executemany("insert into novel(peptide) values(?)", pep_seq) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
28 conn.commit() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
29 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
30 c.execute("SELECT distinct psm.sequence, ps.id, ps.sequence from db_sequence ps, psm_entries psm, novel n, proteins_by_peptide pbp where psm.sequence = n.peptide and pbp.peptide_ref = psm.id and pbp.id = ps.id") |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
31 rows = c.fetchall() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
32 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
33 conn1 = sqlite3.connect(sys.argv[3]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
34 c1 = conn1.cursor() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
35 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
36 outfh = open(sys.argv[4], "w") |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
37 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
38 master_dict = {} |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
39 for each in rows: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
40 peptide = each[0] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
41 acc = each[1] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
42 acc_seq = each[2] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
43 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
44 c1.execute("SELECT chrom,start,end,name,strand,cds_start,cds_end FROM feature_cds_map map WHERE map.name = '"+acc+"'") |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
45 coordinates = c1.fetchall() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
46 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
47 if len(coordinates) != 0: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
48 pep_start = 0 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
49 pep_end = 0 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
50 flag = 0 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
51 splice_flag = 0 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
52 spliced_peptide = [] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
53 for each_entry in coordinates: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
54 chromosome = each_entry[0] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
55 start = int(each_entry[1]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
56 end = int(each_entry[2]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
57 strand = each_entry[4] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
58 cds_start = int(each_entry[5]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
59 cds_end = int(each_entry[6]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
60 pep_pos_start = (acc_seq.find(peptide)*3) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
61 pep_pos_end = pep_pos_start + (len(peptide)*3) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
62 if pep_pos_start >= cds_start and pep_pos_end <= cds_end: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
63 if strand == "+": |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
64 pep_start = start + pep_pos_start - cds_start |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
65 pep_end = start + pep_pos_end - cds_start |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
66 pep_thick_start = 0 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
67 pep_thick_end = len(peptide) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
68 flag == 1 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
69 else: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
70 pep_end = end - pep_pos_start + cds_start |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
71 pep_start = end - pep_pos_end + cds_start |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
72 pep_thick_start = 0 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
73 pep_thick_end = len(peptide) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
74 flag == 1 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
75 spliced_peptide = [] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
76 splice_flag = 0 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
77 else: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
78 if flag == 0: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
79 if strand == "+": |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
80 if pep_pos_start >= cds_start and pep_pos_start <= cds_end and pep_pos_end > cds_end: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
81 pep_start = start + pep_pos_start - cds_start |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
82 pep_end = end |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
83 pep_thick_start = 0 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
84 pep_thick_end = (pep_end-pep_start) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
85 spliced_peptide.append([pep_start,pep_end,pep_thick_start,pep_thick_end]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
86 splice_flag = splice_flag + 1 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
87 if splice_flag == 2: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
88 flag = 1 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
89 elif pep_pos_end >= cds_start and pep_pos_end <= cds_end and pep_pos_start < cds_start: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
90 pep_start = start |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
91 pep_end = start + pep_pos_end - cds_start |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
92 pep_thick_start = (len(peptide)*3)-(pep_end-pep_start) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
93 pep_thick_end = (len(peptide)*3) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
94 spliced_peptide.append([pep_start,pep_end,pep_thick_start,pep_thick_end]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
95 splice_flag = splice_flag + 1 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
96 if splice_flag == 2: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
97 flag = 1 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
98 else: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
99 pass |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
100 else: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
101 if pep_pos_start >= cds_start and pep_pos_start <= cds_end and pep_pos_end >= cds_end: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
102 pep_start = start |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
103 pep_end = end - pep_pos_start - cds_start |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
104 pep_thick_start = 0 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
105 pep_thick_end = (pep_end-pep_start) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
106 spliced_peptide.append([pep_start,pep_end,pep_thick_start,pep_thick_end]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
107 splice_flag = splice_flag + 1 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
108 if splice_flag == 2: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
109 flag = 1 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
110 elif pep_pos_end >= cds_start and pep_pos_end <= cds_end and pep_pos_start <= cds_start: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
111 pep_start = end - pep_pos_end + cds_start |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
112 pep_end = end |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
113 pep_thick_start = (len(peptide)*3)-(pep_end-pep_start) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
114 pep_thick_end = (len(peptide)*3) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
115 spliced_peptide.append([pep_start,pep_end,pep_thick_start,pep_thick_end]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
116 splice_flag = splice_flag + 1 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
117 if splice_flag == 2: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
118 flag = 1 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
119 else: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
120 pass |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
121 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
122 if len(spliced_peptide) == 0: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
123 if strand == "+": |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
124 bed_line = [chromosome, str(pep_start), str(pep_end), peptide, "255", strand, str(pep_start), str(pep_end), "0", "1", str(pep_end-pep_start), "0"] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
125 else: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
126 bed_line = [chromosome, str(pep_start), str(pep_end), peptide, "255", strand, str(pep_start), str(pep_end), "0", "1", str(pep_end-pep_start), "0"] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
127 outfh.write("\t".join(bed_line)+"\n") |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
128 else: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
129 if strand == "+": |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
130 pep_entry = spliced_peptide |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
131 pep_start = min([pep_entry[0][0], pep_entry[1][0]]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
132 pep_end = max([pep_entry[0][1], pep_entry[1][1]]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
133 blockSize = [str(min([pep_entry[0][3], pep_entry[1][3]])),str(max([pep_entry[0][3], pep_entry[1][3]])-min([pep_entry[0][3], pep_entry[1][3]]))] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
134 blockStarts = ["0", str(pep_end-pep_start-(max([pep_entry[0][3], pep_entry[1][3]])-min([pep_entry[0][3], pep_entry[1][3]])))] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
135 bed_line = [chromosome, str(pep_start), str(pep_end), peptide, "255", strand, str(pep_start), str(pep_end), "0", "2", ",".join(blockSize), ",".join(blockStarts)] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
136 outfh.write("\t".join(bed_line)+"\n") |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
137 else: |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
138 pep_entry = spliced_peptide |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
139 pep_start = min([pep_entry[0][0], pep_entry[1][0]]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
140 pep_end = max([pep_entry[0][1], pep_entry[1][1]]) |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
141 blockSize = [str(min([pep_entry[0][3], pep_entry[1][3]])),str(max([pep_entry[0][3], pep_entry[1][3]])-min([pep_entry[0][3], pep_entry[1][3]]))] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
142 blockStarts = ["0", str(pep_end-pep_start-(max([pep_entry[0][3], pep_entry[1][3]])-min([pep_entry[0][3], pep_entry[1][3]])))] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
143 bed_line = [chromosome, str(pep_start), str(pep_end), peptide, "255", strand, str(pep_start), str(pep_end), "0", "2", ",".join(blockSize), ",".join(blockStarts)] |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
144 outfh.write("\t".join(bed_line)+"\n") |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
145 c.execute("DROP table novel") |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
146 conn.commit() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
147 conn.close() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
148 conn1.close() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
149 outfh.close() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
150 pepfile.close() |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
151 |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
152 return None |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
153 if __name__ == "__main__": |
5f49ffce52cb
planemo upload commit be7e9677908b7864ef0b965a1e219a1840eeb2ec
galaxyp
parents:
diff
changeset
|
154 main() |