Often one wants to access a residue's neighbouring residues as defined by the implicit bonding of the backbone atoms: previous residues is bonded to the residue's N atom of its amino group, the next residues is bonded to the residue's C atom of its carboxy group.
In MolTalk, the bonding of residues through their backbone atoms can be accessed the same way as other bonded atoms can:
[ |
main
" load the structure and access the chain and residue we want to work with "
strx := MTStructureFactory newStructureFromPDBDirectory: '1TAR'.
chain := strx getChain: 65.
residue := chain getResidue: '258'.
Transcript showLine: (' going for residue ', residue description).
" find the C atom of the previous residue which is bonded to our residue "
prevC := nil.
atmN := residue getAtomWithName: 'N'.
(atmN allBondedAtoms allObjects) do: [ :atm2 |
(atm2 name = 'C') ifTrue: [ prevC := atm2 ].
].
" find the N atom of the next residue which is bonded to our residue "
nextN := nil.
atmC := residue getAtomWithName: 'C'.
(atmC allBondedAtoms allObjects) do: [ :atm2 |
(atm2 name = 'N') ifTrue: [ nextN := atm2 ].
].
Transcript showLine: ('prev = ', prevC description).
Transcript showLine: (' in residue = ', (self residueWithAtom: prevC inChain: chain) description).
Transcript showLine: ('next = ', nextN description).
Transcript showLine: (' in residue = ', (self residueWithAtom: nextN inChain: chain) description).
" that's all . "
" this subroutine traverses all residues in the chain
and returns the one that contains the atom we search for "
!
residueWithAtom: atom inChain: chain
| result atm |
result := nil.
atm := nil.
(chain allResidues allObjects) do: [ :residue |
atm := residue getAtomWithNumber: (atom number).
(atm notNil) ifTrue: [ result := residue ].
].
^result
]