Skip to content

Commit

Permalink
no fixed bonds
Browse files Browse the repository at this point in the history
  • Loading branch information
lmdu committed Nov 24, 2023
1 parent dacbfab commit f3f341c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ def do(self):

elif line.startswith('ENDMDL'):
lines.append(line)
#mode = convert_pdbqt_to_pdb_by_adt(lines, as_string=True)
#mode = convert_pdbqt_to_pdb_by_adt(lfile, lines, as_string=True)
mode = convert_pdbqt_to_pdb(''.join(lines))
modes[idx] = mode

Expand All @@ -650,6 +650,7 @@ def do(self):
lines.append(line)

#receptor = convert_pdbqt_to_pdb_by_adt(rpdbqt, as_string=False)

receptor = convert_pdbqt_to_pdb(rpdbqt, as_string=False)

for i, row in enumerate(rows):
Expand Down
34 changes: 32 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from pymol import cmd
from rdkit import Chem
from rdkit.Chem import AllChem
from MolKit import Read
from MolKit.pdbWriter import PdbWriter
from openbabel import openbabel
Expand All @@ -26,7 +27,7 @@
class NewPdbWriter(PdbWriter):
def write_string(self, atoms):
try:
self.write("\\/*&^%$#@!><|", atoms, records=['ATOM', 'HETATM'])
self.write("\\/*&^%$#@!><|", atoms, records=['ATOM', 'HETATM', 'CONECT'])
except:
pass

Expand Down Expand Up @@ -235,7 +236,34 @@ def generate_complex_pdb(receptor_pdb, ligand_pdb):

return '\n'.join(complex_lines)

def convert_pdbqt_to_pdb_by_adt(pdbqt, as_string=False):
"""
def assign_bond_orders_from_origin(origin_file, pose_string):
origin_format = os.path.splitext(origin_file)[1]
if origin_format == '.pdb':
template = Chem.MolFromPDBFile(origin_file)
elif origin_format == '.mol2':
template = Chem.MolFromMol2File(origin_file)
elif origin_format == '.mol':
template = Chem.MolFromMolFile(origin_file)
elif origin_format == '.sdf':
for template in Chem.SDMolSupplier(origin_file):
pass
with open('pose.pdb', 'w') as fw:
fw.write(pose_string)
docked_pose = Chem.MolFromPDBFile('pose.pdb')
fixed_pose = AllChem.AssignBondOrdersFromTemplate(template, docked_pose)
return Chem.MolToPDBBlock(fixed_pose)
"""

def convert_pdbqt_to_pdb_by_adt(origin_file, pdbqt, as_string=False):
if as_string:
mols = Read(alllines=pdbqt, dataformat='pdbqt')
else:
Expand All @@ -248,6 +276,8 @@ def convert_pdbqt_to_pdb_by_adt(pdbqt, as_string=False):
writer = NewPdbWriter()
res = writer.write_string(mol.allAtoms)

#correct = assign_bond_orders_from_origin(origin_file, res)

return res

def convert_pdbqt_to_pdb(pdbqt, as_string=True):
Expand Down

0 comments on commit f3f341c

Please sign in to comment.