|
From: Thomas H. <tho...@sc...> - 2013-01-23 13:59:52
|
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 |