RE: [PyMOL] how to get minimum distances in script?

 RE: [PyMOL] how to get minimum distances in script? From: Warren L. DeLano - 2003-07-12 18:18:09 ```Seth, PyMOL is definitely behind other packages right now when it comes to geometric measurement, which is shame since Python is such a good tool for working up this stuff. We'll get there eventually though... I think a brute-force approach is currently necessary, and here is a little code to get you started: # define interface cmd.select("query", ...) cmd.select("target", ...) # example depends on "query" and "target" selections from pymol import cmd import pymol result_list = [] for a in cmd.index("query"): # for each query atom, generate a list of # neighbors within 8 angstroms, including # attributes and xyz coordinates q_sel = "%s`%d"%a print q_sel cmd.iterate(q_sel, "stored.qry_info = (chain,resn,resi,name)") cmd.iterate_state(1,q_sel, "stored.qry_xyz = (x,y,z)") pymol.stored.nbr_info = [] pymol.stored.nbr_xyz = [] cmd.iterate("target and (%s expand 8)"%q_sel, "stored.nbr_info.append((chain,resn,resi,name))") cmd.iterate_state(1,"target and (%s expand 8)"%q_sel, "stored.nbr_xyz.append((x,y,z))") result_list.append(( ((stored.qry_info), (stored.qry_xyz)), map(None,stored.nbr_info, stored.nbr_xyz))) # the rest of the task is just pure Python math, using the # values stored in result_list. for a in result_list: print "Query:",a[0] if len(a[1]): print "Neighbors:" for b in a[1]: print " ",b -- mailto:warren@... Warren L. DeLano, Ph.D. Principal Scientist DeLano Scientific LLC Voice (650)-346-1154 Fax (650)-593-4020 > -----Original Message----- > From: pymol-users-admin@... [mailto:pymol-users- > admin@...] On Behalf Of Seth Harris > Sent: Friday, July 11, 2003 5:37 PM > To: pymol-users@... > Subject: [PyMOL] how to get minimum distances in script? > > Hello all, > > I am trying to write a script that will go through each residue in a > dimer interface and determine for each one how close it is to the > partner monomer. > > I can interactively plot all the distances within a certain cutoff > using the handy: > distance chosen, residue_selected_on_first_chain, > partner_monomer_selection, cutoff > > For atom selections Warren earlier explained how to parse into its > components (using list=[]; iterate > (selection),list.append((resi,resn))). However, the selection > created by the distance command (i.e. "chosen") does not behave the > same way it seems and I haven't been able to iterate over it to get > at the info. > > I see from "help distance" that in the API cmd.distance returns the > average, so it suggested that perhaps minimum and maximum or even > each individual value might also be accessible, giving me hope that > the more elegant solution was close at hand and limited more by my > ignorance than the chosen approach. > > Otherwise I suppose there's the more brute-force avenue of going > through each residue, selecting atoms from the partner monomer within > a certain distance if any, and then explicitly measuring the distance > to each atom one by one, but I thought I'd check with the community > before launching such an ugly attack on the problem, having walked > that road before! > > Also, not to push my luck, but if you'd like to write your > suggestions in both English and Python, my less-than-rudimentary > knowledge of Python will thank you(!) > > Cheers and thanks, > Seth > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Seth F. Harris, PhD > Agard Laboratory > University of California, San Francisco > Mission Bay Genentech Hall > 600 16th St. Suite S416 > San Francisco, CA 94143-2240 > 415.502.2930 > > > ------------------------------------------------------- > This SF.Net email sponsored by: Parasoft > Error proof Web apps, automate testing & more. > Download & eval WebKing and get a free book. > http://www.parasoft.com/bulletproofapps1 > _______________________________________________ > PyMOL-users mailing list > PyMOL-users@... > https://lists.sourceforge.net/lists/listinfo/pymol-users ```

 [PyMOL] how to get minimum distances in script? From: Seth Harris - 2003-07-12 01:37:26 ```Hello all, I am trying to write a script that will go through each residue in a dimer interface and determine for each one how close it is to the partner monomer. I can interactively plot all the distances within a certain cutoff using the handy: distance chosen, residue_selected_on_first_chain, partner_monomer_selection, cutoff For atom selections Warren earlier explained how to parse into its components (using list=[]; iterate (selection),list.append((resi,resn))). However, the selection created by the distance command (i.e. "chosen") does not behave the same way it seems and I haven't been able to iterate over it to get at the info. I see from "help distance" that in the API cmd.distance returns the average, so it suggested that perhaps minimum and maximum or even each individual value might also be accessible, giving me hope that the more elegant solution was close at hand and limited more by my ignorance than the chosen approach. Otherwise I suppose there's the more brute-force avenue of going through each residue, selecting atoms from the partner monomer within a certain distance if any, and then explicitly measuring the distance to each atom one by one, but I thought I'd check with the community before launching such an ugly attack on the problem, having walked that road before! Also, not to push my luck, but if you'd like to write your suggestions in both English and Python, my less-than-rudimentary knowledge of Python will thank you(!) Cheers and thanks, Seth -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Seth F. Harris, PhD Agard Laboratory University of California, San Francisco Mission Bay Genentech Hall 600 16th St. Suite S416 San Francisco, CA 94143-2240 415.502.2930 ```
 RE: [PyMOL] how to get minimum distances in script? From: Warren L. DeLano - 2003-07-12 18:18:09 ```Seth, PyMOL is definitely behind other packages right now when it comes to geometric measurement, which is shame since Python is such a good tool for working up this stuff. We'll get there eventually though... I think a brute-force approach is currently necessary, and here is a little code to get you started: # define interface cmd.select("query", ...) cmd.select("target", ...) # example depends on "query" and "target" selections from pymol import cmd import pymol result_list = [] for a in cmd.index("query"): # for each query atom, generate a list of # neighbors within 8 angstroms, including # attributes and xyz coordinates q_sel = "%s`%d"%a print q_sel cmd.iterate(q_sel, "stored.qry_info = (chain,resn,resi,name)") cmd.iterate_state(1,q_sel, "stored.qry_xyz = (x,y,z)") pymol.stored.nbr_info = [] pymol.stored.nbr_xyz = [] cmd.iterate("target and (%s expand 8)"%q_sel, "stored.nbr_info.append((chain,resn,resi,name))") cmd.iterate_state(1,"target and (%s expand 8)"%q_sel, "stored.nbr_xyz.append((x,y,z))") result_list.append(( ((stored.qry_info), (stored.qry_xyz)), map(None,stored.nbr_info, stored.nbr_xyz))) # the rest of the task is just pure Python math, using the # values stored in result_list. for a in result_list: print "Query:",a[0] if len(a[1]): print "Neighbors:" for b in a[1]: print " ",b -- mailto:warren@... Warren L. DeLano, Ph.D. Principal Scientist DeLano Scientific LLC Voice (650)-346-1154 Fax (650)-593-4020 > -----Original Message----- > From: pymol-users-admin@... [mailto:pymol-users- > admin@...] On Behalf Of Seth Harris > Sent: Friday, July 11, 2003 5:37 PM > To: pymol-users@... > Subject: [PyMOL] how to get minimum distances in script? > > Hello all, > > I am trying to write a script that will go through each residue in a > dimer interface and determine for each one how close it is to the > partner monomer. > > I can interactively plot all the distances within a certain cutoff > using the handy: > distance chosen, residue_selected_on_first_chain, > partner_monomer_selection, cutoff > > For atom selections Warren earlier explained how to parse into its > components (using list=[]; iterate > (selection),list.append((resi,resn))). However, the selection > created by the distance command (i.e. "chosen") does not behave the > same way it seems and I haven't been able to iterate over it to get > at the info. > > I see from "help distance" that in the API cmd.distance returns the > average, so it suggested that perhaps minimum and maximum or even > each individual value might also be accessible, giving me hope that > the more elegant solution was close at hand and limited more by my > ignorance than the chosen approach. > > Otherwise I suppose there's the more brute-force avenue of going > through each residue, selecting atoms from the partner monomer within > a certain distance if any, and then explicitly measuring the distance > to each atom one by one, but I thought I'd check with the community > before launching such an ugly attack on the problem, having walked > that road before! > > Also, not to push my luck, but if you'd like to write your > suggestions in both English and Python, my less-than-rudimentary > knowledge of Python will thank you(!) > > Cheers and thanks, > Seth > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Seth F. Harris, PhD > Agard Laboratory > University of California, San Francisco > Mission Bay Genentech Hall > 600 16th St. Suite S416 > San Francisco, CA 94143-2240 > 415.502.2930 > > > ------------------------------------------------------- > This SF.Net email sponsored by: Parasoft > Error proof Web apps, automate testing & more. > Download & eval WebKing and get a free book. > http://www.parasoft.com/bulletproofapps1 > _______________________________________________ > PyMOL-users mailing list > PyMOL-users@... > https://lists.sourceforge.net/lists/listinfo/pymol-users ```