annotate makewindow.py @ 24:8dd2a3f51c42 draft default tip

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