<p>An SDF file lacks residue information, including atom name.
Although for the latter, the <code>molFileAlias</code> atomic property is frequently used.</p>
<h2>Adding residue info</h2>
<p>There are several ways to do this, such as in RDKit (<a href="https://blog.matteoferla.com/2020/03/atom-names-purely-in-rdkit.html" rel="nofollow noreferrer">blog post</a>):</p>
<pre class="lang-py prettyprint-override"><code>from rdkit import Chem
from rdkit.Chem import AllChem

from typing import List

with Chem.SDMolSupplier('.sdf') as mol_store:
     mols: List[Chem.Mol] = list(mol_store)

mol: Chem.Mol
for mol in mols:
    atom: Chem.Atom
    for i, atom in enumerate(mol.GetAtoms()):
        info = AllChem.AtomPDBResidueInfo(atomName=f'ATM{i}',
                                          residueName='LIG',
                                          residueNumber=1, 
                                          chainId='X')
        atom.SetMonomerInfo(info)   

mol: Chem.Mol
for mol in mols:
    name: str = mol.GetProp('_Name')
    Chem.MolToPDBFile(mol, f'{name}.pdb')
</code></pre>
<p>Notes:</p>
<ul>
<li>Atom names do have somewhat of a standard format, C1, C2, C3. I am being lazy in the above. If your ligand is present in the RCSB PDB, it will have a chemical component info on the PDB: <a href="https://www.rcsb.org/ligand/CFF" rel="nofollow noreferrer">example</a> and it is often imperative to obey the atom names and atom index from there.</li>
<li>PyMOL or pymol2 module can also add PDB information, therein the residue index is not an integer but a string as it combines w/ insertion code.</li>
<li>In some tools, you lose the bond order, but if you have a SDF and not a PDB, then you are safe. But if you have a reference it's easy to fix.</li>
</ul>
<pre class="lang-py prettyprint-override"><code>from rdkit import Chem
from rdkit.Chem import AllChem
template: Chem.Mol = Chem.MolFromSmiles('')
AllChem.AssignBondOrdersFromTemplate(template, mol)
</code></pre>

CC BY-SA 4.0
2023-03-23T08:14:30.963Z
it seem c++ language which i'm not good at, can you provied a python language? the code you provided make error in my pycharm.
chengyun zhang
CC BY-SA 4.0
2023-03-23T18:56:19.947Z
It's _the_ compchem module in Python. It runs on PyBind11 C++, so pycharm incorrectly does not like the methods not receiving the instance. #noqa will keep it quiet. I did write the code in the SO editor so I cannot guarantee it runs bug-free.
`from typing import List` is the only thing missing as far as I can tell.
Matteo Ferla
CC BY-SA 4.0
2023-03-22T07:25:21.180Z
2023-03-24T11:25:00.343Z
2023-03-24T11:25:00.343Z
Matteo Ferla
<p>I use the diffdock (<a href="https://github.com/gcorso/DiffDock" rel="nofollow noreferrer">link to diffdock on github</a>) to dock a peptide with protein and this tool give me a ligand in sdf file format. I traslate this ligand sdf format file to a pdb format file and find the pdbfile lack res information. I wonder if tools/code can automaticly complete this file. I need the UNK become the residue types like pdb.This my error pdb file（this structure is a peptide）<a href="https://i.sstatic.net/lQjJR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/lQjJR.png" alt="enter image description here" /></a>
<a href="https://i.sstatic.net/lQjJR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/lQjJR.png" alt="enter image description here" /></a></p>
<pre><code>HETATM    1  C   UNK     0       9.797  22.501  -6.484  0.00  0.00           C 
HETATM    2  C   UNK     0      10.366  21.086  -6.446  0.00  0.00           C 
HETATM    3  O   UNK     0       9.550  20.218  -7.135  0.00  0.00           O 
HETATM    4  N   UNK     0      11.710  21.084  -6.978  0.00  0.00           N 
HETATM    5  C   UNK     0      11.793  20.201  -8.123  0.00  0.00           C 
HETATM    6  C   UNK     0      11.151  20.760  -9.346  0.00  0.00           C 
HETATM    7  C   UNK     0      11.586  20.031 -10.581  0.00  0.00           C 
HETATM    8  C   UNK     0      13.000  20.308 -10.986  0.00  0.00           C 
HETATM    9  C   UNK     0      13.397  19.716 -12.309  0.00  0.00           C 
HETATM   10  N   UNK     0      12.636  18.523 -12.633  0.00  0.00           N 
HETATM   11  C   UNK     0      11.861  18.392 -13.830  0.00  0.00           C 
HETATM   12  O   UNK     0      11.837  19.364 -14.611  0.00  0.00           O 
HETATM   13  C   UNK     0      11.148  17.131 -14.065  0.00  0.00           C 
HETATM   14  C   UNK     0      11.800  16.246 -15.085  0.00  0.00           C 
</code></pre>

