IMP logo
IMP Reference Guide  develop.50fdd7fa33,2025/09/05
The Integrative Modeling Platform
calculate_seq_match.py
1 import sys
2 
3 
4 def main():
5  result_file = sys.argv[1]
6  total_residue = 0
7  total_residue_matched = 0
8  total_residue_matched_abs = 0
9  with open(result_file, 'r') as infile:
10  for lines in infile:
11  line = lines.strip().split('|')
12  emdb, resolution, seid = line[0].strip().split(' ')
13  se_length = int(seid.split('_')[-1])
14  if 'nan' in line[1]:
15  print(line)
16  else:
17  total_residue += se_length
18  rank = line[1].strip().split(' ')[0]
19  if int(rank) <= se_length/3:
20  total_residue_matched += se_length
21 
22  if int(rank) == 0:
23  total_residue_matched_abs += se_length
24  print(result_file, "total percentage matched ",
25  round(100*(total_residue_matched/total_residue), 3))
26  print(result_file, "total abs percentage matched ",
27  round(100*(total_residue_matched_abs/total_residue), 3))
28 
29 
30 if __name__ == '__main__':
31  main()