<div dir="ltr">* I meant <div><br></div><div><div style="font-family:arial,sans-serif;font-size:13px">h = IMP.atom.Hierarchy(p)</div><div style="font-family:arial,sans-serif;font-size:13px">c = p.get_children(h)</div></div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">this assumes that particle p was already decorated as Hierarchy (let me know if you are not familiar with decorators, Hierarchy, or Particle).</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 2, 2014 at 3:02 PM, Barak Raveh <span dir="ltr"><<a href="mailto:barak.raveh@gmail.com" target="_blank">barak.raveh@gmail.com</a>></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 Josh, <div><br><div>I think get_children() is only a member function of Hierarchy, so you should do something like</div>
<div><br></div><div>IMP.atom.Hierarchy(p)</div><div>c = p.get_children()<br><div><div class="gmail_extra">
<br></div><div class="gmail_extra">'cs' seems to be a ConfigurationSet object - are you sure that you expect it to have children?</div><div class="gmail_extra"><br></div><div class="gmail_extra">What do you want to do?</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Cheers,</div><div class="gmail_extra">Barak</div><div><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 2, 2014 at 1:42 PM, Josh Bullock <span dir="ltr"><<a href="mailto:jma.bullock@gmail.com" target="_blank">jma.bullock@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">ah sorry ! this line gives me the error<div class="gmail_extra"><br></div><div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:13px">h= IMP.atom.Hierarchy.get_</span><span style="font-family:arial,sans-serif;font-size:13px">children(cs)</span></div>
<div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">thanks</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div>
<div class="gmail_extra"><font face="arial, sans-serif">josh<br></font><br><div class="gmail_quote">On 2 July 2014 17:45, <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: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 'help' 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 "Re: Contents of IMP-users digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
  1. Re: Sampling and writing to pym/rmf (Barak Raveh) (Barak Raveh)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Wed, 2 Jul 2014 09:45:30 -0700<br>
From: Barak Raveh <<a href="mailto:barak.raveh@gmail.com" target="_blank">barak.raveh@gmail.com</a>><br>
To: Help and discussion for users of IMP <<a href="mailto:imp-users@salilab.org" target="_blank">imp-users@salilab.org</a>><br>
Subject: Re: [IMP-users] Sampling and writing to pym/rmf (Barak Raveh)<br>
Message-ID:<br>
    <CAHp+_Uo19VasJDJYi+2CoUUu=<a href="mailto:u_6duKCraVetU4dW45%2BoDhTAw@mail.gmail.com" target="_blank">u_6duKCraVetU4dW45+oDhTAw@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Which lines throws the error?<br>
