annotate convertEnsembl.py @ 11:b7f1d9f8f3bc

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