<div dir="ltr">ah i see, yes i had no movers or optimizers ... <div><br></div><div>so now i'm trying to set up a RigidBodyMover but i'm struggling to create the rigid bodies. There seem to be two different ways of doing this, either IMP.atom.create_rigid_body or IMP.atom.setup_as_rigid_body. <div>
<br></div><div>If I use create_rigid_body then when i later try to add restraints i get told "leaf 'A' ... does not have mass"</div><div><br></div><div>If I use setup_as_rigid_body i can add the restraints but i when i try to add it to the RigidBodyMover i get told "Rigid body passed to RigidBodyMover must be set to be optimized" even though rb.set_coordinates_are_optimized(True)</div>
<div><br></div><div>what is the function of choice here ?</div><div><br></div><div>thanks !</div><div><br></div><div>josh</div><div><br></div><div>------------------------------</div><div><br></div><div><div>def create_representation():</div>
<div>Â Â m= IMP.Model()</div><div>Â Â all=IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))</div><div>Â Â all.set_name("the universe")</div><div>Â Â # create a protein, represented as a set of connected balls of appropriate</div>
<div>Â Â # radii and number, chose by the resolution parameter and the number of</div><div>Â Â # amino acids.</div><div>Â Â Â </div><div>Â Â def create_protein_from_pdbs(name, files):</div><div>Â Â Â Â Â </div><div>Â Â Â Â def create_from_pdb(file):</div>
<div>Â Â Â Â Â Â sls=IMP.SetLogState(IMP.NONE)</div><div>Â Â Â Â Â Â datadir = os.getcwd()</div><div>Â Â Â Â Â Â print datadir</div><div><span class="" style="white-space:pre"> </span> Â Â t=IMP.atom.read_pdb( datadir+'/' + file, m,</div>
<div>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â IMP.atom.ATOMPDBSelector())</div><div>Â Â Â Â Â Â del sls</div><div>Â Â Â Â Â Â #IMP.atom.show_molecular_hierarchy(t)</div><div>Â Â Â Â Â Â c=IMP.atom.Chain(IMP.atom.get_by_type(t, IMP.atom.CHAIN_TYPE)[0])</div>
<div>Â Â Â Â Â Â Â </div><div>Â Â Â Â Â Â # there is no reason to use all atoms, just approximate the pdb shape instead</div><div>Â Â Â Â Â Â s=IMP.atom.create_simplified_along_backbone(c,1)</div><div>Â Â Â Â Â Â Â </div><div>
      # make the simplified structure rigid</div><div>      rb=IMP.atom.create_rigid_body(s) </div><div>      #rb=IMP.atom.setup_as_rigid_body(s) </div><div>      #rb=IMP.atom.create_rigid_body(c)</div>
<div>      rb.set_coordinates_are_optimized(True)</div><div>      print rb.get_coordinates_are_optimized()</div><div>       </div><div>      return rb         </div><div><br></div><div>    h= create_from_pdb(files[0])</div>
<div>Â Â Â Â h.set_name(name)</div><div>Â Â Â Â all.add_child(h)</div><div><br></div><div>Â Â create_protein_from_pdbs("A", [Firstpdb])</div></div><div><br></div><div>(m,all)= create_representation()<br></div></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On 11 July 2014 19:42, <span dir="ltr"><<a href="mailto:imp-users-request@salilab.org" target="_blank">imp-users-request@salilab.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Send IMP-users mailing list submissions to<br>
    <a href="mailto:imp-users@salilab.org">imp-users@salilab.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
    <a href="https://salilab.org/mailman/listinfo/imp-users" target="_blank">https://salilab.org/mailman/listinfo/imp-users</a><br>
or, via email, send a message with subject or body 'help' to<br>
    <a href="mailto:imp-users-request@salilab.org">imp-users-request@salilab.org</a><br>
<br>
You can reach the person managing the list at<br>
    <a href="mailto:imp-users-owner@salilab.org">imp-users-owner@salilab.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of IMP-users digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
  1. getting the MCCGsampler to work (Josh Bullock)<br>
  2. Re: getting the MCCGsampler to work (Ben Webb)<br>
  3. Re: getting the MCCGsampler to work (Ben Webb)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Fri, 11 Jul 2014 13:12:01 +0100<br>