<br>
<br>
On Wed, Jul 2, 2014 at 4:56 AM, Josh Bullock <<a href="mailto:jma.bullock@gmail.com" target="_blank">jma.bullock@gmail.com</a>> wrote:<br>
<br>
> Hi Barek,<br>
><br>
> So I'm not giving hierarchy.get_children the correct input:<br>
><br>
> TypeError: unbound method get_children() must be called with Hierarchy<br>
> instance as first argument (got ConfigurationSet instance instead)<br>
><br>
> I'm not sure which argument is the hierarchy instance.<br>
><br>
> Thanks,<br>
><br>
> Josh<br>
><br>
> -------------------------------------------------<br>
><br>
> cs= get_conformations(m)<div><br>
><br>
> for i in range(0, cs.get_number_of_configurations()):<br>
> Â Â JOSH = cs.load_configuration(i)<br>
> Â Â S= IMP.atom.Selection<br>
> Â Â h= IMP.atom.Hierarchy.get_children(cs)<br>
> Â Â tfn = IMP.create_temporary_file_name("josh%d"%i, ".rmf")<br>
> Â Â rh = RMF.create_rmf_file(tfn)<br>
><br></div>
> On 1 July 2014 17:31, <<a href="mailto:imp-users-request@salilab.org" target="_blank">imp-users-request@salilab.org</a>> wrote:<br>
><br>
>> 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 'help' 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 "Re: Contents of IMP-users digest..."<br>
>><br>
>><br>
>> Today'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 <<a href="mailto:barak.raveh@gmail.com" target="_blank">barak.raveh@gmail.com</a>><br>
>> To: Help and discussion for users of IMP <<a href="mailto:imp-users@salilab.org" target="_blank">imp-users@salilab.org</a>><br>
>> Subject: Re: [IMP-users] Sampling and writing to pym/rmf<br>
>> Message-ID:<br>
>> Â Â Â Â <CAHp+_UowiBwJozbwOfi8yFEVt7Z8o2tEZ=<br>
>> <a href="mailto:LvYPnJh-LjpC2cSA@mail.gmail.com" target="_blank">LvYPnJh-LjpC2cSA@mail.gmail.com</a>><br>
>> Content-Type: text/plain; charset="utf-8"<div><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 <<a href="mailto:jma.bullock@gmail.com" target="_blank">jma.bullock@gmail.com</a>><br>
>> wrote:<br>
>><br>
>> > Hello,<br>
>> ><br>
>> > I'm relatively new to all this so please let me know if i'm making any<br>
>> > obvious errors ...<br>
>> ><br></div><div>
>> > Essentially all i'm trying to do is generate an ensemble of models made<br>
>> > from four subunits - constrained by MS connectivity restraints. The<br>
>> models<br>
>> > get scored but nothing seems to write to the pymol file. Ideally i'd<br>
>> like<br>
>> > to write to an .rmf but i haven't worked that one out either ...<br>
>> ><br></div><div><div>
>> > Is this a reasonable way to go about my problem ?<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<br>
>> > how 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(300, 300, 300))<br>
>> ><br>
>> ><br>
>> > # this function creates the molecular hierarchies for the various<br>
>> 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<br>
>> 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<br>
>> > pdb shape instead<br>
>> > Â Â Â Â Â Â s=IMP.atom.create_simplified_along_backbone(c,<br>
>> ><br>
>> resolution/300.0)<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<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<br>
>> > functionality<br>
>> ><br>
>> > Â Â Â Â score=<br>
>> ><br>
>> IMP.core.KClosePairsPairScore(IMP.core.HarmonicSphereDistancePairScore(0,1),tr)<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, iC, iD])<br>
>> > Â Â Â Â n2 = r.add_composite([iA, iB], n1)<br>
>> > Â Â Â Â n3 = r.add_composite([iC, iD], n1)<br>
>> > Â Â Â Â n4 = 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<br>
>> 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>
>> ><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(100)<br>
>> > Â Â sampler.set_number_of_monte_carlo_steps(20)<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<br>
>> 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 the 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>
>> > Â Â Â Â w= IMP.display.PymolWriter("cluster.%d.pym"%i)<br>
>> > Â Â Â Â for g in gs:<br>
>> > Â Â Â Â Â Â w.add_geometry(g)<br>
>> ><br>
>> ><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>
>> > f1 = open("out_scores.csv", "w")<br>
>> > f1.write("\n".join(map(lambda x: str(x), ListScores)))<br>
>> > f1.close()<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>
>> > Â Â JOSH = cs.load_configuration(i)<br>
>> > Â Â S= IMP.atom.Selection<br>
>> > Â Â h= IMP.atom.Hierarchy.get_children(cs)<br>
>> > Â Â tfn = IMP.create_temporary_file_name("josh%d"%i, ".rmf")<br>
>> > Â Â rh = RMF.create_rmf_file(tfn)<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>
>> ><br>
>> ><br></div></div><div>
>> > _______________________________________________<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>
>><br>
>><br></div>
>> --<br>
>> Barak<br>
>> -------------- next part --------------<br>
>> An HTML attachment was scrubbed...<br>
>> URL: <<br>
>> <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><br>
>> ><br>
>><br>
>> ------------------------------<div><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></div>
>> End of IMP-users Digest, Vol 38, Issue 2<br>
>> ****************************************<div><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>
<br>
<br></div>
--<br>
Barak<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://salilab.org/archives/imp-users/attachments/20140702/081e70ca/attachment.html" target="_blank">http://salilab.org/archives/imp-users/attachments/20140702/081e70ca/attachment.html</a>><br>
<br>
------------------------------<div><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></div>
End of IMP-users Digest, Vol 38, Issue 4<br>
****************************************<br>
</blockquote></div><br></div></div>
<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></blockquote></div><br><br clear="all"><div><br></div>-- <br>Barak
</div></div></div></div></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Barak
</div>