Skip to content

Commit

Permalink
[FEATURE] New sandbox_path property
Browse files Browse the repository at this point in the history
  • Loading branch information
PauAndrio committed Jun 14, 2024
1 parent eb47782 commit 4872f99
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 27 deletions.
4 changes: 3 additions & 1 deletion biobb_md/gromacs/editconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Editconf(BiobbObject):
* **gmx_path** (*str*) - ("gmx") Path to the GROMACS executable binary.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
* **container_path** (*str*) - (None) Path to the binary executable of your container.
* **container_image** (*str*) - (None) Container Image identifier.
* **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
Expand Down Expand Up @@ -92,7 +93,8 @@ def launch(self) -> int:
"""Execute the :class:`Editconf <gromacs.editconf.Editconf>` object."""

# Setup Biobb
if self.check_restart(): return 0
if self.check_restart():
return 0
self.stage_files()

# Create command line
Expand Down
5 changes: 4 additions & 1 deletion biobb_md/gromacs/genion.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Genion(BiobbObject):
* **gmx_path** (*str*) - ("gmx") Path to the GROMACS executable binary.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
* **container_path** (*str*) - (None) Path to the binary executable of your container.
* **container_image** (*str*) - ("gromacs/gromacs:latest") Container Image identifier.
* **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
Expand Down Expand Up @@ -62,6 +63,7 @@ class Genion(BiobbObject):
* name: EDAM
* schema: http://edamontology.org/EDAM.owl
"""

def __init__(self, input_tpr_path: str, output_gro_path: str, input_top_zip_path: str,
output_top_zip_path: str, input_ndx_path: str = None, properties: dict = None, **kwargs) -> None:
properties = properties or {}
Expand Down Expand Up @@ -104,7 +106,8 @@ def launch(self) -> int:
"""Execute the :class:`Genion <gromacs.genion.Genion>` object."""

# Setup Biobb
if self.check_restart(): return 0
if self.check_restart():
return 0
self.stage_files()

# Unzip topology to topology_out
Expand Down
4 changes: 3 additions & 1 deletion biobb_md/gromacs/genrestr.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Genrestr(BiobbObject):
* **gmx_path** (*str*) - ("gmx") Path to the GROMACS executable binary.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
* **container_path** (*str*) - (None) Path to the binary executable of your container.
* **container_image** (*str*) - ("gromacs/gromacs:latest") Container Image identifier.
* **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
Expand Down Expand Up @@ -92,7 +93,8 @@ def launch(self) -> int:
"""Execute the :class:`Grompp <gromacs.grompp.Grompp>` object."""

# Setup Biobb
if self.check_restart(): return 0
if self.check_restart():
return 0
self.stage_files()

self.cmd = ['echo', '\"'+self.restrained_group+'\"', '|',
Expand Down
4 changes: 3 additions & 1 deletion biobb_md/gromacs/gmxselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Gmxselect(BiobbObject):
* **gmx_lib** (*str*) - (None) Path set GROMACS GMXLIB environment variable.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
* **container_path** (*str*) - (None) Path to the binary executable of your container.
* **container_image** (*str*) - ("gromacs/gromacs:latest") Container Image identifier.
* **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
Expand Down Expand Up @@ -92,7 +93,8 @@ def launch(self) -> int:
"""Execute the :class:`Gmxselect <gromacs.gmxselect.Gmxselect>` object."""

# Setup Biobb
if self.check_restart(): return 0
if self.check_restart():
return 0
self.stage_files()

self.cmd = [self.gmx_path, 'select',
Expand Down
18 changes: 10 additions & 8 deletions biobb_md/gromacs/grompp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Grompp(BiobbObject):
* **gmx_path** (*str*) - ("gmx") Path to the GROMACS executable binary.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
* **container_path** (*str*) - (None) Path to the binary executable of your container.
* **container_image** (*str*) - ("gromacs/gromacs:latest") Container Image identifier.
* **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
Expand Down Expand Up @@ -121,7 +122,8 @@ def launch(self) -> int:
"""Execute the :class:`Grompp <gromacs.grompp.Grompp>` object."""

# Setup Biobb
if self.check_restart(): return 0
if self.check_restart():
return 0
self.stage_files()

# Unzip topology to topology_out
Expand All @@ -146,13 +148,13 @@ def launch(self) -> int:
top_file = str(Path(self.container_volume_path).joinpath(Path(top_dir).name, Path(top_file).name))

self.cmd = [self.gmx_path, 'grompp',
'-f', self.output_mdp_path,
'-c', self.stage_io_dict["in"]["input_gro_path"],
'-r', self.stage_io_dict["in"]["input_gro_path"],
'-p', top_file,
'-o', self.stage_io_dict["out"]["output_tpr_path"],
'-po', 'mdout.mdp',
'-maxwarn', self.maxwarn]
'-f', self.output_mdp_path,
'-c', self.stage_io_dict["in"]["input_gro_path"],
'-r', self.stage_io_dict["in"]["input_gro_path"],
'-p', top_file,
'-o', self.stage_io_dict["out"]["output_tpr_path"],
'-po', 'mdout.mdp',
'-maxwarn', self.maxwarn]

if self.stage_io_dict["in"].get("input_cpt_path") and Path(self.stage_io_dict["in"]["input_cpt_path"]).exists():
self.cmd.append('-t')
Expand Down
1 change: 1 addition & 0 deletions biobb_md/gromacs/grompp_mdrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GromppMdrun(BiobbObject):
* **gmx_path** (*str*) - ("gmx") Path to the GROMACS executable binary.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
* **container_path** (*str*) - (None) Path to the binary executable of your container.
* **container_image** (*str*) - ("gromacs/gromacs:latest") Container Image identifier.
* **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
Expand Down
13 changes: 8 additions & 5 deletions biobb_md/gromacs/make_ndx.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class MakeNdx(BiobbObject):
* **gmx_path** (*str*) - ("gmx") Path to the GROMACS executable binary.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
* **container_path** (*str*) - (None) Path to the binary executable of your container.
* **container_image** (*str*) - ("gromacs/gromacs:latest") Container Image identifier.
* **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
Expand All @@ -53,6 +54,7 @@ class MakeNdx(BiobbObject):
* name: EDAM
* schema: http://edamontology.org/EDAM.owl
"""

