Source code for schrodinger.application.livedesign.tasks
"""
LiveDesign protocol tasks.
Copyright Schrodinger, LLC. All rights reserved.
"""
import os
import shlex
from schrodinger.tasks import tasks
from schrodinger.tasks import jobtasks
from schrodinger.models import parameters
from schrodinger.application.glide import glide
[docs]def run_task(task, task_type):
"""
Check the task to see if it completed successfully. Will raise a
RuntimeError if the job failed or a FileNotFoundError is the output file
does not exist
:param task: job_utils task object
:type task: 'schrodinger.tasks.jobtasks.CmdJobTask'
:param task_type: Calculation performed by the task
:type task_type: str
"""
task.start()
task.wait()
if task.status == tasks.Status.FAILED:
raise RuntimeError(f'ERROR: {task_type} job failed')
if not os.path.exists(task.output.out_file):
raise RuntimeError(
f'ERROR: {task_type} failed to generate {task.output.out_file}')
[docs]class LigPrepTask(jobtasks.CmdJobTask):
"""
Create a LigPrep task using in the input, output and job settings
"""
[docs] class JobConfig(jobtasks.JobConfig):
driver_host_settings: jobtasks.HostSettings = jobtasks.HostSettings(
allowed_host_types=jobtasks.AllowedHostTypes.CPU_ONLY)
[docs] class Output(jobtasks.CmdJobTask.Output):
out_file: jobtasks.TaskFile
dropped_file: jobtasks.TaskFile
[docs] def makeCmd(self):
cmd = ['ligprep']
args = ['-isd', self.input.ligands_file, '-omae', self.output.out_file]
if self.input.ligprep_infile:
args.extend(['-inp', self.input.ligprep_infile])
if self.input.ligprep_args:
args.extend(shlex.split(self.input.ligprep_args))
cmd.extend(args)
cmd.extend(
['-DRIVERHOST',
self.job_config.driver_host_settings.toCmdArg()])
return cmd
[docs] @tasks.preprocessor()
def processOutput(self):
self.output.dropped_file = f'{self.name}-dropped.sdf'
[docs]class LigFilterTask(jobtasks.CmdJobTask):
"""
Create a LigFilter task using in the input, output and job settings
"""
[docs] class JobConfig(jobtasks.JobConfig):
driver_host_settings: jobtasks.HostSettings = jobtasks.HostSettings(
allowed_host_types=jobtasks.AllowedHostTypes.CPU_ONLY)
[docs] class Output(jobtasks.CmdJobTask.Output):
out_file: jobtasks.TaskFile
[docs] def makeCmd(self):
cmd = [
'ligfilter', self.input.ligands_file, '-f', self.input.filter_file,
'-j', self.name
]
if self.job_config.host_settings.num_subjobs:
cmd.extend([
'-NJOBS',
str(self.job_config.host_settings.num_subjobs), '-DRIVERHOST',
self.job_config.driver_host_settings.toCmdArg()
])
return cmd
[docs]class GlideTask(jobtasks.CmdJobTask):
"""
Create a Glide task using in the input, output and job settings
"""
[docs] class JobConfig(jobtasks.JobConfig):
driver_host_settings: jobtasks.HostSettings = jobtasks.HostSettings(
allowed_host_types=jobtasks.AllowedHostTypes.CPU_ONLY)
[docs] class Output(jobtasks.CmdJobTask.Output):
out_file: jobtasks.TaskFile
csv_file: jobtasks.TaskFile
parsed_inp_file: jobtasks.TaskFile
keyword_dict: dict
[docs] def makeCmd(self):
cmd = ['glide', self.output.parsed_inp_file]
cmd.extend(
['-DRIVERHOST',
self.job_config.driver_host_settings.toCmdArg()])
return cmd
[docs] @tasks.postprocessor()
def processOutput(self):
self.output.csv_file = self.name + '.csv'
[docs]class AlignLigandsTask(jobtasks.CmdJobTask):
"""
Create a align_ligands task using in the input, output and job settings. The
alignment_args is a list of arguments that align_ligands takes
"""
[docs] class Output(jobtasks.CmdJobTask.Output):
out_file: jobtasks.TaskFile
[docs] def makeCmd(self):
cmd = [
'align_ligands', self.input.ligands_file, '-o',
self.output.out_file, '-JOBNAME', self.name
] + self.input.alignment_args
return cmd
[docs]class FlexAlignTask(jobtasks.CmdJobTask):
"""
Create a flex_align task using in the input, output and job settings. The
alignment_args is a list of arguments that align_ligands takes
"""
[docs] class Output(jobtasks.CmdJobTask.Output):
out_file: jobtasks.TaskFile
[docs] def makeCmd(self):
cmd = [
'flex_align', '-screen', self.input.ligands_file, '-shape',
self.input.refligs_file, '-JOB', self.name
]
if self.input.flex_align_args:
cmd.extend(shlex.split(self.input.flex_align_args))
return cmd
[docs]class EpikTask(jobtasks.CmdJobTask):
"""
Create a Epik task using in the input, output and job settings
"""
[docs] class JobConfig(jobtasks.JobConfig):
driver_host_settings: jobtasks.HostSettings = jobtasks.HostSettings(
allowed_host_types=jobtasks.AllowedHostTypes.CPU_ONLY)
[docs] class Output(jobtasks.CmdJobTask.Output):
out_file: jobtasks.TaskFile
[docs] def makeCmd(self):
cmd = ['epik']
args = ['-imae', self.input.ligands_file, '-omae', self.output.out_file]
if self.input.epik_infile:
args.extend(['-inp', self.input.epik_infile])
if self.input.epik_args:
args.extend(shlex.split(self.input.epik_args))
cmd.extend(args)
cmd.extend(
['-DRIVERHOST',
self.job_config.driver_host_settings.toCmdArg()])
return cmd