[Chimera-users] Regarding getSequence

Eric Pettersen pett at cgl.ucsf.edu
Tue Dec 18 11:41:42 PST 2007


On Dec 18, 2007, at 10:40 AM, Jean-Didier Maréchal wrote:

> Hi again,
>
> I'd like  to return the sequence of the protein I opened in  
> chimera  in
> the python shell.
>
>> From what I read through, I thought that chimera.getSequence could be
> used to do so.
>
> I was thinking in a simple script beginning with :
> import chimera
> s=chimera.getSequence(0,0)
> ..
>
> However the chimera.getSequence(0,0)  comes back with:
>
> Traceback (most recent call last):
>   File "<pyshell#50>", line 1, in ?
>     chimera.getSequence(0, 0)
>   File "CHIMERA/share/chimera/Sequence.py", line 614, in getSequence
>   File "CHIMERA/share/chimera/Sequence.py", line 656, in getSequences
> AttributeError: 'int' object has no attribute 'residues'
>
> and
>
>
> chimera.getSequence(0,A)
>
> with
>
> Traceback (most recent call last):
>   File "<pyshell#48>", line 1, in ?
>     chimera.getSequence(0,A)
> NameError: name 'A' is not defined
>
>
> Did I understand correctly the role of getSequence? if yes, what would
> be the correct syntax please?


Hi JD,
	getSequence takes two arguments: a Molecule instance and a string  
containing a chain ID.  It looks like you were trying to provide a  
model number and a chain ID of A.  The chain needed to be a string  
and not just the bare letter A, which is interpreted as a variable  
named A by the Python interpreter (and which you undoubtedly haven't  
previously defined).
	You get a Molecule instance by using chimera.openModels.list to list  
Models and grab the one you want from that list.  Something like:

	from chimera import openModels, Molecule
	m = openModels.list(id=0, modelTypes=[Molecule])[0]

to get the Molecule open as model 0.
	Once you have the Molecule instance you don't even have to use  
getSequence, just:

	m.sequence("A")

will return the Sequence object.

--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-users/attachments/20071218/00eb1e9d/attachment.html>


More information about the Chimera-users mailing list