annotate ensembl_to_ucsc.py @ 1:7c1a351ad733 default tip

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