annotate mytools/convertEnsembl.py @ 9:87eb5c5ddfe9

Uploaded
author xuebing
date Fri, 09 Mar 2012 20:01:43 -0500
parents f0dc65e7f6c0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
1 '''
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
2 convert ensembl bed to ucsc
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
3 add chr to chromosome
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
4 1 = +
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
5 -1 = -
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
6 '''
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
7
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
8 import sys
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
9 f = open(sys.argv[1])
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
10 out = open(sys.argv[2],'w')
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
11 skip = int(sys.argv[3])
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
12
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
13 for i in range(skip):
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
14 f.readline()
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
15
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
16 for line in f:
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
17 flds = line.strip().split('\t')
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
18 flds[0] = 'chr'+flds[0]
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
19 if flds[5] == '1':
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
20 flds[5] = '+'
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
21 else:
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
22 flds[5] = '-'
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
23 out.write('\t'.join(flds)+'\n')
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
24 f.close()
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
25 out.close()
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
26