IMP  2.0.0
The Integrative Modeling Platform
complex_to_anchor_graph.py
1 #!/usr/bin/env python
2 
3 from optparse import OptionParser
4 import IMP.em
5 import IMP.multifit
6 def main():
7  IMP.base.set_log_level(IMP.base.SILENT)
8  usage = "usage: %prog [options] <complex.pdb> <output: anchor_graph.cmm>\n Description: The script gets as input a PDB file of a complex and calculates an anchor graph,\n such that nodes corresponds to the centroids of its chains and \n edges are between chains that are close in space."
9  parser = OptionParser(usage)
10  (options, args) = parser.parse_args()
11  if len(args) != 2:
12  parser.error("incorrect number of arguments")
13  pdb_fn=args[0]
14  cmm_fn=args[1]
15  #read the protein
16  mdl=IMP.Model()
19  #find the centers of the individual chains
20  chains=IMP.atom.get_by_type(mh,IMP.atom.CHAIN_TYPE)
21  centers=[]
22  rbs=[]
23  for chain in chains:
24  ps=IMP.core.XYZs(IMP.core.get_leaves(chain))
25  centers.append(IMP.core.get_centroid(ps))
26  IMP.atom.setup_as_rigid_body(chain)
27  #fast calculations of which chains are close
28  links=[]
31  for id1,chain1 in enumerate(chains):
32  for id2,chain2 in enumerate(chains[id1+1:]):
33  #check if the bounding boxes are intersecting
34  if rdps.evaluate((chain1.get_particle(), chain2), None)<0.5:
35  links.append([id1,id1+id2+1])
36  #write the cmm file
37  output=open(cmm_fn,"w")
38  output.write('<marker_set name="centers_cryst">\n')
39  for id,c in enumerate(centers):
40  output.write('<marker id="'+str(id)+'" x="'+str(c[0])+'" y="'+str(c[1])+'" z="'+str(c[2])+ '" radius= "3.0" r= "0.9" g= "0.05" b= "0.18" />')
41  for id1,id2 in links:
42  output.write('<link id1="'+str(id1)+'" id2="'+str(id2)+'" radius="1."/>\n')
43  output.write('</marker_set>\n')
44 
45 if __name__ == "__main__":
46  main()