IMP logo
IMP Reference Guide  2.8.0
The Integrative Modeling Platform
indexes.py
1 #!/usr/bin/env python
2 
3 from __future__ import print_function
4 import IMP.multifit
5 from IMP import OptionParser
6 
7 __doc__ = "Generate indexes of fitting solutions."
8 
9 def parse_args():
10  usage = """%prog [options] <assembly name> <assembly input> <number of fits> <indexes filename>
11 
12 Generate indexes of fitting solutions.
13 """
14  parser = OptionParser(usage)
15  options, args = parser.parse_args()
16  if len(args) != 4:
17  parser.error("incorrect number of arguments")
18  return options, args
19 
20 
21 def run(assembly_name, asmb_fn, num_fits, mapping_fn=""):
22  IMP.set_log_level(IMP.WARNING)
23  asmb_input = IMP.multifit.read_settings(asmb_fn)
24  asmb_input.set_was_used(True)
25  ap_em_fn = asmb_input.get_assembly_header().get_coarse_over_sampled_ap_fn()
26  if mapping_fn == "":
27  mapping_fn = assembly_name + ".indexes.mapping.input"
28  mapping_data = open(mapping_fn, "w")
29  mapping_data.write("|anchors|" + ap_em_fn + "|\n")
30  for i in range(asmb_input.get_number_of_component_headers()):
31  name = asmb_input.get_component_header(i).get_name()
32  trans_fn = asmb_input.get_component_header(i).get_transformations_fn()
34  print("number of fits for component", i, "is", len(fits), trans_fn)
35  index_fn = assembly_name + "." + name + ".fit.indexes.txt"
36  indexes = []
37  for i in range(min(num_fits, len(fits))):
38  indexes.append([i])
39  IMP.multifit.write_paths(indexes, index_fn)
40  mapping_data.write("|protein|" + name +
41  "|" + index_fn + "|\n")
42  mapping_data.close()
43 
44 
45 def main():
46  options, args = parse_args()
47  asmb_name = args[0]
48  asmb_input = args[1]
49  max_fits = int(args[2])
50  mapping_fn = args[3]
51  run(asmb_name, asmb_input, max_fits, mapping_fn)
52 
53 if __name__ == "__main__":
54  main()
void write_paths(const IntsList &paths, const std::string &txt_filename)
SettingsData * read_settings(const char *filename)
Fitting atomic structures into a cryo-electron microscopy density map.
void set_log_level(LogLevel l)
Set the current global log level.
FittingSolutionRecords read_fitting_solutions(const char *fitting_fn)
Fitting solutions reader.