forked from roryk/junkdrawer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtophatUtils.py
More file actions
31 lines (28 loc) · 1.02 KB
/
Copy pathtophatUtils.py
File metadata and controls
31 lines (28 loc) · 1.02 KB
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
def parseTophatBedLineToDict(line):
linedict = {}
bl = line.split('\t')
blocksizes = bl[10].split(',')
blockstarts = bl[11].split(',')
linedict['blockstarts'] = [int(x) for x in blockstarts]
linedict['blocksizes'] = [int(x) for x in blocksizes]
linedict['chromStart'] = int(bl[1])
linedict['chromEnd'] = int(bl[2])
linedict['name'] = bl[3]
linedict['score'] = bl[4]
linedict['strand'] = bl[5]
linedict['chrom'] = bl[0]
return(linedict)
def calculateJunctionEnds(linedict):
"""
calculates the last base of the left end of the splice junction and the
first base of the right end of the splice junction
this is 0 based.
arguments: linedict a line dictionary
returns: linedict augmented with 'left' and 'right' entries
"""
left = linedict['chromStart'] + linedict['blocksizes'][0]
right = linedict['chromStart'] + linedict['blockstarts'][1]
# -1 because it is 0 based
linedict['left'] = left
linedict['right'] = right + 1
return(linedict)