annotate bed_window.py @ 1:0f849231e4e0 default tip

Uploaded
author xuebing
date Sat, 31 Mar 2012 14:05:49 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
1 def makeWindow(filename,outfile,window):
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
2 window = window/2
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
3 f=open(filename)
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
4 out = open(outfile,'w')
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
5 for line in f:
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
6 flds = line.strip().split()
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
7 #new position
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
8 center = (int(flds[1]) + int(flds[2]))/2
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
9 start = center - window
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
10 end = center + window
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
11 if start >= 0:
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
12 flds[1] = str(start)
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
13 flds[2] = str(end)
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
14 out.write('\t'.join(flds)+'\n')
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
15 f.close()
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
16 out.close()
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
17
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
18 import sys
0f849231e4e0 Uploaded
xuebing
parents:
diff changeset
19 makeWindow(sys.argv[1],sys.argv[2],int(sys.argv[3]))