[Chimera-users] scripting problem
Eric Pettersen
pett at cgl.ucsf.edu
Sat Oct 20 22:32:51 PDT 2012
Hi Dean,
Your script looks okay to me. One thing that may be tripping you up is that residue '7' is the eighth residue found in the input file (0: first; 1: second; etc.). It is also not necessarily the residue with sequence number 7. If you want to find the residue with sequence number 7, you would have to make a lookup dictionary, something like:
resLookup = {}
for r in model[0].residues:
resLookup[r.id.position] = r
then you could lookup the residue with sequence number 7 with:
r = resLookup[7]
If you already knew all the above, then somehow the residue doesn't have a QD1 atom in it. Just above the line that throws the error put a "print res". That will print the residue identification to the reply log so you can see which residue it was using to look up the QD1 atom in and make sure it's the residue you expect.
I hope something in this reply helps! :-)
--Eric
Eric Pettersen
UCSF Computer Graphics Lab
On Oct 19, 2012, at 12:55 PM, Strotz von Moos Dean wrote:
> Hi,
>
> I have a question to the following code. I can not figure out why certain atom types are not understood (HG, QD etc).
> The atom types occur in the structure and I can select them through the terminal or add them as pseudo bonds through the pseudoBond reader.
>
> For a QD1 one for instance I get: KeyError: 'QD1' <module> grp.newPseudoBond(res[r1].atomsMap[A1][0],res[r2].atomsMap[A2][0])
>
>
> Excerpt from the input file:
>
> 7 HA 7 H red #this is understood
> 7 H 7 QD1 yellow #error message for QD1
>
> What is wrong with my code?
> The A1 = str(A1) ?
> How would I do it alternatively?
>
> All the best and many thanks
> Dean
>
>
> import chimera
> from chimera.colorTable import getColorByName
> from chimera.misc import getPseudoBondGroup
> from chimera import runCommand as rC # use 'rc' as shorthand for runCommand
>
> model = chimera.openModels.open('xxx.pdb')
>
> rC('show #0')
> rC('ribbon')
> rC('ribcolor gray')
> rC('background solid white')
> rC('unset depthCue')
>
> ins = open('pseudobondsToAdd.txt', "r" )
> array = []
> for line in ins:
> array.append(line)
> ins.close()
>
> for line in array:
> r1, A1, r2, A2, c = line.split() # Split the line on white space.
> r1 = int(r1)
> r2 = int(r2)
> A1 = str(A1)
> A2 = str(A2)
> c = str(c)
> res = model[0].residues
> grp = getPseudoBondGroup("mybonds", associateWith=model)
> grp.newPseudoBond(res[r1].atomsMap[A1][0],res[r2].atomsMap[A2][0])
> grp.color = getColorByName(c)
>
>
>
> ETH Zürich
> Dean Strotz
> Laboratorium f. Physikalische Chemie
> HCI F 217
> Wolfgang-Pauli-Str. 10
> 8093 Zürich
>
> E-Mail: dean.strotz at phys.chem.ethz.ch<mailto:dean.strotz at phys.chem.ethz.ch>
>
>
> _______________________________________________
> Chimera-users mailing list
> Chimera-users at cgl.ucsf.edu
> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
>
More information about the Chimera-users
mailing list