[chimera-dev] Read a file from script
Eric Pettersen
pett at cgl.ucsf.edu
Thu Nov 4 12:58:37 PDT 2010
On Nov 4, 2010, at 11:50 AM, Elisabeth Ortega wrote:
> Dear all,
>
>
> I need to read some parameters that are write in the same file that
> I have opened. For exemple, I had a python script that parses the
> author of the PDB file and I want to run it in a chimera script to
> use it in other part of the script. To open the file I use:
>
> from openSave import osOpen
>
> f=osOpen("/home/eortega/data.pdb")
>
> code ....
>
>
> I want to do that more "polite". I mean, without write the entire
> route of the file. Saying to chimera that reads the same file that
> it has open and appears in the screen.
Hi Elisabeth,
Although the entire text of a PDB file isn't preserved in Chimera
when the file is opened, the header lines are, which should be good
enough for your purpose. So what you need to do is locate the
Molecule object corresponding to the structure you want, and then:
mol.pdbHeaders['AUTHOR']
will return a list of the PDB AUTHOR header lines (only one line in
this case of course).
Locating the Molecule object depends a bit on what your script does.
If your script opened the PDB file itself with:
chimera.openModels.open("/home/eortega/data.pdb")
then the return value of that is a list of Molecule objects (it's a
list because some kinds of files cause multiple Molecules to be
created [e.g. NMR ensembles]). Similarly:
chimera.openModels.list(modelTypes=[chimera.Molecule])
will return a list of all currently open Molecule objects. Lastly, if
the structure is selected then:
chimera.selection.currentMolecules()
will return a list of selected Molecules.
--Eric
Eric Pettersen
UCSF Computer Graphics Lab
http://www.cgl.ucsf.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20101104/cfa94a3f/attachment.html>
More information about the Chimera-dev
mailing list