IMP logo
IMP Reference Guide  2.21.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 ArgumentParser
6 
7 __doc__ = "Generate indexes of fitting solutions."
8 
9 
10 def parse_args():
11  desc = """Generate indexes of fitting solutions."""
12  p = ArgumentParser(description=desc)
13  p.add_argument("assembly_name", help="name of the assembly")
14  p.add_argument("assembly_file", help="assembly file name")
15  p.add_argument("num_fits", type=int, help="number of fits")
16  p.add_argument("indexes_file", help="indexes file name")
17  return p.parse_args()
18 
19 
20 def run(assembly_name, asmb_fn, num_fits, mapping_fn=""):
21  IMP.set_log_level(IMP.WARNING)
22  asmb_input = IMP.multifit.read_settings(asmb_fn)
23  asmb_input.set_was_used(True)
24  ap_em_fn = asmb_input.get_assembly_header().get_coarse_over_sampled_ap_fn()
25  if mapping_fn == "":
26  mapping_fn = assembly_name + ".indexes.mapping.input"
27  mapping_data = open(mapping_fn, "w")
28  mapping_data.write("|anchors|" + ap_em_fn + "|\n")
29  for i in range(asmb_input.get_number_of_component_headers()):
30  name = asmb_input.get_component_header(i).get_name()
31  trans_fn = asmb_input.get_component_header(i).get_transformations_fn()
33  print("number of fits for component", i, "is", len(fits), trans_fn)
34  index_fn = assembly_name + "." + name + ".fit.indexes.txt"
35  indexes = []
36  for i in range(min(num_fits, len(fits))):
37  indexes.append([i])
38  IMP.multifit.write_paths(indexes, index_fn)
39  mapping_data.write("|protein|" + name + "|" + index_fn + "|\n")
40  mapping_data.close()
41 
42 
43 def main():
44  args = parse_args()
45  run(args.assembly_name, args.assembly_file, args.num_fits,
46  args.indexes_file)
47 
48 
49 if __name__ == "__main__":
50  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.