From: Josh Bullock <<a href="mailto:jma.bullock@gmail.com">jma.bullock@gmail.com</a>><br>
To: <a href="mailto:imp-users@salilab.org">imp-users@salilab.org</a><br>
Subject: [IMP-users] getting the MCCGsampler to work<br>
Message-ID:<br>
    <<a href="mailto:CAHh_40_B9Ciag3LMdDMgFLJf2MCx2-tGPp3tmMke9MQriHwMJA@mail.gmail.com">CAHh_40_B9Ciag3LMdDMgFLJf2MCx2-tGPp3tmMke9MQriHwMJA@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hello again,<br>
<br>
So I have the same overall problem as before - creating an ensemble of a<br>
4-subunit complex using MSconnectivity restraints. Having visualised the<br>
output (via RMF - thanks Barak :?) , it's clear that no matter how many<br>
steps of CG or MC I put, the models do not change from their initial random<br>
placement. I know that the restraints are present because the models are<br>
evaluated and scored appropriately.<br>
<br>
So I saw on an old (2011) nup84 example that MCCG can't handle rigid<br>
bodies, is this still the case ? If so, should I switch to the DOMINO<br>
sampler ? or it does work and likely there's an error in my code ...<br>
<br>
Many thanks !<br>
<br>
Josh<br>
<br>
-------------------------------------------------<br>
<br>
import IMP<br>
import IMP.atom<br>
import IMP.rmf<br>
import inspect<br>
import IMP.container<br>
import IMP.display<br>
import IMP.statistics<br>
#import IMP.example<br>
import sys, math, os, optparse<br>
import RMF<br>
<br>
from optparse import OptionParser<br>
<br>
<br>
# Convert the arguments into strings and number<br>
Firstpdb = str(sys.argv[1])<br>
Secondpdb = str(sys.argv[2])<br>
Thirdpdb = str(sys.argv[3])<br>
Fourthpdb = str(sys.argv[4])<br>
models = float(sys.argv[5])<br>
<br>
#*****************************************<br>
<br>
# the spring constant to use, it doesnt really matter<br>
k=100<br>
# the target resolution for the representation, this is used to specify how<br>
detailed<br>
# the representation used should be<br>
resolution=300<br>
# the box to perform everything<br>
bb=IMP.algebra.BoundingBox3D(IMP.algebra.Vector3D(0,0,0),<br>
               IMP.algebra.Vector3D(100, 100, 100))<br>
<br>
<br>
# this function creates the molecular hierarchies for the various involved<br>
proteins<br>
def create_representation():<br>
  m= IMP.Model()<br>
  all=IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))<br>
  all.set_name("the universe")<br>
  # create a protein, represented as a set of connected balls of<br>
appropriate<br>
  # radii and number, chose by the resolution parameter and the number of<br>
  # amino acids.<br>
<br>
  def create_protein_from_pdbs(name, files):<br>
<br>
    def create_from_pdb(file):<br>
      sls=IMP.SetLogState(IMP.NONE)<br>
      datadir = os.getcwd()<br>
      print datadir<br>
  t=IMP.atom.read_pdb( datadir+'/' + file, m,<br>
                 IMP.atom.ATOMPDBSelector())<br>
      del sls<br>
      #IMP.atom.show_molecular_hierarchy(t)<br>
      c=IMP.atom.Chain(IMP.atom.get_by_type(t,<br>
IMP.atom.CHAIN_TYPE)[0])<br>
      if c.get_number_of_children()==0:<br>
        IMP.atom.show_molecular_hierarchy(t)<br>
      # there is no reason to use all atoms, just approximate the pdb<br>
shape instead<br>
      s=IMP.atom.create_simplified_along_backbone(c,<br>
                            1)<br>
      #IMP.atom.destroy(t)<br>
      # make the simplified structure rigid<br>
      rb=IMP.atom.create_rigid_body(s)<br>
      rb=IMP.atom.create_rigid_body(c)<br>
      rb.set_coordinates_are_optimized(True)<br>
      return s    # <------- swapping c with s will give a coarse<br>
