-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompile_sequence_recovery.py
executable file
·60 lines (44 loc) · 1.37 KB
/
compile_sequence_recovery.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python
from sys import argv,stdout
from glob import glob
from string import split
from os.path import basename
globfiles = argv[1:]
#globfiles.sort()
N = {}
recovery = {}
for file in globfiles:
lines = open( file ).readlines()
tag = basename( file ).split('.')[0]
N[ tag ] = {}
recovery[ tag ] = {}
kinds_of_residues = []
for line in lines[-4:]:
cols = split( line )
N[ tag ][ cols[0] ] = int( cols[1] )
recovery[ tag ][ cols[0] ] = float( cols[2] )
kinds_of_residues.append( cols[0] )
tags = N.keys()
tags.sort()
total_residues = {}
total_recovery = {}
for kind in kinds_of_residues:
total_residues[ kind ] = 0
total_recovery[ kind ] = 0
stdout.write( '%10s' % 'RNA')
for kind in kinds_of_residues:
stdout.write( ' %15s' % kind )
stdout.write( '\n')
for tag in tags:
stdout.write( '%10s ' % tag)
for kind in kinds_of_residues:
total_residues[ kind ] += N[ tag ][ kind]
total_recovery[ kind ] += N[ tag ][ kind] * recovery[ tag ][ kind]
stdout.write( ' %3d %8.3f ' % (N[tag][ kind ], recovery[tag][kind]) )
stdout.write( '\n' )
stdout.write( '%10s ' % 'TOTAL')
for kind in kinds_of_residues:
total_recovery[ kind ] /= total_residues[kind]
stdout.write( ' %3d %8.3f ' % \
(total_residues[kind], total_recovery[kind]) )
stdout.write( '\n' )