I want to add a bond between specific atoms. I found on VMD page that one can use topotools (e.g. topo addbond 1 2 ), but I have a lot of residues so this method didn't work with me. I need to select the two residues and then build a bond between the two atoms of the two different residues. Does anyone have an idea how to do this?


1 Answer 1


topo addbond x y should do the trick. where x is the index of the atom of an residue in which you are interested.
if you want a more automated way, then you need to know the exact atom name and the residue number.

Let's say, the residue number you are interested in is 250 and the atom name is HG1, and you want to add a bond to atom name OG1 of residue 267.

set a [atomselect top "residue 250 and name HG1"] 
set aindex [$a get index]

set a1 [atomselect top "residue 267 and name OG1"] 
set a1index [$a1 get index]

topo addbond $aindex $a1index

if you have a list of atom names and a list of residue numbers, you can just do a foreach loop and keep the above code in the loop, in that way you can add bonds to all the desired atoms at once.

  • $\begingroup$ Thank you for your comment. This method is ok now, but why VMD didn't draw the bond in the visualization. I have the two atoms without a bond between. $\endgroup$ Commented Jan 15, 2022 at 9:03
  • $\begingroup$ That's unusual, It should form a bond. Are you sure you are looking at the correct indices? $\endgroup$
    – Vasista
    Commented Jan 15, 2022 at 10:55
  • $\begingroup$ Yes and I checked the index in the PDB file, and it was right, but there is no bond formed $\endgroup$ Commented Jan 15, 2022 at 10:58
  • 1
    $\begingroup$ @Abd-ElazeemMohamed Be cautious. Indices in VMD start from 0, where as in PDB it starts from 1. Did you take that into account? $\endgroup$
    – Vasista
    Commented Jan 15, 2022 at 11:04
  • 2
    $\begingroup$ @Vasista In general, we have tried to avoid making new chat rooms when possible, see this Meta discussion. By using a few rooms about existing topics, it's easier for users to find these discussion later and avoids a large number of unused rooms that get hidden after a short amount of time. It's not a huge problem, but in the future don't follow the prompt to make an automatic room. The instructions in that Meta post explain how to move comments to an existing room. $\endgroup$
    – Tyberius
    Commented Jan 15, 2022 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .