forked from chizksh/digenome-toolkit2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8.count-1_depth.py
More file actions
29 lines (26 loc) · 986 Bytes
/
Copy path8.count-1_depth.py
File metadata and controls
29 lines (26 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import string
import sys
from sys import argv
for fn in argv[1:]:
try:
f = open(fn)
msg = "count-1 depth {}".format(fn.strip('./'))
sys.stdout.write(msg);sys.stdout.flush()
sys.stdout.write("\b"*len(msg));sys.stdout.flush()
fnhead = '.'.join(fn.split('.')[:-1])
fo = open('{}_count-1.txt'.format(fnhead), 'w')
for line in f.xreadlines():
units = line.split()
seq = units[0]
count = string.atoi(units[1])
depth = string.atoi(units[2])
count_1_depth = (count-1)*1.0/depth
if count-1 != 0 :
s = ( seq +" "+ str(count-1) +" "+ str(depth) +" "+ str(count_1_depth*100)+"\n" )
fo.write(s)
f.close();fo.close()
sys.stdout.write(" "*len(msg));sys.stdout.flush()
sys.stdout.write("\b"*len(msg));sys.stdout.flush()
except IOError:
print "IOError"
pass