[Chimera-users] scripting problem

Strotz von Moos Dean dean.strotz at phys.chem.ethz.ch
Fri Oct 19 12:55:25 PDT 2012


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>





More information about the Chimera-users mailing list