CC BY-SA 4.0
2023-03-21T11:59:03.270Z
Please don't post images of text. We cannot use them: we can't copy, we can't search. Also, this makes the post heavier for people with slow connections. Instead, copy/paste the text directly into your question and use the [formatting tools](https://bioinformatics.stackexchange.com/help/formatting) to format it as code.
terdon
CC BY-SA 4.0
2023-03-23T21:28:36.887Z
open babel add correct res type to pdb when you feed peptide sdf file, use http://www.cheminfo.org/Chemistry/Cheminformatics/FormatConverter/index.html and https://www.litemol.org/Viewer/ to check it out –
pippo1980
<pdb><peptide-shaker>
complete the res type in sdf
# complete the res type in sdf

(Asked by: username_0 on 2023-03-21)

I use the diffdock (link to diffdock on github) to dock a peptide with protein and this tool give me a ligand in sdf file format. I traslate this ligand sdf format file to a pdb format file and find the pdbfile lack res information. I wonder if tools/code can automaticly complete this file. I need the UNK become the residue types like pdb.This my error pdb file（this structure is a peptide）

HETATM    1  C   UNK     0       9.797  22.501  -6.484  0.00  0.00           C 
HETATM    2  C   UNK     0      10.366  21.086  -6.446  0.00  0.00           C 
HETATM    3  O   UNK     0       9.550  20.218  -7.135  0.00  0.00           O 
HETATM    4  N   UNK     0      11.710  21.084  -6.978  0.00  0.00           N 
HETATM    5  C   UNK     0      11.793  20.201  -8.123  0.00  0.00           C 
HETATM    6  C   UNK     0      11.151  20.760  -9.346  0.00  0.00           C 
HETATM    7  C   UNK     0      11.586  20.031 -10.581  0.00  0.00           C 
HETATM    8  C   UNK     0      13.000  20.308 -10.986  0.00  0.00           C 
HETATM    9  C   UNK     0      13.397  19.716 -12.309  0.00  0.00           C 
HETATM   10  N   UNK     0      12.636  18.523 -12.633  0.00  0.00           N 
HETATM   11  C   UNK     0      11.861  18.392 -13.830  0.00  0.00           C 
HETATM   12  O   UNK     0      11.837  19.364 -14.611  0.00  0.00           O 
HETATM   13  C   UNK     0      11.148  17.131 -14.065  0.00  0.00           C 
HETATM   14  C   UNK     0      11.800  16.246 -15.085  0.00  0.00           C

**Tags:** pdb, peptide-shaker
> **Comments:**
> **username_1**: Please don't post images of text. We cannot use them: we can't copy, we can't search. Also, this makes the post heavier for people with slow connections. Instead, copy/paste the text directly into your question and use the [formatting tools](https://bioinformatics.stackexchange.com/help/formatting) to format it as code.  
> **username_2**: open babel add correct res type to pdb when you feed peptide sdf file, use http://www.cheminfo.org/Chemistry/Cheminformatics/FormatConverter/index.html and https://www.litemol.org/Viewer/ to check it out –  

---

## 1 answers

### Answer by username_3 on 2023-03-22. Score: 1

An SDF file lacks residue information, including atom name.
Although for the latter, the molFileAlias atomic property is frequently used.
Adding residue info
There are several ways to do this, such as in RDKit (blog post):
from rdkit import Chem
from rdkit.Chem import AllChem

from typing import List

with Chem.SDMolSupplier('.sdf') as mol_store:
     mols: List[Chem.Mol] = list(mol_store)

mol: Chem.Mol
for mol in mols:
    atom: Chem.Atom
    for i, atom in enumerate(mol.GetAtoms()):
        info = AllChem.AtomPDBResidueInfo(atomName=f'ATM{i}',
                                          residueName='LIG',
                                          residueNumber=1, 
                                          chainId='X')
        atom.SetMonomerInfo(info)   

mol: Chem.Mol
for mol in mols:
    name: str = mol.GetProp('_Name')
    Chem.MolToPDBFile(mol, f'{name}.pdb')

Notes:

Atom names do have somewhat of a standard format, C1, C2, C3. I am being lazy in the above. If your ligand is present in the RCSB PDB, it will have a chemical component info on the PDB: example and it is often imperative to obey the atom names and atom index from there.
PyMOL or pymol2 module can also add PDB information, therein the residue index is not an integer but a string as it combines w/ insertion code.
In some tools, you lose the bond order, but if you have a SDF and not a PDB, then you are safe. But if you have a reference it's easy to fix.

from rdkit import Chem
from rdkit.Chem import AllChem
template: Chem.Mol = Chem.MolFromSmiles('')
AllChem.AssignBondOrdersFromTemplate(template, mol)

> **Comments:**
> **username_0**: it seem c++ language which i'm not good at, can you provied a python language? the code you provided make error in my pycharm.  
> **username_3**: It's _the_ compchem module in Python. It runs on PyBind11 C++, so pycharm incorrectly does not like the methods not receiving the instance. #noqa will keep it quiet. I did write the code in the SO editor so I cannot guarantee it runs bug-free. `from typing import List` is the only thing missing as far as I can tell.  

---

