openmm / pdbfixer

PDBFixer fixes problems in PDB files
Other
453 stars 114 forks source link

Is bond order available via pdbfixer? #231

Closed ljmartin closed 2 years ago

ljmartin commented 2 years ago

Hi, Is it possible to access bond orders from a protein structure via a pdb file, as interpreted by pdbfixer? Do topology objects from a pdb file (without any other input files) infer bond order at all?

Here's a minimal example of what I'm missing:

import requests
from io import BytesIO
import pdbfixer

def getPDB(code):
    out = requests.get(f'https://files.rcsb.org/download/{code}.pdb')
    f = open(f'{code}.pdb', 'w')
    f.write(out.content.decode('utf8'))

code='3udn'
pdb_string = getPDB('code')

fixer = PDBFixer(filename=f'{code}.pdb')
fixer.findMissingResidues()
fixer.findNonstandardResidues()
fixer.replaceNonstandardResidues()
fixer.removeHeterogens(True)
fixer.findMissingAtoms()
fixer.addMissingAtoms()
fixer.addMissingHydrogens(7.0)

for bond in fixer.topology.bonds():
    print(bond.order)

This prints None for every bond.

The end goal here is to use pdbfixer to read a PDB, generate atom and bonding information, and then port the bonding information into an RDKit RWMol object. RDKit assumes single bonds when creating a molecule bond-by-bond, but it can of course make double bonds - if I knew when to specify them, that is!

Thanks lew

peastman commented 2 years ago

PDB files don't contain any information about bond order. RDKit can load a PDB file directly, and it will attempt to infer bond order. But be aware that it doesn't always get everything right! You can also use Open Babel to load a PDB file and infer bond orders, but it too makes mistakes. I recently encountered this exact problem, and I didn't come up with any entirely satisfactory general solution.

ljmartin commented 2 years ago

Thanks @peastman. I asked a similar question on the rdkit mailing list, and Maceij from ODDT pointed out he tried something similar, and ended up writing an rdkit tool to assign bond orders (assuming correct connectivity) using templates: https://github.com/oddt/oddt/blob/master/oddt/toolkits/extras/rdkit/fixer.py#L623-L669 . That gets most of the way there. Cheers

peastman commented 2 years ago

That's good to know about. Thanks!