-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_trans.py
executable file
·56 lines (41 loc) · 1.21 KB
/
get_trans.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*
'''
This script is used to get the entire transcript annotation from the V4expCaculate_combined_houm.gtf file
'''
import modify_gtf as gtf
import sys
# import pdb
def summaryLast():
global curTransId
global curGeneId
global curCh
global curSrc
global curStrand
global lCoords
# pool all coordinates together, the min is the first, the max is the last
# pdb.set_trace()
lCoords = [int(c) for c in lCoords]
firstCoord = min(lCoords)
lastCoord = max(lCoords)
lOut = [curCh, curSrc, 'transcript', str(firstCoord), str(lastCoord), '.', curStrand, '.', 'gene_id ' + curGeneId + '; transcript_id ' + curTransId]
print '\t'.join(lOut)
curTransId = ''
# f = open('/lustre/user/houm/projects/AnnoLnc/test_trans.gtf')
# for line in f.readlines():
for line in sys.stdin.readlines():
li = line.rstrip('\n').split('\t')
# pdb.set_trace()
dAnnos = gtf.processAnnotation(li[8])
transId = dAnnos['transcript_id']
geneId = dAnnos['gene_id']
if transId != curTransId and curTransId != '':
summaryLast()
if transId != curTransId:
curTransId = transId
curGeneId = geneId
curCh, curSrc = li[0:2]
curStrand = li[6]
lCoords = []
lCoords += li[3:5]
summaryLast()