text: user6684: 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?
  
  user6322: 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.
  
original_text: 6684: <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>
   6322: <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>
  