grain representation - much faster !<br>
# Â Â Â Â Â Â return c<br>
<br>
    h= create_from_pdb(files[0])<br>
    h.set_name(name)<br>
    all.add_child(h)<br>
<br>
  create_protein_from_pdbs("A", [Firstpdb])<br>
  create_protein_from_pdbs("B", [Secondpdb])<br>
  create_protein_from_pdbs("C", [Thirdpdb])<br>
  create_protein_from_pdbs("D", [Fourthpdb])<br>
  #create_protein_from_pdbs("C", ["rpt3_imp.pdb"])<br>
  return (m, all)<br>
<br>
# create the needed restraints and add them to the model<br>
<br>
def create_restraints(m, all):<br>
  def add_connectivity_restraint(s):<br>
<br>
    tr= IMP.core.TableRefiner()<br>
    rps=[]<br>
    for sc in s:<br>
      ps= sc.get_selected_particles()<br>
      rps.append(ps[0])<br>
      tr.add_particle(ps[0], ps)<br>
<br>
    # duplicate the IMP.atom.create_connectivity_restraint functionality<br>
<br>
    score=<br>
IMP.core.KClosePairsPairScore(IMP.core.HarmonicSphereDistancePairScore(0,1),tr)<br>
<br>
    #ub = IMP.core.HarmonicUpperBound(1.0, 0.1)<br>
    #ss = IMP.core.DistancePairScore(ub)<br>
<br>
    r= IMP.core.MSConnectivityRestraint(m,score)<br>
<br>
    iA = r.add_type([rps[0]])<br>
    iB = r.add_type([rps[1]])<br>
    iC = r.add_type([rps[2]])<br>
    iD = r.add_type([rps[3]])<br>
    #n1 = r.add_composite([iA, iB])<br>
    n1 = r.add_composite([iA, iB, iC, iD])<br>
    n2 = r.add_composite([iA, iB],n1)<br>
    n3 = r.add_composite([iB, iD],n1)<br>
    n4 = r.add_composite([iA, iB, iC],n1)<br>
    n5 = r.add_composite([iB, iC, iD],n1)<br>
<br>
    m.add_restraint(r)<br>
<br>
  evr=IMP.atom.create_excluded_volume_restraint([all])<br>
  m.add_restraint(evr)<br>
  # a Selection allows for natural specification of what the restraints<br>
act on<br>
  S= IMP.atom.Selection<br>
  sA=S(hierarchy=all, molecule="A")<br>
  sB=S(hierarchy=all, molecule="B")<br>
  sC=S(hierarchy=all, molecule="C")<br>
  sD=S(hierarchy=all, molecule="D")<br>
  add_connectivity_restraint([sA, sB, sC, sD])<br>
<br>
  nbl = IMP.container.ClosePairContainer([all], 0, 2)<br>
  h = IMP.core.HarmonicLowerBound(0, 1)<br>
  sd = IMP.core.SphereDistancePairScore(h)<br>
  # use the lower bound on the inter-sphere distance to push the spheres<br>
apart<br>
  nbr = IMP.container.PairsRestraint(sd, nbl)<br>
  m.add_restraint(nbr)<br>
<br>
<br>
  # r1 = IMP.core.ExcludedVolumeRestraint(all)<br>
  # m.add_restraint(r1)<br>
<br>
<br>
# find acceptable conformations of the model<br>
def get_conformations(m):<br>
  sampler= IMP.core.MCCGSampler(m)<br>
  sampler.set_bounding_box(bb)<br>
  # magic numbers, experiment with them and make them large enough for<br>
things to work<br>
  sampler.set_number_of_conjugate_gradient_steps(200)<br>
  sampler.set_number_of_monte_carlo_steps(40)<br>
  sampler.set_number_of_attempts(models)<br>
  # We don't care to see the output from the sampler<br>
  #sampler.set_log_level(IMP.SILENT)<br>
  # return the IMP.ConfigurationSet storing all the found configurations<br>
