Re: [PyMOL] echo colour

2013-01-23 Thread Thomas Holder
Hi Joel,

the color is stored as a numeric atom property, you can use iterate to
get it.

PyMOL> iterate (first objX), print color

If you need the name of the color, get the index to name mapping as a
dictionary from PyMOL like this:

PyMOL> stored.cn = dict((i,c) for (c,i) in cmd.get_color_indices())
PyMOL> iterate (first objX), print stored.cn[color]

Last but not least, there is the psico.querying.get_color function in
the PSICO module :)

Cheers,
  Thomas

Joel Tyndall wrote, On 01/23/13 02:04:
> Hi list,
> 
> With the myriad of colours in Pymol, I tend to forget which shade of
> what I have used. Is there a way/command to print the colour I have used
> to colour object X?
> 
> Cheers
> 
> Joel
> _
> 
> Joel Tyndall, PhD
> 
> Senior Lecturer in Medicinal Chemistry
> National School of Pharmacy
> University of Otago
> PO Box 56 Dunedin 9054
> New Zealand  
> 
> Skype: jtyndall
> 
> Ph: +64 3 479 7293

-- 
Thomas Holder
PyMOL Developer
Schrödinger Contractor

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
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


Re: [PyMOL] How do I get current selection name from python?

2013-01-23 Thread Boris Kheyfets
It prints the selection all right. Why then save wouldn't save it:

def bk_saves_unique_pdb(Selection = None):
"""Takes current selection (or "all" -- if nothing selected) and
saves it as a uniquetly named pdb file
(Frame_Selection_RandomString.pdb) in the current working
directory."""
if not Selection:
Selection = cmd.get_names('selections', 1)
if Selection:
Selection = Selection[0] # it was a list
else:
Selection = 'all'
tempFile = tempfile.NamedTemporaryFile(dir=os.curdir,
prefix="{frame:03d}_{sel}_".format(frame=cmd.get_frame(),
sel=Selection) , suffix=".pdb")
print tempFile.name, Selection # prints righteous file name and
selection name (though not in quotes)
cmd.save(tempFile.name, Selection) # but still saves nothing
cmd.extend("bk_saves_unique_pdb", bk_saves_unique_pdb)



On Tue, Jan 22, 2013 at 10:49 PM, Thomas Holder <
thomas.hol...@schrodinger.com> wrote:

> Hi Boris,
>
> this will give you the list of active selections, which has by default
> only one entry (or zero, if no selection is enabled).
>
> active_selections = cmd.get_names('selections', 1)
>
> Hope that helps.
>
> Cheers,
>   Thomas
>
> On Jan 22, 2013, at 2:08 PM, Boris Kheyfets  wrote:
> > I want to save current selection as a uniquetly-named pdb file. So I
> need tempfile of python.
> >
> > So I write def, and I want it have current selection as default one (not
> the '(all)'). How do I do that?
> >
> > I think it will be somewhere under
> >  cmd.get_session()
> >
> > I read the sources, but couldn't find a single instance where current
> selection would be a default one.
>
> --
> Thomas Holder
> PyMOL Developer
> Schrödinger Contractor
>
>
--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d___
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

Re: [PyMOL] How do I get current selection name from python?

2013-01-23 Thread Thomas Holder
http://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile

Quote: "If delete is true (the default), the file is deleted as soon as
it is closed."

Cheers,
  Thomas

Boris Kheyfets wrote, On 01/23/13 14:47:
> It prints the selection all right. Why then save wouldn't save it:
> 
> 
> def bk_saves_unique_pdb(Selection = None):
> """Takes current selection (or "all" -- if nothing selected) and saves it 
> as a uniquetly named pdb file (Frame_Selection_RandomString.pdb) in the 
> current working directory."""
> if not Selection:
> Selection = cmd.get_names('selections', 1)
> if Selection:
> Selection = Selection[0] # it was a list
> else:
> Selection = 'all'
> tempFile = tempfile.NamedTemporaryFile(dir=os.curdir, 
> prefix="{frame:03d}_{sel}_".format(frame=cmd.get_frame(), sel=Selection) , 
> suffix=".pdb")
> print tempFile.name, Selection # prints righteous file name and selection 
> name (though not in quotes)
> cmd.save(tempFile.name, Selection) # but still saves nothing
> cmd.extend("bk_saves_unique_pdb", bk_saves_unique_pdb)

-- 
Thomas Holder
PyMOL Developer
Schrödinger Contractor

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
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


Re: [PyMOL] echo colour

2013-01-23 Thread Joel Tyndall
Thanks Thomas,

seems to work.

-Original Message-
From: Thomas Holder [mailto:thomas.hol...@schrodinger.com] 
Sent: Wednesday, 23 January 2013 10:47 p.m.
To: pymol-users@lists.sourceforge.net
Subject: Re: [PyMOL] echo colour

Hi Joel,

the color is stored as a numeric atom property, you can use iterate to get it.

PyMOL> iterate (first objX), print color

If you need the name of the color, get the index to name mapping as a 
dictionary from PyMOL like this:

PyMOL> stored.cn = dict((i,c) for (c,i) in cmd.get_color_indices()) 
PyMOL> iterate (first objX), print stored.cn[color]

Last but not least, there is the psico.querying.get_color function in the PSICO 
module :)

Cheers,
  Thomas

Joel Tyndall wrote, On 01/23/13 02:04:
> Hi list,
> 
> With the myriad of colours in Pymol, I tend to forget which shade of 
> what I have used. Is there a way/command to print the colour I have 
> used to colour object X?
> 
> Cheers
> 
> Joel
> _
> 
> Joel Tyndall, PhD
> 
> Senior Lecturer in Medicinal Chemistry National School of Pharmacy 
> University of Otago PO Box 56 Dunedin 9054 New Zealand
> 
> Skype: jtyndall
> 
> Ph: +64 3 479 7293

--
Thomas Holder
PyMOL Developer
Schrödinger Contractor

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, 
Windows 8 Apps, JavaScript and much more. Keep your skills current with 
LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. 
ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
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

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
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