Mercurial > repos > xuebing > sharplabtool
comparison tools/mytools/makewindow.py @ 0:9071e359b9a3
Uploaded
| author | xuebing |
|---|---|
| date | Fri, 09 Mar 2012 19:37:19 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:9071e359b9a3 |
|---|---|
| 1 def makeWindow(filename,outfile,window): | |
| 2 window = window/2 | |
| 3 f=open(filename) | |
| 4 out = open(outfile,'w') | |
| 5 for line in f: | |
| 6 flds = line.strip().split() | |
| 7 #new position | |
| 8 center = (int(flds[1]) + int(flds[2]))/2 | |
| 9 start = center - window | |
| 10 end = center + window | |
| 11 if start >= 0: | |
| 12 flds[1] = str(start) | |
| 13 flds[2] = str(end) | |
| 14 out.write('\t'.join(flds)+'\n') | |
| 15 f.close() | |
| 16 out.close() | |
| 17 | |
| 18 import sys | |
| 19 makeWindow(sys.argv[1],sys.argv[2],int(sys.argv[3])) |
