Skip to content

Commit

Permalink
[TYPING](ALL): Fix typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PauAndrio committed Oct 17, 2024
1 parent aaba598 commit e06b72a
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 47 deletions.
8 changes: 4 additions & 4 deletions biobb_gromacs/gromacs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path
from biobb_common.tools import file_utils as fu
from biobb_common.command_wrapper import cmd_wrapper
from typing import Dict, Mapping, Optional
from typing import Mapping, Optional


def get_gromacs_version(gmx: str = "gmx", minimum_version: int = 512) -> int:
Expand Down Expand Up @@ -108,7 +108,7 @@ def gmx_rms(file_a: str, file_b: str, file_tpr: str, gmx: str = 'gmx', tolerance
return True


def read_mdp(input_mdp_path: str) -> Dict[str, str]:
def read_mdp(input_mdp_path: str) -> dict[str, str]:
# Credit for these two reg exps to:
# https://github.com/Becksteinlab/GromacsWrapper/blob/master/gromacs/fileformats/mdp.py
parameter_re = re.compile(r"\s*(?P<parameter>[^=]+?)\s*=\s*(?P<value>[^;]*)(?P<comment>\s*;.*)?", re.VERBOSE)
Expand All @@ -125,8 +125,8 @@ def read_mdp(input_mdp_path: str) -> Dict[str, str]:
return mdp_dict


def mdp_preset(sim_type: str) -> Dict[str, str]:
mdp_dict: Dict[str, str] = {}
def mdp_preset(sim_type: str) -> dict[str, str]:
mdp_dict: dict[str, str] = {}
if not sim_type or sim_type == 'index':
return mdp_dict

Expand Down
7 changes: 4 additions & 3 deletions biobb_gromacs/gromacs/editconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

"""Module containing the Editconf class and the command line interface."""
import argparse
from typing import Optional
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
from biobb_common.tools import file_utils as fu
from biobb_common.tools.file_utils import launchlogger
from biobb_gromacs.gromacs.common import get_gromacs_version
from typing import Optional, Dict
from typing import Optional


class Editconf(BiobbObject):
Expand Down Expand Up @@ -56,7 +57,7 @@ class Editconf(BiobbObject):
* schema: http://edamontology.org/EDAM.owl
"""

def __init__(self, input_gro_path: str, output_gro_path: str, properties: Optional[Dict] = None, **kwargs) -> None:
def __init__(self, input_gro_path: str, output_gro_path: str, properties: Optional[dict] = None, **kwargs) -> None:
properties = properties or {}

# Call parent class constructor
Expand Down Expand Up @@ -139,7 +140,7 @@ def launch(self) -> int:
return self.return_code


def editconf(input_gro_path: str, output_gro_path: str, properties: Optional[Dict] = None, **kwargs) -> int:
def editconf(input_gro_path: str, output_gro_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Create :class:`Editconf <gromacs.editconf.Editconf>` class and
execute the :meth:`launch() <gromacs.editconf.Editconf.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_gromacs/gromacs/genion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"""Module containing the Genion class and the command line interface."""
import shutil
import argparse
from typing import Optional
from pathlib import Path
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
from biobb_common.tools import file_utils as fu
from biobb_common.tools.file_utils import launchlogger
from biobb_gromacs.gromacs.common import get_gromacs_version
from typing import Optional, Dict, Union
from typing import Optional, Union


class Genion(BiobbObject):
Expand Down Expand Up @@ -64,7 +65,7 @@ class Genion(BiobbObject):
"""

def __init__(self, input_tpr_path: Union[str, Path], output_gro_path: Union[str, Path], input_top_zip_path: Union[str, Path],
output_top_zip_path: Union[str, Path], input_ndx_path: Optional[Union[str, Path]] = None, properties: Optional[Dict] = None, **kwargs) -> None:
output_top_zip_path: Union[str, Path], input_ndx_path: Optional[Union[str, Path]] = None, properties: Optional[dict] = None, **kwargs) -> None:
properties = properties or {}

