Skip to content

Commit

Permalink
add option to not add hydrogen
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Nov 19, 2024
1 parent 2ef6b96 commit 67e31dc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions prody/proteins/fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def addMissingAtoms(infile, method='openbabel', pH=7.0, outfile=None, **kwargs):
Open Babel: An open chemical toolbox *Journal of cheminformatics* **2011** 3:1-14. """

model_residues = kwargs.get("model_residues", False)
add_hydrogens = kwargs.get("add_hydrogens", True)
remove_heterogens = kwargs.get("remove_heterogens", False)
keep_water = kwargs.get("keep_water", True)
overwrite = kwargs.get("overwrite", False)
Expand Down Expand Up @@ -122,7 +123,10 @@ def addMissingAtoms(infile, method='openbabel', pH=7.0, outfile=None, **kwargs):
obconversion.SetInFormat("pdb")
mol = openbabel.OBMol()
obconversion.ReadFile(mol, infile)
mol.AddHydrogens()

if add_hydrogens:
mol.AddHydrogens()

obconversion.WriteFile(mol, outfile)
LOGGER.info("Hydrogens were added to the structure. Structure {0} is saved in the local directry.".format(outfile))

Expand All @@ -147,7 +151,10 @@ def addMissingAtoms(infile, method='openbabel', pH=7.0, outfile=None, **kwargs):

fixer.findMissingAtoms()
fixer.addMissingAtoms()
fixer.addMissingHydrogens(pH)

if add_hydrogens:
fixer.addMissingHydrogens(pH)

PDBFile.writeFile(fixer.topology, fixer.positions, open(outfile, 'w'), keepIds=keep_ids)
LOGGER.info("Hydrogens were added to the structure. New structure is saved as {0}.".format(outfile))

Expand Down

0 comments on commit 67e31dc

Please sign in to comment.