that<br>
  # meet the various restraint maximum scores.<br>
  cs= sampler.create_sample()<br>
  return cs<br>
<br>
<br>
# cluster the conformations and write them to a file<br>
def analyze_conformations(cs, all, gs):<br>
  # we want to cluster the configurations to make them easier to<br>
understand<br>
  # in this case, the clustering is pretty meaningless<br>
  embed= IMP.statistics.ConfigurationSetXYZEmbedding(cs,<br>
<br>
 IMP.container.ListSingletonContainer(IMP.atom.get_leaves(all)), True)<br>
  cluster= IMP.statistics.create_lloyds_kmeans(embed, 10, 10000)<br>
  # dump each cluster center to a file so it can be viewed.<br>
  for i in range(cluster.get_number_of_clusters()):<br>
    center= cluster.get_cluster_center(i)<br>
    cs.load_configuration(i)<br>
    h = IMP.atom.Hierarchy.get_children(all)<br>
    #tfn = IMP.create_temporary_file_name("cluster%d"%i, ".rmf")<br>
    huh = "./models/CLUSTER%d"%i<br>
    huh = huh +".rmf"<br>
    #print "file is", tfn<br>
    print "file is", huh<br>
    rh = RMF.create_rmf_file(huh)<br>
<br>
<br>
    IMP.rmf.add_hierarchies(rh, h)<br>
<br>
    # add the current configuration to the file as frame 0<br>
    IMP.rmf.save_frame(rh)<br>
<br>
    #for g in gs:<br>
     #  rh.add_geometry(g)<br>
<br>
<br>
#******************************************************************************************<br>
# now do the actual work<br>
<br>
(m,all)= create_representation()<br>
#IMP.atom.show_molecular_hierarchy(all)<br>
create_restraints(m, all)<br>
<br>
# in order to display the results, we need something that maps the<br>
particles onto<br>
# geometric objets. The IMP.display.Geometry objects do this mapping.<br>
# IMP.display.XYZRGeometry map an IMP.core.XYZR particle onto a sphere<br>
gs=[]<br>
for i in range(all.get_number_of_children()):<br>
  color= IMP.display.get_display_color(i)<br>
  n= all.get_child(i)<br>
  name= n.get_name()<br>
  g= IMP.atom.HierarchyGeometry(n)<br>
  g.set_color(color)<br>
  gs.append(g)<br>
<br>
cs= get_conformations(m)<br>
<br>
print "found", cs.get_number_of_configurations(), "solutions"<br>
<br>
ListScores = []<br>
for i in range(0, cs.get_number_of_configurations()):<br>
    cs.load_configuration(i)<br>
    # print the configuration<br>
    print "solution number: ",i,"scored :", m.evaluate(False)<br>
    ListScores.append(m.evaluate(False))<br>
<br>
# for each of the configuration, dump it to a file to view in pymol<br>
for i in range(0, cs.get_number_of_configurations()):<br>
  cs.load_configuration(i)<br>
  h = IMP.atom.Hierarchy.get_children(all)<br>
  #tfn = IMP.create_temporary_file_name("josh%d"%i, ".rmf")<br>
  #print "file is", tfn<br>
  huh = "./models/IMP%d"%i<br>
  huh = huh +".rmf"<br>
  print "file is", huh<br>
  rh = RMF.create_rmf_file(huh)<br>
<br>
  # add the hierarchy to the file<br>
  IMP.rmf.add_hierarchies(rh, h)<br>
<br>
  # add the current configuration to the file as frame 0<br>
  IMP.rmf.save_frame(rh)<br>
<br>
  #for g in gs:<br>
   #  w.add_geometry(g)<br>
