IMP  2.1.1
The Integrative Modeling Platform
anchors.py
1 #!/usr/bin/env python
2 
3 __doc__ = "Generate anchors for a density map."
4 
5 import IMP.multifit
6 import IMP.em
7 from IMP import OptionParser
8 
9 def parse_args():
10  usage = """%prog [options] <assembly input> <output anchors prefix>
11 
12 Generate anchors for a density map."""
13  parser = OptionParser(usage)
14  parser.add_option("-s", "--size", type="int", dest="size", default=-1,
15  help="number of residues per bead")
16  options, args = parser.parse_args()
17 
18 
19  if len(args) != 2:
20  parser.error("incorrect number of arguments")
21  return options,args
22 
23 
24 def main():
25  options,args=parse_args()
26  asmb_fn=args[0]
27  output=args[1]
28  asmb = IMP.multifit.read_settings(asmb_fn)
29  asmb.set_was_used(True)
30  dmap = IMP.em.read_map(asmb.get_assembly_header().get_dens_fn(),
32  if options.size==-1:
33  number_of_means = asmb.get_number_of_component_headers()
34  else:
35  total_num_residues=0
36  mdl=IMP.kernel.Model()
37  for i in range(asmb.get_number_of_component_headers()):
38  total_num_residues+=len(IMP.atom.get_by_type(IMP.atom.read_pdb(asmb.get_component_header(i).get_filename(),mdl),IMP.atom.RESIDUE_TYPE))
39  number_of_means=total_num_residues/options.size
40  print "Calculating a segmentation into",number_of_means,"regions"
41  density_threshold = asmb.get_assembly_header().get_threshold()
42 
43  IMP.multifit.get_anchors_for_density(dmap, number_of_means,
44  density_threshold,
45  output+".pdb", output+".cmm",
46  "", output+".txt")
47 
48 if __name__=="__main__":
49  main()
SettingsData * read_settings(const char *filename)
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
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.
See IMP.multifit for more information.
See IMP.em for more information.
Definition: CoarseCC.h:23
DensityMap * read_map(std::string filename)
IMP::kernel::OptionParser OptionParser
void read_pdb(base::TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.