annotate mytools/makewindow.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 def makeWindow(filename,outfile,window):
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
2 window = window/2
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
3 f=open(filename)
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
4 out = open(outfile,'w')
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
5 for line in f:
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
6 flds = line.strip().split()
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
7 #new position
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
8 center = (int(flds[1]) + int(flds[2]))/2
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
9 start = center - window
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
10 end = center + window
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
11 if start >= 0:
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
12 flds[1] = str(start)
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
13 flds[2] = str(end)
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
14 out.write('\t'.join(flds)+'\n')
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
15 f.close()
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
16 out.close()
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
17
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
18 import sys
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
19 makeWindow(sys.argv[1],sys.argv[2],int(sys.argv[3]))