IMP logo
IMP Reference Guide  2.21.0
The Integrative Modeling Platform
anchors.py
1 #!/usr/bin/env python
2 
3 from __future__ import print_function
4 import IMP.multifit
5 import IMP.em
6 from IMP import ArgumentParser
7 
8 __doc__ = "Generate anchors for a density map."
9 
10 
11 def parse_args():
12  desc = """Generate anchors for a density map."""
13  p = ArgumentParser(description=desc)
14  p.add_argument("-s", "--size", type=int, dest="size", default=-1,
15  help="number of residues per bead")
16  p.add_argument("assembly_file", help="assembly file name")
17  p.add_argument("anchor_prefix",
18  help="prefix for output anchors file names")
19 
20  return p.parse_args()
21 
22 
23 def main():
24  args = parse_args()
25  output = args.anchor_prefix
26  asmb = IMP.multifit.read_settings(args.assembly_file)
27  asmb.set_was_used(True)
28  dmap = IMP.em.read_map(asmb.get_assembly_header().get_dens_fn(),
30  if args.size == -1:
31  number_of_means = asmb.get_number_of_component_headers()
32  else:
33  total_num_residues = 0
34  mdl = IMP.Model()
35  for i in range(asmb.get_number_of_component_headers()):
36  total_num_residues += len(
37  IMP.atom.get_by_type(
39  asmb.get_component_header(
40  i).get_filename(
41  ),
42  mdl),
43  IMP.atom.RESIDUE_TYPE))
44  number_of_means = total_num_residues / args.size
45  print("Calculating a segmentation into", number_of_means, "regions")
46  density_threshold = asmb.get_assembly_header().get_threshold()
47 
48  IMP.multifit.get_anchors_for_density(dmap, number_of_means,
49  density_threshold,
50  output + ".pdb", output + ".cmm",
51  "", output + ".txt")
52 
53 
54 if __name__ == "__main__":
55  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.