<p>Atom reordering is a common problem in compchemistry.</p>

<p>Rdkit (a python package) can do this, but it is limited by the formats it can read and mol2 files are a bit hit or miss. It works really well with SMILES, SMARTS and mol (sdf) files. But the writing may cause problems with Brookhaven pdb and mol2 files.
So the formats you have are both problematic. One is a pdbqt (a PDB file with partial charges (Q, generally Gasteiger calculated) and atom type (T) and the other a mol2. Let's pretend first that they are not.</p>

<p>Also the hydrogens might be made implicit depending on your mol2 file.</p>

<pre><code>from rdkit import Chem
ref = Chem.MolFromMol2File('ligand.mol2')
target = Chem.MolFromPDBFile('ligand.pdb')
atoms = target.GetSubstructMatches(ref) #: List[int]
new = Chem.RenumberAtoms(target, atoms)
Chem.MolToMolFile(new, 'neoligand.mol')
</code></pre>

<p>Extra steps would be required for the protons and if your starting ligand was not from a file, but a SMILES.</p>

<pre><code>mol = Chem.AddHs(mol) #protonate explicitly
Chem.GetSSSR(mol) #resonance fixing
AllChem.EmbedMolecule(mol) #initialise for 3d.
AllChem.UFFOptimizeMolecule(mol, maxIters=2000)
</code></pre>

<p>So this is all nice, but the formats may not work. Luckily openbabel can deal with this problem.</p>

<pre><code>obabel -i mol2 input.mol2 -o pdbqt -O output.pdbqt
</code></pre>

<p>However, one thing to keep an eye out is what will be recalculated. Say, sdf files do not have partial charges or what PDB calls "atom names" and Rdkit calls "atom labels" (About the latter, I actually wrote <a href="https://github.com/matteoferla/AtomicRenamer" rel="noreferrer">a script to relabel atom labels in pdbs from mol files</a>), while mol2 and PDBQT have.</p>

CC BY-SA 4.0
2019-12-26T15:32:29.717Z
2019-12-26T15:32:29.717Z
Matteo Ferla
<p>When I was drawing conformation of Autodock result, I noticed that Autodock generated pdbqt from dlg has some structural problem (e.g. Benzene ring missing), and wants to correct this. However I noticed that the atom order of pdbqt doesn't match with the original mol2's, and caused some problems when I tried to fix.</p>

<p>So how could I reorder pdbqt according to mol2's atom coordinate?</p>

<proteins><format-conversion><docking>
How could I match atom orders between a .mol2 and a .pdb?
# How could I match atom orders between a .mol2 and a .pdb?

(Asked by: username_0 on 2019-12-25)

When I was drawing conformation of Autodock result, I noticed that Autodock generated pdbqt from dlg has some structural problem (e.g. Benzene ring missing), and wants to correct this. However I noticed that the atom order of pdbqt doesn't match with the original mol2's, and caused some problems when I tried to fix.

So how could I reorder pdbqt according to mol2's atom coordinate?

**Tags:** proteins, format-conversion, docking

---

## 1 answers

### Answer by username_1 on 2019-12-26. Score: 5 | Accepted answer

Atom reordering is a common problem in compchemistry.
Rdkit (a python package) can do this, but it is limited by the formats it can read and mol2 files are a bit hit or miss. It works really well with SMILES, SMARTS and mol (sdf) files. But the writing may cause problems with Brookhaven pdb and mol2 files.
So the formats you have are both problematic. One is a pdbqt (a PDB file with partial charges (Q, generally Gasteiger calculated) and atom type (T) and the other a mol2. Let's pretend first that they are not.
Also the hydrogens might be made implicit depending on your mol2 file.
from rdkit import Chem
ref = Chem.MolFromMol2File('ligand.mol2')
target = Chem.MolFromPDBFile('ligand.pdb')
atoms = target.GetSubstructMatches(ref) #: List[int]
new = Chem.RenumberAtoms(target, atoms)
Chem.MolToMolFile(new, 'neoligand.mol')

Extra steps would be required for the protons and if your starting ligand was not from a file, but a SMILES.
mol = Chem.AddHs(mol) #protonate explicitly
Chem.GetSSSR(mol) #resonance fixing
AllChem.EmbedMolecule(mol) #initialise for 3d.
AllChem.UFFOptimizeMolecule(mol, maxIters=2000)

So this is all nice, but the formats may not work. Luckily openbabel can deal with this problem.
obabel -i mol2 input.mol2 -o pdbqt -O output.pdbqt

However, one thing to keep an eye out is what will be recalculated. Say, sdf files do not have partial charges or what PDB calls "atom names" and Rdkit calls "atom labels" (About the latter, I actually wrote a script to relabel atom labels in pdbs from mol files), while mol2 and PDBQT have.


---

