Skip to content

Commit

Permalink
Create pdbfix.py
Browse files Browse the repository at this point in the history
  • Loading branch information
plainerman authored Nov 20, 2023
1 parent 817dce6 commit 03be621
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions utils/pdbfix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import glob
from pdbfixer import PDBFixer
from openmm.app import PDBFile

base_dir = 'posebusters_benchmark_set'
suffix = '_protein.pdb'
new_suffix = '_protein_fix.pdb'
for in_file in list(glob.glob(f'posebusters_benchmark_set/*/*{suffix}')):
prefix = os.path.basename(in_file).removesuffix(suffix)
out_file = os.path.join(os.path.dirname(in_file), prefix + new_suffix)
print(f'{in_file} -> {out_file}')

fixer = PDBFixer(filename=in_file)
fixer.findMissingResidues()
fixer.findNonstandardResidues()
fixer.replaceNonstandardResidues()
# fixer.removeHeterogens(True)
fixer.findMissingAtoms()
fixer.addMissingAtoms()

with open(out_file, 'w+') as out:
PDBFile.writeFile(fixer.topology, fixer.positions, out)

0 comments on commit 03be621

Please sign in to comment.