[Chimera-users] access to pdb parser
Eric Pettersen
pett at cgl.ucsf.edu
Thu Feb 1 11:40:40 PST 2007
Hi JD,
Depending on what you want to do, you may not even have to use PDBio
directly. Once you open a molecular model by any means in Chimera,
it will have that pdbHeaders dictionary attribute. You can get a
list of the currently open molecular models in Chimera like this:
import chimera
mols = chimera.openModels.list(modelTypes=[chimera.Molecule])
--Eric
On Feb 1, 2007, at 3:46 AM, Jean Didier Pie Marechal wrote:
> Hi Eric,
>
> Well, the truth is that these are two good news. Most likely I
> didn't explain myself correctly. In reality, for practical reasons,
> I'd like to use only chimera for the teaching. So, I am planning to
> only use its internal python shell for python applications.
> Therefore the tips you gave me are perfect.
>
> Thanks a lot for the help!
> Cheers
>
>
> JD
>
> Dr. Jean-Didier Maréchal
> Professor Lector
> Unitat de Química Física
> Departament de Química
> Universitat Autònoma de Barcelona
> Edifici C.n.
> 08193 Cerdonyola (Barcelona)
> Tel: +34.935814988
> e-mail: JeanDidier.Marechal at uab.es
>
> ----- Missatge original -----
> De: Eric Pettersen <pett at cgl.ucsf.edu>
> Data: Dimecres, Gener 31, 2007 10:31 pm
> Assumpte: Re: [Chimera-users] access to pdb parser
>
>> Hi JD,
>> I have good news and I have bad news. The good news it that using
>>
>> PDBio to do what you want is pretty easy. The bad news is that you
>>
>> can't use it in a generic Python shell, only in Chimera's own
>> Python
>> shell. This is because we use a modified version of Python so that
>>
>> the types we define in the C++ layer (Molecule, etc.) can have
>> attributes added to them in the Python layer -- otherwise they
>> would
>> behave like the built-in Python types (dict, list. etc.) that can't
>>
>> have arbitrary attributes added to them. We intend to improve our
>> own code to make modifying Python unnecessary, but haven't gotten
>> to
>> it so far.
>> Nonetheless, you can basically use Chimera in place of a Python
>> interpreter. "chimera --nogui script.py" will execute the Python
>> script named script.py without bringing up the Chimera interface.
>> Also, you can start Chimera normally and bring up the graphical
>> interface to its interactive Python shell, IDLE (under Tools-
>>> General
>> Controls) and type Python commands to that.
>> Here's a session of me using PDBio in IDLE. I've added some
>> comments.
>>>>> from chimera import PDBio # import PDBio
>>>>> pdbio = PDBio() # create a PDBio instance
>>>>> mols = pdbio.readPDBfile("/mol/pdb/gc/pdb1gcn.ent") # read a
>> PDB file given its file name
>>>>> m = mols[0] # readPDBfile() returned a list of models (NMR
>> can
>> have many) so get the model itself
>>>>> m.pdbHeaders["HEADER"] # each model will have a pdbHeaders
>> dictionary, keyed by the record type, the values will be a list of
>> strings -- the PDB records
>> ['HEADER HORMONE 17-OCT-77
>> 1GCN 1GCN 3']
>>>>>
>>
>> --Eric
>>
>> On Jan 31, 2007, at 12:42 PM, Jean Didier Pie Marechal wrote:
>>
>>> Hi Eric,
>>>
>>> Yes, that would be better to explain more what I'd like to do.
>>>
>>> I am planning to give a practical on computational (bio)chemistry
>>
>>> in my department next year. I'd stongly like to have the students
>>
>>> using chimera and python as their main tools (though both are
>> tools
>>> I am in process of learning :-)).
>>>
>>> One of the "simple things" I have in mind, is to obtain pdb infos
>>
>>> directly from the shell e.g list the SEQRES entry or access to
>> the
>>> resolution (REMARK 2), the crystallization conditions etc. The
>>> students will be chemists and I think that from a didactic point
>> of
>>> view, obtaining infos from the python shell would be better that
>>> reading the pdb files, especially if we want to compare different
>>
>>> structures e.g. Writing a comand that gives you ALL the
>> resolutions
>>> of the 10 structures you loaded would be interesting. I looked at
>>
>>> the PDBio, but I can see how to catch REMARKS infos.
>>>
>>> I'd really like to have this work going on, but as you can see, I
>>
>>> am a bit lost in where to begin.
>>>
>>> Any help to tell me where to start would be fantastic!
>>>
>>> Cheers
>>>
>>> JD
>>>
>>>
>>>
>>>
>>> Dr. Jean-Didier Maréchal
>>> Professor Lector
>>> Unitat de Química Física
>>> Departament de Química
>>> Universitat Autònoma de Barcelona
>>> Edifici C.n.
>>> 08193 Cerdonyola (Barcelona)
>>> Tel: +34.935814988
>>> e-mail: JeanDidier.Marechal at uab.es
>>>
>>> ----- Missatge original -----
>>> De: Eric Pettersen <pett at cgl.ucsf.edu>
>>> Data: Dimarts, Gener 30, 2007 1:25 am
>>> Assumpte: Re: [Chimera-users] access to pdb parser
>>>
>>>> Hi JD,
>>>> Chimera does its PDB parsing in the C++ layer (the PDBio class in
>>>>
>>>> the Python layer). There is a file named PDB.py in the mmCIF-
>>>> parsing
>>>> module, but it's not for parsing PDB files. Perhaps if you
>>>> described
>>>> why you need Python PDB parsing I could suggest options -- using
>>>> PDBio possibly being one of them.
>>>>
>>>> --Eric
>>>>
>>>> Eric Pettersen
>>>> UCSF Computer Graphics Lab
>>>> pett at cgl.ucsf.edu
>>>> http://www.cgl.ucsf.edu
>>>>
>>>> On Jan 29, 2007, at 1:49 PM, Jean Didier Pie Marechal wrote:
>>>>
>>>>> Hello everyone,
>>>>>
>>>>> a short question. What is the right call for importing the
>>>>> pdbparser module in the chimera python shell? I found the PDB.py
>>>>
>>>>> module in the site-package mmlib, but I don't know how to import
>>>> it...>
>>>>> Thanks a lot,
>>>>>
>>>>> JD
>>>>>
>>>>>
>>>>> Dr. Jean-Didier Maréchal
>>>>> Professor Lector
>>>>> Unitat de Química Física
>>>>> Departament de Química
>>>>> Universitat Autònoma de Barcelona
>>>>> Edifici C.n.
>>>>> 08193 Cerdonyola (Barcelona)
>>>>> Tel: +34.935814988
>>>>> e-mail: JeanDidier.Marechal at uab.es
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Chimera-users mailing list
>>>>> Chimera-users at cgl.ucsf.edu
>>>>> http://www.cgl.ucsf.edu/mailman/listinfo/chimera-users
>>>>
>>>>
>>>
>>>
>>
>>
>
>
More information about the Chimera-users
mailing list