Skip to content

Commit

Permalink
Update preprocessing.py
Browse files Browse the repository at this point in the history
Applied MDAnalysis RDKit Converter for SDF Generation
  • Loading branch information
talagayev authored Jun 8, 2024
1 parent 2ef46b7 commit cf6d3c7
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions openmmdl/openmmdl_analysis/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import rdkit
import mdtraj as md
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem import AllChem
from rdkit.Chem import Draw, AllChem, SDWriter
from rdkit.Chem.Draw import rdMolDraw2D
from openbabel import pybel


def renumber_protein_residues(input_pdb, reference_pdb, output_pdb):
Expand Down Expand Up @@ -138,17 +136,13 @@ def extract_and_save_ligand_as_sdf(input_pdb_filename, output_filename, target_r
print(f"No ligand with residue name '{target_resname}' found in the PDB file.")
return

# Create a new Universe with only the ligand
ligand_universe = mda.Merge(ligand_atoms)
#Using RDKit Converter to get SDF File
lig_atoms = ligand_atoms.convert_to("RDKIT")

# Save the ligand Universe as a PDB file
ligand_universe.atoms.write("lig.pdb")

# use openbabel to convert pdb to sdf
mol = next(pybel.readfile("pdb", "lig.pdb"))
mol.write("sdf", output_filename, overwrite=True)
# remove the temporary pdb file
os.remove("lig.pdb")
#Write out the SDF file
writer = SDWriter(output_filename)
writer.write(lig_atoms)
writer.close()


def renumber_atoms_in_residues(input_pdb_file, output_pdb_file, lig_name):
Expand Down

0 comments on commit cf6d3c7

Please sign in to comment.