def __init__(self, input_structure_path: str, output_ndx_path: str, input_ndx_path: str = None,
properties: dict = None, **kwargs) -> None:
properties = properties or {}
Expand Down Expand Up @@ -89,15 +91,16 @@ def launch(self) -> int:
"""Execute the :class:`MakeNdx <gromacs.make_ndx.MakeNdx>` object."""

# Setup Biobb
if self.check_restart(): return 0
if self.check_restart():
return 0
self.stage_files()

# Create command line
self.cmd = ['echo', '-e', '\'' + self.selection + '\\nq' + '\'', '|',
self.gmx_path, 'make_ndx',
'-f', self.stage_io_dict["in"]["input_structure_path"],
'-o', self.stage_io_dict["out"]["output_ndx_path"]
]
self.gmx_path, 'make_ndx',
'-f', self.stage_io_dict["in"]["input_structure_path"],
'-o', self.stage_io_dict["out"]["output_ndx_path"]
]

if self.stage_io_dict["in"].get("input_ndx_path")\
and Path(self.stage_io_dict["in"].get("input_ndx_path")).exists():
Expand Down
9 changes: 5 additions & 4 deletions biobb_md/gromacs/mdrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Mdrun(BiobbObject):
* **gmx_path** (*str*) - ("gmx") Path to the GROMACS executable binary.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
* **container_path** (*str*) - (None) Path to the binary executable of your container.
* **container_image** (*str*) - (None) Container Image identifier.
* **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
Expand Down Expand Up @@ -128,7 +129,8 @@ def launch(self) -> int:
"""Execute the :class:`Mdrun <gromacs.mdrun.Mdrun>` object."""

# Setup Biobb
if self.check_restart(): return 0
if self.check_restart():
return 0
self.stage_files()

