I want to read sdf file (containing many molecules) and return the weighted adjacency matrix of the molecule. Atoms should be treated as vertices and bond as edges. If i and j vertex are connected by single, double, or triple bond then corresponding entries in the adjacency matrix should be 1,2, and 3 respectively. I need to further obtain a distance vector for each vertex which list the number of vertices at different distance.
Are there any python package available to do this?
I would recommend Pybel for reading and manipulating SDF files in Python. To get the bonding information, you will probably need to also use the more full-featured but less pythonic openbabel module, which can be used in concert with Pybel (as pybel.ob).
To start with, you would write something like this:
import pybel
for mol in pybel.readfile('sdf', 'many_molecules.sdf'):
for atom in mol:
coords = atom.coords
for neighbor in pybel.ob.OBAtomAtomIter(atom.OBAtom):
neighbor_coords = pybel.atom(neighbor).coords