<div dir="ltr">Which lines throws the error? </div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 2, 2014 at 4:56 AM, Josh Bullock <span dir="ltr">&lt;<a href="mailto:jma.bullock@gmail.com" target="_blank">jma.bullock@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Barek,<div><br></div><div>So I&#39;m not giving hierarchy.get_children the correct input:</div><div>
<br>
</div><div>TypeError: unbound method get_children() must be called with Hierarchy instance as first argument (got ConfigurationSet instance instead)</div>
<div><br></div><div>I&#39;m not sure which argument is the hierarchy instance. </div><div><br></div><div>Thanks,</div><div><br></div><div>Josh<br><div class="gmail_extra"><br></div><div class="gmail_extra">-------------------------------------------------</div>


<div class="gmail_extra"><br></div><div class="gmail_extra">cs= get_conformations(m)<br></div><div class="gmail_extra"><br><div class="gmail_extra">for i in range(0, cs.get_number_of_configurations()):</div><div class="gmail_extra">


    JOSH = cs.load_configuration(i)</div><div class="gmail_extra">    S= IMP.atom.Selection</div><div class="gmail_extra">    h= IMP.atom.Hierarchy.get_children(cs)</div><div class="gmail_extra">    tfn = IMP.create_temporary_file_name(&quot;josh%d&quot;%i, &quot;.rmf&quot;)</div>


<div class="gmail_extra">    rh = RMF.create_rmf_file(tfn)</div><div class="gmail_extra"><br></div><div class="gmail_quote">On 1 July 2014 17:31,  <span dir="ltr">&lt;<a href="mailto:imp-users-request@salilab.org" target="_blank">imp-users-request@salilab.org</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Send IMP-users mailing list submissions to<br>
        <a href="mailto:imp-users@salilab.org" target="_blank">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 &#39;help&#39; to<br>
        <a href="mailto:imp-users-request@salilab.org" target="_blank">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" target="_blank">imp-users-owner@salilab.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of IMP-users digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1. Re: Sampling and writing to pym/rmf (Barak Raveh)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Tue, 1 Jul 2014 09:31:33 -0700<br>
From: Barak Raveh &lt;<a href="mailto:barak.raveh@gmail.com" target="_blank">barak.raveh@gmail.com</a>&gt;<br>
To: Help and discussion for users of IMP &lt;<a href="mailto:imp-users@salilab.org" target="_blank">imp-users@salilab.org</a>&gt;<br>
Subject: Re: [IMP-users] Sampling and writing to pym/rmf<br>
Message-ID:<br>
        &lt;CAHp+_UowiBwJozbwOfi8yFEVt7Z8o2tEZ=<a href="mailto:LvYPnJh-LjpC2cSA@mail.gmail.com" target="_blank">LvYPnJh-LjpC2cSA@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
