Skip to content
Snippets Groups Projects
Commit e08c3243 authored by Bienchen's avatar Bienchen
Browse files

Enable extra arguents for run-af2 (for custom run_alphafold.py scripts)

parent d3a33a2f
No related branches found
No related tags found
No related merge requests found
...@@ -212,7 +212,7 @@ def parse_af2_arguments(parser): ...@@ -212,7 +212,7 @@ def parse_af2_arguments(parser):
metavar="<FILE>", metavar="<FILE>",
default=None, default=None,
) )
opts = parser.parse_args() opts, extra_opts = parser.parse_known_args()
# check that the db_preset setting makes sense # check that the db_preset setting makes sense
for arg in db_preset_choices[opts.db_preset]: for arg in db_preset_choices[opts.db_preset]:
...@@ -253,7 +253,7 @@ def parse_af2_arguments(parser): ...@@ -253,7 +253,7 @@ def parse_af2_arguments(parser):
) )
sys.exit(1) sys.exit(1)
return opts return opts, extra_opts
# LocalWords: argparse ArgumentParser Namespace Bioinformatics Biozentrum af # LocalWords: argparse ArgumentParser Namespace Bioinformatics Biozentrum af
......
...@@ -118,6 +118,7 @@ def _assemble_singularity_call( # pylint: disable=too-many-arguments ...@@ -118,6 +118,7 @@ def _assemble_singularity_call( # pylint: disable=too-many-arguments
model_preset, model_preset,
is_prokaryote_list, is_prokaryote_list,
data_paths, data_paths,
extra_arg_list,
): ):
"""Assemble the command to run AF2 from the Singularity image.""" """Assemble the command to run AF2 from the Singularity image."""
# Since the number of arguments to this function is already high, we allow # Since the number of arguments to this function is already high, we allow
...@@ -158,6 +159,9 @@ def _assemble_singularity_call( # pylint: disable=too-many-arguments ...@@ -158,6 +159,9 @@ def _assemble_singularity_call( # pylint: disable=too-many-arguments
for flag, path in data_paths.items(): for flag, path in data_paths.items():
snglrty_cmd.append(f"--{flag}={path}") snglrty_cmd.append(f"--{flag}={path}")
# append extra arguments
snglrty_cmd.extend(extra_arg_list)
return snglrty_cmd return snglrty_cmd
...@@ -199,6 +203,7 @@ def run_af2_singularity_image( # pylint: disable=too-many-arguments ...@@ -199,6 +203,7 @@ def run_af2_singularity_image( # pylint: disable=too-many-arguments
af2_image_dir="/scicore/home/schwede/GROUP/alphafold_data/", af2_image_dir="/scicore/home/schwede/GROUP/alphafold_data/",
snglrty_bin="/usr/bin/singularity", snglrty_bin="/usr/bin/singularity",
tmpdir_var="TMPDIR", tmpdir_var="TMPDIR",
extra_arg_list=None,
# data_dir="/scicore/data/managed/AF2params/frozen_210805T171956/", # data_dir="/scicore/data/managed/AF2params/frozen_210805T171956/",
data_dir="/scicore/home/schwede/GROUP/alphafold_data/", data_dir="/scicore/home/schwede/GROUP/alphafold_data/",
uniref90_database_path="/scicore/data/managed/UniProt/latest/uniref/" uniref90_database_path="/scicore/data/managed/UniProt/latest/uniref/"
...@@ -274,6 +279,10 @@ def run_af2_singularity_image( # pylint: disable=too-many-arguments ...@@ -274,6 +279,10 @@ def run_af2_singularity_image( # pylint: disable=too-many-arguments
:param tmpdir_var: An environment variable defining tmp space, that is not :param tmpdir_var: An environment variable defining tmp space, that is not
necessarily "/tmp" on some systems. necessarily "/tmp" on some systems.
:type tmpdir_var: :class:`str` :type tmpdir_var: :class:`str`
:param extra_arg_list: List of extra arguments appended to the Singularity
call. That is for adding extra arguments in a
modified version of run_alphafold.py.
:type extra_arg_list: :class:`list`
:param data_dir: Holds the params sub directory with model parameters. :param data_dir: Holds the params sub directory with model parameters.
Corresponds to DOWNLOAD_DIR in AF2. Corresponds to DOWNLOAD_DIR in AF2.
:type data_dir: :class:`str` :type data_dir: :class:`str`
...@@ -321,6 +330,8 @@ def run_af2_singularity_image( # pylint: disable=too-many-arguments ...@@ -321,6 +330,8 @@ def run_af2_singularity_image( # pylint: disable=too-many-arguments
# Since the number of arguments to this function is already high, we allow # Since the number of arguments to this function is already high, we allow
# more local variables than defined by PEP8. # more local variables than defined by PEP8.
# pylint: disable=too-many-locals # pylint: disable=too-many-locals
if extra_arg_list is None:
extra_arg_list = []
tmpdir = os.getenv(tmpdir_var) tmpdir = os.getenv(tmpdir_var)
if tmpdir is None: if tmpdir is None:
raise ValueError(f"tmpdir_var {tmpdir_var} must not be empty.") raise ValueError(f"tmpdir_var {tmpdir_var} must not be empty.")
...@@ -382,6 +393,7 @@ def run_af2_singularity_image( # pylint: disable=too-many-arguments ...@@ -382,6 +393,7 @@ def run_af2_singularity_image( # pylint: disable=too-many-arguments
model_preset, model_preset,
is_prokaryote_list, is_prokaryote_list,
data_paths, data_paths,
extra_arg_list,
) )
# set up environment # set up environment
...@@ -412,7 +424,7 @@ def run_af2_singularity_image( # pylint: disable=too-many-arguments ...@@ -412,7 +424,7 @@ def run_af2_singularity_image( # pylint: disable=too-many-arguments
def main(): def main():
"""Execute as script""" """Execute as script"""
opts = _parse_cmdline() opts, extra_arg_list = _parse_cmdline()
# Collect data paths into a dictionary so we can deal with default path on # Collect data paths into a dictionary so we can deal with default path on
# the sciCORE cluster more easily. # the sciCORE cluster more easily.
...@@ -449,7 +461,8 @@ def main(): ...@@ -449,7 +461,8 @@ def main():
opts.db_preset, opts.db_preset,
opts.model_preset, opts.model_preset,
opts.is_prokaryote_list, opts.is_prokaryote_list,
af2_image_file=opts.singularity_image, opts.singularity_image,
extra_arg_list=extra_arg_list,
**data_paths, **data_paths,
) )
except RuntimeError as rte: except RuntimeError as rte:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment