<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"><<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">Hi Barek,<div><br></div><div>So I'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'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("josh%d"%i, ".rmf")</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"><<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)<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=<a href="mailto:LvYPnJh-LjpC2cSA@mail.gmail.com" target="_blank">LvYPnJh-LjpC2cSA@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<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>> 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>
> Essentially all i'm trying to do is generate an ensemble of models made<br>
> from four subunits - constrained by MS connectivity restraints. The models<br>
> get scored but nothing seems to write to the pymol file. Ideally i'd like<br>
> to write to an .rmf but i haven't worked that one out either ...<br>
><br>
> 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 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<br>
> pdb shape instead<br>
> s=IMP.atom.create_simplified_along_backbone(c,<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>
> 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 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 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>
> # 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>
> _______________________________________________<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>
--<br>
Barak<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<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>
<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>