Source code for schrodinger.application.bioluminate.run_propka
"""
PROPKA wrapper functions
"""
import os
import platform
import subprocess
import sys
PROPKA_SCRIPT = "propka_run_wrapper.py"
[docs]def run_propka(files, **kwargs):
"""
Runs the propka job.
All kwargs will be added to the command line arguments. They must
be taken from the help arguments. The prepended dash is automatically
added to the key. For example, this::
propka.run(files, pH=6.8)
will run propka with "-pH 6.8" added to the command line.
:param files: The pdb files to operate on
:type files: The filename (as string) or list/tuple of filenames (strings)
"""
try:
schro = os.environ['SCHRODINGER']
if sys.platform.startswith("win32"):
cmd = ["%s/run.exe" % schro, PROPKA_SCRIPT]
else:
cmd = ['%s/run' % schro, PROPKA_SCRIPT]
except KeyError:
# In case SCHRODINGER is not defined
cmd = ["python", PROPKA_SCRIPT]
if type(files) in [list, tuple]:
cmd.extend([f for f in files])
else:
cmd.append(files)
for key, val in kwargs.items():
new_key = '-%s' % key
cmd.append(new_key)
cmd.append(val)
# Suppress DeprecationWarning from __main__ when running
env = os.environ.copy()
env["PYTHONWARNINGS"] = "ignore::DeprecationWarning"
proc = subprocess.run(cmd, text=True, env=env, capture_output=True)
return proc.stdout, proc.stderr
if __name__ == '__main__':
# Pass all the arguments to the PROPKA backend
schro = os.environ['SCHRODINGER']
if platform.system() == 'Windows':
cmd = ["%s/run.exe" % schro, PROPKA_SCRIPT]
else:
cmd = ['%s/run' % schro, PROPKA_SCRIPT]
cmd += sys.argv[1:]
subprocess.call(cmd)