self.cmd = [self.gmx_path, 'mdrun',
Expand Down Expand Up @@ -182,7 +184,7 @@ def launch(self) -> int:
self.cmd.append('-ntomp_pme')
self.cmd.append(self.num_threads_omp_pme)
# GMX gpu properties
if self.use_gpu:
if self.use_gpu:
fu.log('Adding GPU specific settings adds: -nb gpu -pme gpu', self.out_log)
self.cmd += ["-nb", "gpu", "-pme", "gpu"]
if self.gpu_id:
Expand All @@ -194,7 +196,6 @@ def launch(self) -> int:
self.cmd.append('-gputasks')
self.cmd.append(self.gpu_tasks)


if self.gmx_lib:
self.environment = os.environ.copy()
self.environment['GMXLIB'] = self.gmx_lib
Expand Down Expand Up @@ -257,7 +258,7 @@ def main():
# Specific call of each building block
mdrun(input_tpr_path=args.input_tpr_path, output_trr_path=args.output_trr_path,
output_gro_path=args.output_gro_path, output_edr_path=args.output_edr_path,
output_log_path=args.output_log_path, input_cpt_path=args.input_cpt_path,
output_log_path=args.output_log_path, input_cpt_path=args.input_cpt_path,
output_xtc_path=args.output_xtc_path, output_cpt_path=args.output_cpt_path,
output_dhdl_path=args.output_dhdl_path, properties=properties)

Expand Down
8 changes: 5 additions & 3 deletions biobb_md/gromacs/pdb2gmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Pdb2gmx(BiobbObject):
* **gmx_path** (*str*) - ("gmx") Path to the GROMACS executable binary.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
* **container_path** (*str*) - (None) Path to the binary executable of your container.
* **container_image** (*str*) - ("gromacs/gromacs:latest") Container Image identifier.
* **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
Expand Down Expand Up @@ -72,8 +73,8 @@ def __init__(self, input_pdb_path: str, output_gro_path: str, output_top_zip_pat
}

# Properties specific for BB
self.internal_top_name = properties.get('internal_top_name', 'p2g.top') # Excluded from documentation for simplicity
self.internal_itp_name = properties.get('internal_itp_name', 'posre.itp') # Excluded from documentation for simplicity
self.internal_top_name = properties.get('internal_top_name', 'p2g.top') # Excluded from documentation for simplicity
self.internal_itp_name = properties.get('internal_itp_name', 'posre.itp') # Excluded from documentation for simplicity
self.water_type = properties.get('water_type', 'spce')
self.force_field = properties.get('force_field', 'amber99sb-ildn')
self.ignh = properties.get('ignh', False)
Expand All @@ -100,7 +101,8 @@ def launch(self) -> int:
"""Execute the :class:`Pdb2gmx <gromacs.pdb2gmx.Pdb2gmx>` object."""

# Setup Biobb
if self.check_restart(): return 0
if self.check_restart():
return 0
self.stage_files()

internal_top_name = fu.create_name(prefix=self.prefix, step=self.step, name=self.internal_top_name)
Expand Down
5 changes: 4 additions & 1 deletion biobb_md/gromacs/solvate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Solvate(BiobbObject):
* **gmx_path** (*str*) - ("gmx") Path to the GROMACS executable binary.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
* **container_path** (*str*) - (None) Path to the binary executable of your container.
* **container_image** (*str*) - ("gromacs/gromacs:latest") Container Image identifier.
* **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
Expand Down Expand Up @@ -59,6 +60,7 @@ class Solvate(BiobbObject):
* name: EDAM
* schema: http://edamontology.org/EDAM.owl
"""

def __init__(self, input_solute_gro_path: str, output_gro_path: str, input_top_zip_path: str,
output_top_zip_path: str, input_solvent_gro_path: str = None, properties: dict = None, **kwargs) -> None:
properties = properties or {}
Expand Down Expand Up @@ -100,7 +102,8 @@ def launch(self) -> int:
"""Execute the :class:`Solvate <gromacs.solvate.Solvate>` object."""

# Setup Biobb
if self.check_restart(): return 0
if self.check_restart():
return 0
self.stage_files()

# Unzip topology to topology_out
Expand Down
6 changes: 4 additions & 2 deletions biobb_md/gromacs_extra/append_ligand.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AppendLigand(BiobbObject):
* **posres_name** (*str*) - ("POSRES_LIGAND") String to be included in the ifdef clause.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
Examples:
This is a use example of how to use the building block from Python::
Expand Down Expand Up @@ -70,7 +71,8 @@ def __init__(self, input_top_zip_path: str, input_itp_path: str, output_top_zip_
def launch(self) -> int:
"""Execute the :class:`AppendLigand <gromacs_extra.append_ligand.AppendLigand>` object."""
# Setup Biobb
if self.check_restart(): return 0
if self.check_restart():
return 0

# Unzip topology
top_file = fu.unzip_top(zip_file=self.io_dict['in'].get("input_top_zip_path"), out_log=self.out_log)
Expand Down Expand Up @@ -176,7 +178,7 @@ def main():
args = parser.parse_args()
config = args.config if args.config else None
properties = settings.ConfReader(config=config).get_prop_dic()

# Specific call of each building block
append_ligand(input_top_zip_path=args.input_top_zip_path, input_itp_path=args.input_itp_path,
output_top_zip_path=args.output_top_zip_path, input_posres_itp_path=args.input_posres_itp_path,
Expand Down

0 comments on commit 4872f99

Please sign in to comment.