46.2k views
1 vote
I have raw data of the atom types and their coordinates. For example, water molecule is: O -0.034 0.977 0.007 H 0.064 0.020 0.001 H 0.871 1.300 0.0006 Here, I would like to transform this atomic coordinate data into SDF file. How can I do it with a software or library such as RDKit?

1 Answer

4 votes

Final answer:

To transform the atomic coordinate data into an SDF file using RDKit, you can follow these steps. Here's an example of how to achieve this in Python using RDKit.

Step-by-step explanation:

To transform the atomic coordinate data into an SDF file using RDKit, you can follow these steps:

  1. Create an empty RDKit Mol object.
  2. Split the raw data into atom type and coordinates.
  3. Add each atom with its coordinates to the Mol object.
  4. Specify the atom mapping numbers if required.
  5. Write the Mol object to an SDF file using the RDKit library.

Here's an example of how to achieve this in Python using RDKit:

```python

from rdkit import Chem

def sdf_from_coordinates(raw_data):

molecule = Chem.Mol()

raw_data_list = raw_data.split()

for i in range(0, len(raw_data_list), 4):

atom_type = raw_data_list[i]

x = float(raw_data_list[i+1])

y = float(raw_data_list[i+2])

z = float(raw_data_list[i+3])

atom = Chem.Atom(atom_type)

atom.SetDoubleProp('x', x)

atom.SetDoubleProp('y', y)

atom.SetDoubleProp('z', z)

molecule.AddAtom(atom)

Chem.rdmolops.SanitizeMol(molecule)

sd_writer = Chem.SDWriter('output.sdf')

sd_writer.write(molecule)

sd_writer.close()

```

Make sure you have RDKit installed in your Python environment before running the code.

User VT Chiew
by
8.9k points