I want a PyMOL script to automatically draw bonds for a given structure, e.g. between all palladium atoms, or between all palladium and sulfur atoms.
I can do this manually by the bond
command, but need to know the identifiers of the atoms:
bond id 3, id 4
bond id 2, id 6
...
After crawling the PyMol mailinglist, I managed to connect all atoms. e.g.
bond (elem pd), (elem pd)
draws bonds between all the Pd atoms.
Now to the cuttoff radius:
bond (elem pd), (elem s) within 2.5 of (elem pd)
draws bonds between all Pd atoms and all S atoms within the range of 2.5 of any Pd atom. This is resulting in a weired structure with very long bonds.
I think it's necessary to iterate over one of both selections to yield bonds within the desired cutoff radius only.
Instead, I make use of the find_pairs function of pymol (this is API only and thus has to be used in a python script).
from pymol import cmd, stored
pd_s_bonds = cmd.find_pairs('n. pd', 'n. s', cutoff=2.5)
for pair in pd_s_bonds:
cmd.bond('index %s' % pair[0][6], 'index %s' % pair[1][7])