<br>
analyze_conformations(cs, all, gs)<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://salilab.org/archives/imp-users/attachments/20140711/fc50f2fe/attachment.html" target="_blank">http://salilab.org/archives/imp-users/attachments/20140711/fc50f2fe/attachment.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Fri, 11 Jul 2014 11:26:24 -0700<br>
From: Ben Webb <<a href="mailto:ben@salilab.org">ben@salilab.org</a>><br>
To: Help and discussion for users of IMP <<a href="mailto:imp-users@salilab.org">imp-users@salilab.org</a>><br>
Subject: Re: [IMP-users] getting the MCCGsampler to work<br>
Message-ID: <<a href="mailto:53C02C50.4020507@salilab.org">53C02C50.4020507@salilab.org</a>><br>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br>
<br>
On 7/11/14, 5:12 AM, Josh Bullock wrote:<br>
> So I have the same overall problem as before - creating an ensemble of a<br>
> 4-subunit complex using MSconnectivity restraints. Having visualised the<br>
> output (via RMF - thanks Barak :?) , it's clear that no matter how many<br>
> steps of CG or MC I put, the models do not change from their initial<br>
> random placement. I know that the restraints are present because the<br>
> models are evaluated and scored appropriately.<br>
<br>
A sampler that ignores the scoring function would be pretty useless!<br>
Obviously MCCG doesn't do that. So my guess would be that you didn't add<br>
the restraints to the scoring function, the thresholds are all wrong (so<br>
that no MC moves are ever accepted), you have terrible starting<br>
conditions (so that the optimizer can never improve the score) or you<br>
have a poor choice of MC move set. I don't see you actually adding any<br>
Movers to your sampler in the script, so I'd suspect the last one. The<br>
underlying MonteCarlo class keeps some statistics (e.g. number of<br>
accepted/rejected moves) which might shed some light on what's going on.<br>
<br>
> So I saw on an old (2011) nup84 example that MCCG can't handle rigid<br>
> bodies, is this still the case ?<br>
<br>
No. You just need to add a suitable RigidBodyMover.<br>
<br>
> If so, should I switch to the DOMINO<br>
> sampler ?<br>
<br>
DOMINO enumerates in a discrete space, so is a rather different kind of<br>
optimizer. It is probably not the best choice in your case.<br>
<br>
    Ben<br>
--<br>
<a href="mailto:ben@salilab.org">ben@salilab.org</a> Â Â Â Â Â Â Â Â Â Â Â <a href="http://salilab.org/~ben/" target="_blank">http://salilab.org/~ben/</a><br>
"It is a capital mistake to theorize before one has data."<br>
    - Sir Arthur Conan Doyle<br>
<br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Fri, 11 Jul 2014 11:42:19 -0700<br>
From: Ben Webb <<a href="mailto:ben@salilab.org">ben@salilab.org</a>><br>
To: Help and discussion for users of IMP <<a href="mailto:imp-users@salilab.org">imp-users@salilab.org</a>><br>
Subject: Re: [IMP-users] getting the MCCGsampler to work<br>
Message-ID: <<a href="mailto:53C0300B.5010504@salilab.org">53C0300B.5010504@salilab.org</a>><br>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br>
<br>
To clarify a little, the MCCGSampler tries to wrap a common use of the<br>
underlying MonteCarlo optimizer (that use case being a bunch of<br>
independently movable x,y,z particles). If in your case you actually<br>
have a bunch of rigid bodies, you should probably use the MonteCarlo<br>
optimizer directly and add RigidBodyMovers to it.<br>
<br>
    Ben<br>
--<br>
<a href="mailto:ben@salilab.org">ben@salilab.org</a> Â Â Â Â Â Â Â Â Â Â Â <a href="http://salilab.org/~ben/" target="_blank">http://salilab.org/~ben/</a><br>
"It is a capital mistake to theorize before one has data."<br>
    - Sir Arthur Conan Doyle<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
IMP-users mailing list<br>
<a href="mailto:IMP-users@salilab.org">IMP-users@salilab.org</a><br>
<a href="https://salilab.org/mailman/listinfo/imp-users" target="_blank">https://salilab.org/mailman/listinfo/imp-users</a><br>
<br>
<br>
End of IMP-users Digest, Vol 38, Issue 15<br>
*****************************************<br>
</blockquote></div><br></div></div>