IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
The Integrative Modeling Platform
anchors.py
1 #!/usr/bin/env python
2 
3 import IMP.multifit
4 import IMP.em
5 from IMP import ArgumentParser
6 
7 __doc__ = "Generate anchors for a density map."
8 
9 
10 def parse_args():
11  desc = """Generate anchors for a density map."""
12  p = ArgumentParser(description=desc)
13  p.add_argument("-s", "--size", type=int, dest="size", default=-1,
14  help="number of residues per bead")
15  p.add_argument("assembly_file", help="assembly file name")
16  p.add_argument("anchor_prefix",
17  help="prefix for output anchors file names")
18 
19  return p.parse_args()
20 
21 
22 def main():
23  args = parse_args()
24  output = args.anchor_prefix
25  asmb = IMP.multifit.read_settings(args.assembly_file)
26  asmb.set_was_used(True)
27  dmap = IMP.em.read_map(asmb.get_assembly_header().get_dens_fn(),
29  if args.size == -1:
30  number_of_means = asmb.get_number_of_component_headers()
31  else:
32  total_num_residues = 0
33  mdl = IMP.Model()
34  for i in range(asmb.get_number_of_component_headers()):
35  total_num_residues += len(
36  IMP.atom.get_by_type(
38  asmb.get_component_header(
39  i).get_filename(
40  ),
41  mdl),
42  IMP.atom.RESIDUE_TYPE))
43  number_of_means = total_num_residues / args.size
44  print("Calculating a segmentation into", number_of_means, "regions")
45  density_threshold = asmb.get_assembly_header().get_threshold()
46 
47  IMP.multifit.get_anchors_for_density(dmap, number_of_means,
48  density_threshold,
49  output + ".pdb", output + ".cmm",
50  "", output + ".txt")
51 
52 
53 if __name__ == "__main__":
54  main()
SettingsData * read_settings(const char *filename)
void read_pdb(TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
void get_anchors_for_density(em::DensityMap *dmap, int number_of_means, float density_threshold, std::string pdb_filename, std::string cmm_filename, std::string seg_filename, std::string txt_filename)
Generate anchors in several formats for a given density map.
Fitting atomic structures into a cryo-electron microscopy density map.
Basic utilities for handling cryo-electron microscopy 3D density maps.