This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Converting "Multiconformer" Sdf To Multistate Pdb With Openbabel

Dear biostar users,

In a python script i need to read an sdf file that contain multiple conformation of the same molecule and convert it to a multistate pdb.

The problem is that i can't see how to do it with openbabel in python and i would prefer not to call obabel as a subprocess.

from openbabel import *
...

#3D conformers to pdb
inputfile = args.input
try:
    conv = OBConversion()
    conv.SetInAndOutFormats("sdf","pdb")
    mol= OBMol()
    conv.ReadFile(mol,inputfile)
    conv.WriteFile(mol,inputfile[:-4]+".pdb")
except:
    raise

I think there would be some function that allow to read each conformer one by one and append each one in the pdb file as state.

Thanks

python pdb conversion

1 answer

You should try this:

babel *.sdf -opdb -m

Also, check "File Conversion" section on this link: http://openbabel.org/wiki/Tutorial:Basic_Usage

I think you read too fast. I don't want to call babel/obabel inside my script as an external program. I want to use the right functions with python that can do that (For example : http://openbabel.org/docs/2.3.1/UseTheLibrary/PythonDoc.html )

And even if i wanted to use obabel/babel, i don't want multiple file output. I want multiple states for one molecule in a pdb. No need for -m flag, it works fine without.

Log in to answer this question.