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 <jason.vertr...@schrodinger.com> 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] 
> <cschu...@its.jnj.com> 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.


------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Reply via email to