# Call parent class constructor
Expand Down Expand Up @@ -173,7 +174,7 @@ def launch(self) -> int:


def genion(input_tpr_path: Union[str, Path], output_gro_path: Union[str, Path], input_top_zip_path: Union[str, Path],
output_top_zip_path: Union[str, Path], input_ndx_path: Optional[Union[str, Path]] = None, properties: Optional[Dict] = None, **kwargs) -> int:
output_top_zip_path: Union[str, Path], input_ndx_path: Optional[Union[str, Path]] = None, properties: Optional[dict] = None, **kwargs) -> int:
"""Create :class:`Genion <gromacs.genion.Genion>` class and
execute the :meth:`launch() <gromacs.genion.Genion.launch>` method."""
return Genion(input_tpr_path=input_tpr_path, output_gro_path=output_gro_path,
Expand Down
7 changes: 4 additions & 3 deletions biobb_gromacs/gromacs/genrestr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

"""Module containing the Genrestr class and the command line interface."""
import argparse
from typing import Optional
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
from biobb_common.tools import file_utils as fu
from biobb_common.tools.file_utils import launchlogger
from biobb_gromacs.gromacs.common import get_gromacs_version
from pathlib import Path
from typing import Union, Optional, Dict
from typing import Union, Optional


class Genrestr(BiobbObject):
Expand Down Expand Up @@ -57,7 +58,7 @@ class Genrestr(BiobbObject):
"""

def __init__(self, input_structure_path: Union[str, Path], output_itp_path: Union[str, Path],
input_ndx_path: Optional[Union[str, Path]] = None, properties: Optional[Dict] = None, **kwargs) -> None:
input_ndx_path: Optional[Union[str, Path]] = None, properties: Optional[dict] = None, **kwargs) -> None:
properties = properties or {}

# Call parent class constructor
Expand Down Expand Up @@ -137,7 +138,7 @@ def launch(self) -> int:


def genrestr(input_structure_path: Union[str, Path], output_itp_path: Union[str, Path],
input_ndx_path: Optional[Union[str, Path]] = None, properties: Optional[Dict] = None, **kwargs) -> int:
input_ndx_path: Optional[Union[str, Path]] = None, properties: Optional[dict] = None, **kwargs) -> int:
"""Create :class:`Genrestr <gromacs.genrestr.Genrestr>` class and
execute the :meth:`launch() <gromacs.genrestr.Genrestr.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_gromacs/gromacs/gmxselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

"""Module containing the Select class and the command line interface."""
import argparse
from typing import Optional
from pathlib import Path
from typing import Optional, Dict
from typing import Optional
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
from biobb_common.tools import file_utils as fu
Expand Down Expand Up @@ -56,7 +57,7 @@ class Gmxselect(BiobbObject):
"""

def __init__(self, input_structure_path: str, output_ndx_path: str, input_ndx_path: Optional[str] = None,
properties: Optional[Dict] = None, **kwargs) -> None:
properties: Optional[dict] = None, **kwargs) -> None:
properties = properties or {}

# Call parent class constructor
Expand Down Expand Up @@ -138,7 +139,7 @@ def launch(self) -> int:


def gmxselect(input_structure_path: str, output_ndx_path: str,
input_ndx_path: Optional[str] = None, properties: Optional[Dict] = None,
input_ndx_path: Optional[str] = None, properties: Optional[dict] = None,
**kwargs) -> int:
"""Create :class:`Gmxselect <gromacs.gmxselect.Gmxselect>` class and
execute the :meth:`launch() <gromacs.gmxselect.Gmxselect.launch>` method."""
Expand Down
5 changes: 3 additions & 2 deletions biobb_gromacs/gromacs/grompp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

"""Module containing the Grompp class and the command line interface."""
import argparse
from typing import Optional
import shutil
from typing import Optional, Dict
from typing import Optional
from pathlib import Path
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -70,7 +71,7 @@ class Grompp(BiobbObject):

def __init__(self, input_gro_path: str, input_top_zip_path: str, output_tpr_path: str,
input_cpt_path: Optional[str] = None, input_ndx_path: Optional[str] = None, input_mdp_path: Optional[str] = None,
properties: Optional[Dict] = None, **kwargs) -> None:
properties: Optional[dict] = None, **kwargs) -> None:
properties = properties or {}

# Call parent class constructor
Expand Down
9 changes: 5 additions & 4 deletions biobb_gromacs/gromacs/grompp_mdrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

"""Module containing the GromppMDrun class and the command line interface."""
import argparse
from typing import Optional, Dict
from typing import Optional
from typing import Optional
from pathlib import Path
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -44,8 +45,8 @@ class GromppMdrun(BiobbObject):
* **num_threads_omp** (*int*) - (0) [0-1000|1] Let GROMACS guess. The number of GROMACS OPENMP threads that are going to be used.
* **num_threads_omp_pme** (*int*) - (0) [0-1000|1] Let GROMACS guess. The number of GROMACS OPENMP_PME threads that are going to be used.
* **use_gpu** (*bool*) - (False) Use settings appropriate for GPU. Adds: -nb gpu -pme gpu
* **gpu_id** (*str*) - (None) List of unique GPU device IDs available to use.
* **gpu_tasks** (*str*) - (None) List of GPU device IDs, mapping each PP task on each node to a device.
* **gpu_id** (*str*) - (None) list of unique GPU device IDs available to use.
* **gpu_tasks** (*str*) - (None) list of GPU device IDs, mapping each PP task on each node to a device.
* **gmx_lib** (*str*) - (None) Path set GROMACS GMXLIB environment variable.
* **binary_path** (*str*) - ("gmx") Path to the GROMACS executable binary.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
Expand Down Expand Up @@ -166,7 +167,7 @@ def grompp_mdrun(input_gro_path: str, input_top_zip_path: str, output_trr_path:
output_gro_path: str, output_edr_path: str, output_log_path: str,
input_cpt_path: Optional[str] = None, input_ndx_path: Optional[str] = None, input_mdp_path: Optional[str] = None,
output_xtc_path: Optional[str] = None, output_cpt_path: Optional[str] = None, output_dhdl_path: Optional[str] = None,
output_tpr_path: Optional[str] = None, properties: Optional[Dict] = None, **kwargs) -> int:
output_tpr_path: Optional[str] = None, properties: Optional[dict] = None, **kwargs) -> int:
return GromppMdrun(input_gro_path=input_gro_path, input_top_zip_path=input_top_zip_path,
output_trr_path=output_trr_path, output_gro_path=output_gro_path,
output_edr_path=output_edr_path, output_log_path=output_log_path,
Expand Down
7 changes: 4 additions & 3 deletions biobb_gromacs/gromacs/make_ndx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

"""Module containing the MakeNdx class and the command line interface."""
import argparse
from typing import Optional
from pathlib import Path
from typing import Optional, Dict
from typing import Optional
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
from biobb_common.tools import file_utils as fu
Expand Down Expand Up @@ -55,7 +56,7 @@ class MakeNdx(BiobbObject):
"""

def __init__(self, input_structure_path: str, output_ndx_path: str, input_ndx_path: Optional[str] = None,
properties: Optional[Dict] = None, **kwargs) -> None:
properties: Optional[dict] = None, **kwargs) -> None:
properties = properties or {}

# Call parent class constructor
Expand Down Expand Up @@ -132,7 +133,7 @@ def launch(self) -> int:


def make_ndx(input_structure_path: str, output_ndx_path: str,
input_ndx_path: Optional[str] = None, properties: Optional[Dict] = None, **kwargs) -> int:
input_ndx_path: Optional[str] = None, properties: Optional[dict] = None, **kwargs) -> int:
"""Create :class:`MakeNdx <gromacs.make_ndx.MakeNdx>` class and
execute the :meth:`launch() <gromacs.make_ndx.MakeNdx.launch>` method."""
return MakeNdx(input_structure_path=input_structure_path,
Expand Down
9 changes: 5 additions & 4 deletions biobb_gromacs/gromacs/mdrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Module containing the MDrun class and the command line interface."""
import argparse
from typing import Optional
from typing import Optional
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
from biobb_common.tools import file_utils as fu
Expand Down Expand Up @@ -36,8 +37,8 @@ class Mdrun(BiobbObject):
* **num_threads_omp** (*int*) - (0) [0~1000|1] Let GROMACS guess. The number of GROMACS OPENMP threads that are going to be used.
* **num_threads_omp_pme** (*int*) - (0) [0~1000|1] Let GROMACS guess. The number of GROMACS OPENMP_PME threads that are going to be used.
* **use_gpu** (*bool*) - (False) Use settings appropriate for GPU. Adds: -nb gpu -pme gpu
* **gpu_id** (*str*) - (None) List of unique GPU device IDs available to use.
* **gpu_tasks** (*str*) - (None) List of GPU device IDs, mapping each PP task on each node to a device.
* **gpu_id** (*str*) - (None) list of unique GPU device IDs available to use.
* **gpu_tasks** (*str*) - (None) list of GPU device IDs, mapping each PP task on each node to a device.
* **gmx_lib** (*str*) - (None) Path set GROMACS GMXLIB environment variable.
* **binary_path** (*str*) - ("gmx") Path to the GROMACS executable binary.
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
Expand Down Expand Up @@ -198,11 +199,11 @@ def launch(self) -> int:
fu.log('Adding GPU specific settings adds: -nb gpu -pme gpu', self.out_log)
self.cmd += ["-nb", "gpu", "-pme", "gpu"]
if self.gpu_id:
fu.log(f'List of unique GPU device IDs available to use: {self.gpu_id}', self.out_log)
fu.log(f'list of unique GPU device IDs available to use: {self.gpu_id}', self.out_log)
self.cmd.append('-gpu_id')
self.cmd.append(self.gpu_id)
if self.gpu_tasks:
fu.log(f'List of GPU device IDs, mapping each PP task on each node to a device: {self.gpu_tasks}', self.out_log)
fu.log(f'list of GPU device IDs, mapping each PP task on each node to a device: {self.gpu_tasks}', self.out_log)
self.cmd.append('-gputasks')
self.cmd.append(self.gpu_tasks)

Expand Down
7 changes: 4 additions & 3 deletions biobb_gromacs/gromacs/pdb2gmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""Module containing the Pdb2gmx class and the command line interface."""
import os
import argparse
from typing import Optional, Dict
from typing import Optional
from typing import Optional
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
from biobb_common.tools import file_utils as fu
Expand Down Expand Up @@ -59,7 +60,7 @@ class Pdb2gmx(BiobbObject):
* schema: http://edamontology.org/EDAM.owl
"""

def __init__(self, input_pdb_path: str, output_gro_path: str, output_top_zip_path: str, properties: Optional[Dict] = None,
def __init__(self, input_pdb_path: str, output_gro_path: str, output_top_zip_path: str, properties: Optional[dict] = None,
**kwargs) -> None:
properties = properties or {}

Expand Down Expand Up @@ -158,7 +159,7 @@ def launch(self) -> int:


def pdb2gmx(input_pdb_path: str, output_gro_path: str, output_top_zip_path: str,
properties: Optional[Dict] = None, **kwargs) -> int:
properties: Optional[dict] = None, **kwargs) -> int:
"""Create :class:`Pdb2gmx <gromacs.pdb2gmx.Pdb2gmx>` class and
execute the :meth:`launch() <gromacs.pdb2gmx.Pdb2gmx.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_gromacs/gromacs/solvate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"""Module containing the Editconf class and the command line interface."""
import shutil
import argparse
from typing import Optional
from pathlib import Path
from typing import Optional, Dict
from typing import Optional
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
from biobb_common.tools import file_utils as fu
Expand Down Expand Up @@ -61,7 +62,7 @@ class Solvate(BiobbObject):
"""

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: Optional[str] = None, properties: Optional[Dict] = None, **kwargs) -> None:
output_top_zip_path: str, input_solvent_gro_path: Optional[str] = None, properties: Optional[dict] = None, **kwargs) -> None:
properties = properties or {}

# Call parent class constructor
Expand Down Expand Up @@ -151,7 +152,7 @@ def launch(self) -> int:


def solvate(input_solute_gro_path: str, output_gro_path: str, input_top_zip_path: str,
output_top_zip_path: str, input_solvent_gro_path: Optional[str] = None, properties: Optional[Dict] = None, **kwargs) -> int:
output_top_zip_path: str, input_solvent_gro_path: Optional[str] = None, properties: Optional[dict] = None, **kwargs) -> int:
"""Create :class:`Solvate <gromacs.solvate.Solvate>` class and
execute the :meth:`launch() <gromacs.solvate.Solvate.launch>` method."""

Expand Down
10 changes: 5 additions & 5 deletions biobb_gromacs/gromacs/trjcat.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python3

"""Module containing the Trjcat class and the command line interface."""
import typing
import shutil
import argparse
from typing import Optional
from pathlib import Path
from typing import Optional, Dict
from typing import Optional
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
from biobb_common.tools import file_utils as fu
Expand Down Expand Up @@ -55,7 +55,7 @@ class Trjcat(BiobbObject):
* schema: http://edamontology.org/EDAM.owl
"""

def __init__(self, input_trj_zip_path: str, output_trj_path: str, properties: Optional[Dict] = None, **kwargs) -> None:
def __init__(self, input_trj_zip_path: str, output_trj_path: str, properties: Optional[dict] = None, **kwargs) -> None:
properties = properties or {}

# Call parent class constructor
Expand Down Expand Up @@ -101,7 +101,7 @@ def launch(self) -> int:

# Unzip trajectory bundle
trj_dir: str = fu.create_unique_dir()
trj_list: typing.List[str] = fu.unzip_list(self.input_trj_zip_path, trj_dir, self.out_log)
trj_list: list[str] = fu.unzip_list(self.input_trj_zip_path, trj_dir, self.out_log)

# Copy trajectories to container
if self.container_path:
Expand Down Expand Up @@ -135,7 +135,7 @@ def launch(self) -> int:
return self.return_code


def trjcat(input_trj_zip_path: str, output_trj_path: str, properties: Optional[Dict] = None, **kwargs) -> int:
def trjcat(input_trj_zip_path: str, output_trj_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Create :class:`Trjcat <gromacs.trjcat.Trjcat>` class and
execute the :meth:`launch() <gromacs.trjcat.Trjcat.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_gromacs/gromacs_extra/append_ligand.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"""Module containing the AppendLigand class and the command line interface."""
import re
import argparse
from typing import Optional
import shutil
from pathlib import Path
from typing import Optional, Dict
from typing import Optional
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
from biobb_common.tools import file_utils as fu
Expand Down Expand Up @@ -49,7 +50,7 @@ class AppendLigand(BiobbObject):
"""

def __init__(self, input_top_zip_path: str, input_itp_path: str, output_top_zip_path: str,
input_posres_itp_path: Optional[str] = None, properties: Optional[Dict] = None, **kwargs) -> None:
input_posres_itp_path: Optional[str] = None, properties: Optional[dict] = None, **kwargs) -> None:
properties = properties or {}

# Call parent class constructor
Expand Down Expand Up @@ -156,7 +157,7 @@ def launch(self) -> int:


def append_ligand(input_top_zip_path: str, input_itp_path: str, output_top_zip_path: str,
input_posres_itp_path: Optional[str] = None, properties: Optional[Dict] = None, **kwargs) -> int:
input_posres_itp_path: Optional[str] = None, properties: Optional[dict] = None, **kwargs) -> int:
"""Create :class:`AppendLigand <gromacs_extra.append_ligand.AppendLigand>` class and
execute the :meth:`launch() <gromacs_extra.append_ligand.AppendLigand.launch>` method."""
return AppendLigand(input_top_zip_path=input_top_zip_path,
Expand Down
Loading

0 comments on commit e06b72a

Please sign in to comment.