Hi Josh, from a very superficial look, your code to write the RMF files<br>
seems fine - do you get an output RMF file? Could you load it in Chimera?<br>
<br>
<br>
On Tue, Jul 1, 2014 at 2:40 AM, Josh Bullock &lt;<a href="mailto:jma.bullock@gmail.com" target="_blank">jma.bullock@gmail.com</a>&gt; wrote:<br>
<br>
&gt; Hello,<br>
&gt;<br>
&gt; I&#39;m relatively new to all this so please let me know if i&#39;m making any<br>
&gt; obvious errors ...<br>
&gt;<br>
&gt; Essentially all i&#39;m trying to do is generate an ensemble of models made<br>
&gt; from four subunits - constrained by MS connectivity restraints. The models<br>
&gt; get scored but nothing seems to write to the pymol file. Ideally i&#39;d like<br>
&gt; to write to an .rmf but i haven&#39;t worked that one out either ...<br>
&gt;<br>
&gt; Is this a reasonable way to go about my problem ?<br>
&gt;<br>
&gt; Many thanks,<br>
&gt;<br>
&gt; Josh<br>
&gt;<br>
&gt; -------------------------------------------<br>
&gt;<br>
&gt; import IMP<br>
&gt; import IMP.atom<br>
&gt; import IMP.rmf<br>
&gt; import inspect<br>
&gt; import IMP.container<br>
&gt; import IMP.display<br>
&gt; import IMP.statistics<br>
&gt; #import IMP.example<br>
&gt; import sys, math, os, optparse<br>
&gt; import RMF<br>
&gt;<br>
&gt; from optparse import OptionParser<br>
&gt;<br>
&gt;<br>
&gt; # Convert the arguments into strings and number<br>
&gt; Firstpdb = str(sys.argv[1])<br>
&gt; Secondpdb = str(sys.argv[2])<br>
&gt; Thirdpdb = str(sys.argv[3])<br>
&gt; Fourthpdb = str(sys.argv[4])<br>
&gt; models = float(sys.argv[5])<br>
&gt;<br>
&gt; #*****************************************<br>
&gt;<br>
&gt; # the spring constant to use, it doesnt really matter<br>
&gt; k=100<br>
&gt; # the target resolution for the representation, this is used to specify<br>
&gt; how detailed<br>
&gt; # the representation used should be<br>
&gt; resolution=300<br>
&gt; # the box to perform everything<br>
&gt; bb=IMP.algebra.BoundingBox3D(IMP.algebra.Vector3D(0,0,0),<br>
&gt;                              IMP.algebra.Vector3D(300, 300, 300))<br>
&gt;<br>
&gt;<br>
&gt; # this function creates the molecular hierarchies for the various involved<br>
&gt; proteins<br>
&gt; def create_representation():<br>
&gt;     m= IMP.Model()<br>
&gt;     all=IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))<br>
&gt;     all.set_name(&quot;the universe&quot;)<br>
&gt;     # create a protein, represented as a set of connected balls of<br>
&gt; appropriate<br>
&gt;     # radii and number, chose by the resolution parameter and the number of<br>
&gt;     # amino acids.<br>
&gt;<br>
&gt;     def create_protein_from_pdbs(name, files):<br>
&gt;<br>
&gt;         def create_from_pdb(file):<br>
&gt;             sls=IMP.SetLogState(IMP.NONE)<br>
&gt;             datadir = os.getcwd()<br>
&gt;             print datadir<br>
&gt;     t=IMP.atom.read_pdb( datadir+&#39;/&#39; + file, m,<br>
&gt;                                  IMP.atom.ATOMPDBSelector())<br>
&gt;             del sls<br>
&gt;             #IMP.atom.show_molecular_hierarchy(t)<br>
&gt;             c=IMP.atom.Chain(IMP.atom.get_by_type(t,<br>
&gt; IMP.atom.CHAIN_TYPE)[0])<br>
&gt;             if c.get_number_of_children()==0:<br>
&gt;                 IMP.atom.show_molecular_hierarchy(t)<br>
&gt;             # there is no reason to use all atoms, just approximate the<br>
&gt; pdb shape instead<br>
&gt;             s=IMP.atom.create_simplified_along_backbone(c,<br>
&gt;                                                         resolution/300.0)<br>
&gt;             IMP.atom.destroy(t)<br>
&gt;             # make the simplified structure rigid<br>
&gt;             rb=IMP.atom.create_rigid_body(s)<br>
&gt; #            rb=IMP.atom.create_rigid_body(c)<br>
&gt;             rb.set_coordinates_are_optimized(True)<br>
&gt;             return s<br>
&gt; #            return c<br>
&gt;<br>
&gt;         h= create_from_pdb(files[0])<br>
&gt;         h.set_name(name)<br>
&gt;         all.add_child(h)<br>
&gt;<br>
&gt;     create_protein_from_pdbs(&quot;A&quot;, [Firstpdb])<br>
&gt;     create_protein_from_pdbs(&quot;B&quot;, [Secondpdb])<br>
&gt;     create_protein_from_pdbs(&quot;C&quot;, [Thirdpdb])<br>
&gt;     create_protein_from_pdbs(&quot;D&quot;, [Fourthpdb])<br>
&gt;     #create_protein_from_pdbs(&quot;C&quot;, [&quot;rpt3_imp.pdb&quot;])<br>
&gt;     return (m, all)<br>
&gt;<br>
&gt; # create the needed restraints and add them to the model<br>
&gt;<br>
&gt; def create_restraints(m, all):<br>
&gt;     def add_connectivity_restraint(s):<br>
&gt;<br>
&gt;         tr= IMP.core.TableRefiner()<br>
&gt;         rps=[]<br>
&gt;         for sc in s:<br>
&gt;             ps= sc.get_selected_particles()<br>
&gt;             rps.append(ps[0])<br>
&gt;             tr.add_particle(ps[0], ps)<br>
&gt;<br>
&gt;         # duplicate the IMP.atom.create_connectivity_restraint<br>
&gt; functionality<br>
&gt;<br>
&gt;         score=<br>
&gt; IMP.core.KClosePairsPairScore(IMP.core.HarmonicSphereDistancePairScore(0,1),tr)<br>
&gt;<br>
&gt;         r= IMP.core.MSConnectivityRestraint(m,score)<br>
&gt;<br>
&gt;         iA = r.add_type([rps[0]])<br>
&gt;         iB = r.add_type([rps[1]])<br>
&gt;         iC = r.add_type([rps[2]])<br>
&gt;         iD = r.add_type([rps[3]])<br>
&gt;         n1 = r.add_composite([iA, iB, iC, iD])<br>
&gt;         n2 = r.add_composite([iA, iB], n1)<br>
&gt;         n3 = r.add_composite([iC, iD], n1)<br>
&gt;         n4 = r.add_composite([iB, iC, iD], n1)<br>
&gt;<br>
&gt;         m.add_restraint(r)<br>
&gt;<br>
&gt;     evr=IMP.atom.create_excluded_volume_restraint([all])<br>
&gt;     m.add_restraint(evr)<br>
&gt;     # a Selection allows for natural specification of what the restraints<br>
&gt; act on<br>
&gt;     S= IMP.atom.Selection<br>
&gt;     sA=S(hierarchy=all, molecule=&quot;A&quot;)<br>
&gt;     sB=S(hierarchy=all, molecule=&quot;B&quot;)<br>
&gt;     sC=S(hierarchy=all, molecule=&quot;C&quot;)<br>
&gt;     sD=S(hierarchy=all, molecule=&quot;D&quot;)<br>
&gt;     add_connectivity_restraint([sA, sB, sC, sD])<br>
&gt;<br>
&gt;<br>
&gt; # find acceptable conformations of the model<br>
&gt; def get_conformations(m):<br>
&gt;     sampler= IMP.core.MCCGSampler(m)<br>
&gt;     sampler.set_bounding_box(bb)<br>
&gt;     # magic numbers, experiment with them and make them large enough for<br>
&gt; things to work<br>
&gt;     sampler.set_number_of_conjugate_gradient_steps(100)<br>
&gt;     sampler.set_number_of_monte_carlo_steps(20)<br>
&gt;     sampler.set_number_of_attempts(models)<br>
&gt;     # We don&#39;t care to see the output from the sampler<br>
&gt;     sampler.set_log_level(IMP.SILENT)<br>
&gt;     # return the IMP.ConfigurationSet storing all the found configurations<br>
&gt; that<br>
&gt;     # meet the various restraint maximum scores.<br>
&gt;     cs= sampler.create_sample()<br>
&gt;     return cs<br>
&gt;<br>
&gt;<br>
&gt; # cluster the conformations and write them to a file<br>
&gt; def analyze_conformations(cs, all, gs):<br>
&gt;     # we want to cluster the configurations to make them easier to<br>
&gt; understand<br>
&gt;     # in the case, the clustering is pretty meaningless<br>
&gt;     embed= IMP.statistics.ConfigurationSetXYZEmbedding(cs,<br>
&gt;<br>
&gt;  IMP.container.ListSingletonContainer(IMP.atom.get_leaves(all)), True)<br>
&gt;     cluster= IMP.statistics.create_lloyds_kmeans(embed, 10, 10000)<br>
&gt;     # dump each cluster center to a file so it can be viewed.<br>
&gt;     for i in range(cluster.get_number_of_clusters()):<br>
&gt;         center= cluster.get_cluster_center(i)<br>
&gt;         cs.load_configuration(i)<br>
&gt;         w= IMP.display.PymolWriter(&quot;cluster.%d.pym&quot;%i)<br>
&gt;         for g in gs:<br>
&gt;             w.add_geometry(g)<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; #******************************************************************************************<br>
&gt; # now do the actual work<br>
&gt;<br>
&gt; (m,all)= create_representation()<br>
&gt; IMP.atom.show_molecular_hierarchy(all)<br>
&gt; create_restraints(m, all)<br>
&gt;<br>
&gt; # in order to display the results, we need something that maps the<br>
&gt; particles onto<br>
&gt; # geometric objets. The IMP.display.Geometry objects do this mapping.<br>
&gt; # IMP.display.XYZRGeometry map an IMP.core.XYZR particle onto a sphere<br>
&gt; gs=[]<br>
&gt; for i in range(all.get_number_of_children()):<br>
&gt;     color= IMP.display.get_display_color(i)<br>
&gt;     n= all.get_child(i)<br>
&gt;     name= n.get_name()<br>
&gt;     g= IMP.atom.HierarchyGeometry(n)<br>
&gt;     g.set_color(color)<br>
&gt;     gs.append(g)<br>
&gt;<br>
&gt; cs= get_conformations(m)<br>
&gt;<br>
&gt; print &quot;found&quot;, cs.get_number_of_configurations(), &quot;solutions&quot;<br>
&gt;<br>
&gt; ListScores = []<br>
&gt; for i in range(0, cs.get_number_of_configurations()):<br>
&gt;         cs.load_configuration(i)<br>
&gt;         # print the configuration<br>
&gt;         print &quot;solution number: &quot;,i,&quot;scored :&quot;, m.evaluate(False)<br>
&gt;         ListScores.append(m.evaluate(False))<br>
&gt;<br>
&gt; f1 = open(&quot;out_scores.csv&quot;, &quot;w&quot;)<br>
&gt; f1.write(&quot;\n&quot;.join(map(lambda x: str(x), ListScores)))<br>
&gt; f1.close()<br>
&gt;<br>
&gt; # for each of the configuration, dump it to a file to view in pymol<br>
&gt; for i in range(0, cs.get_number_of_configurations()):<br>
&gt;     JOSH = cs.load_configuration(i)<br>
&gt;     S= IMP.atom.Selection<br>
&gt;     h= IMP.atom.Hierarchy.get_children(cs)<br>
&gt;     tfn = IMP.create_temporary_file_name(&quot;josh%d&quot;%i, &quot;.rmf&quot;)<br>
&gt;     rh = RMF.create_rmf_file(tfn)<br>
&gt;<br>
&gt;     # add the hierarchy to the file<br>
&gt;     IMP.rmf.add_hierarchies(rh, h)<br>
&gt;<br>
&gt;     # add the current configuration to the file as frame 0<br>
&gt;     IMP.rmf.save_frame(rh)<br>
&gt;<br>
&gt;     for g in gs:<br>
&gt;         w.add_geometry(g)<br>
&gt;<br>
&gt; analyze_conformations(cs, all, gs)<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; IMP-users mailing list<br>
&gt; <a href="mailto:IMP-users@salilab.org" target="_blank">IMP-users@salilab.org</a><br>
&gt; <a href="https://salilab.org/mailman/listinfo/imp-users" target="_blank">https://salilab.org/mailman/listinfo/imp-users</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
--<br>
Barak<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: &lt;<a href="http://salilab.org/archives/imp-users/attachments/20140701/7b0e5f9f/attachment.html" target="_blank">http://salilab.org/archives/imp-users/attachments/20140701/7b0e5f9f/attachment.html</a>&gt;<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
IMP-users mailing list<br>
<a href="mailto:IMP-users@salilab.org" target="_blank">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 2<br>
****************************************<br>
</blockquote></div><br></div></div></div>
<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></blockquote></div><br><br clear="all"><div><br></div>-- <br>Barak
</div>