annotate mytools/convertEnsembl.py @ 0:39217fa39ff2

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