|
From: Thomas H. <tho...@sc...> - 2014-01-31 18:34:33
|
Hi Carsten & Jason,
this is what I would do:
@cmd.extend
def list_resi(selection='all'):
resi_list = []
cmd.iterate('byca (%s)' % selection,
'resi_list.append(resi);'
'print "/%s/%s/%s/%s`%s" % (model, segi, chain, resn, resi)',
space=locals())
return resi_list
Cheers,
Thomas
On 31 Jan 2014, at 11:37, Jason Vertrees <jas...@sc...> wrote:
> Carsten,
>
> What about http://www.pymolwiki.org/index.php/List_Selection and http://www.pymolwiki.org/index.php/List_Selection2? I also made a similar script for retrieving object names: http://www.pymolwiki.org/index.php/GetNamesInSel.
>
> Cheers,
>
> -- Jason
>
>
> On Fri, Jan 31, 2014 at 10:30 AM, Schubert, Carsten [JRDUS] <CSC...@it...> wrote:
> Hi All,
>
>
>
> probably a question for the developers, but may not hurt to ask publicly: Is there a functionality in Pymol to list the residues in a given selection? I am looking for the equivalent to the get_chains() function. I have scripted something up, but the code is not 100% clean and not flexible enough. For large molecules the performance is not great either.
>
>
>
>
>
> #### start script
>
> def list_resi(obj=""):
>
> """
>
> DESCRIPTION
>
>
>
> "list_resi" prints and returns the unique residue IDs from the input
>
> object. The object must be present in the object list
>
> on the GUI. Selections are currently not implemented.
>
> Chain or Segments are also not taken into account
>
> USAGE
>
>
>
> list_resi obj
>
>
>
> EXAMPLES
>
>
>
> list_resi my_prot
>
>
>
> l = list_resi(my_prot)
>
> """
>
>
>
> if ( obj == "" ):
>
> obj="(all)"
>
>
>
> ol = cmd.get_object_list()
>
> if (obj in ol):
>
> pass
>
> else:
>
> print "Error: Object (%s) not found" % obj
>
> return
>
>
>
> stored.resi_list = []
>
> cmd.iterate(obj,"stored.resi_list.append(int(resi))")
>
> stored.resi_list=list(set(stored.resi_list)) # make list unique
>
> stored.resi_list.sort()
>
>
>
> for i in range(0,len(stored.resi_list)):
>
> print "%s," % stored.resi_list[i],
>
> if ((i+1) % 10 == 0):
>
> print ""
>
>
>
> return stored.resi_list
>
>
>
> ##### End Script
>
>
> Thanks for any input
> Carsten
--
Thomas Holder
PyMOL Developer
Schrödinger, Inc.
|