Skip to content

Commit

Permalink
[TYPING](ALL): Fix typing problems
Browse files Browse the repository at this point in the history
  • Loading branch information
PauAndrio committed Oct 17, 2024
1 parent 0f55c8e commit 6135504
Show file tree
Hide file tree
Showing 21 changed files with 85 additions and 64 deletions.
4 changes: 2 additions & 2 deletions biobb_analysis/ambertools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ def copy_instructions_file_to_container(instructions_file, unique_dir):
def remove_tmp_files(list, remove_tmp, out_log, input_top_path_orig=None, input_top_path=None):
""" Removes temporal files generated by the wrapper """
tmp_files = list
if zipfile.is_zipfile(input_top_path_orig):
tmp_files.append(PurePath(input_top_path).parent)
if zipfile.is_zipfile(str(input_top_path_orig)):
tmp_files.append(PurePath(str(input_top_path)).parent)

if remove_tmp:
removed_files = [f for f in tmp_files if fu.rm(f)]
Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Average class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -167,8 +168,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(PurePath(str(self.instructions_file)).parent)
])
self.remove_tmp_files()

Expand All @@ -177,7 +178,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_average(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: dict = None, **kwargs) -> int:
def cpptraj_average(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajAverage <ambertools.cpptraj_average.CpptrajAverage>` class and
execute the :meth:`launch() <ambertools.cpptraj_average.CpptrajAverage.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_bfactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Bfactor class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -174,8 +175,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(str(PurePath(self.instructions_file).parent))
])
self.remove_tmp_files()

Expand All @@ -184,7 +185,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_bfactor(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, input_exp_path: str = None, properties: dict = None, **kwargs) -> int:
def cpptraj_bfactor(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, input_exp_path: Optional[str] = None, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajBfactor <ambertools.cpptraj_bfactor.CpptrajBfactor>` class and
execute the :meth:`launch() <ambertools.cpptraj_bfactor.CpptrajBfactor.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Convert class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -164,8 +165,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(PurePath(self.instructions_file).parent)
])
self.remove_tmp_files()

Expand All @@ -174,7 +175,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_convert(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: dict = None, **kwargs) -> int:
def cpptraj_convert(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajConvert <ambertools.cpptraj_convert.CpptrajConvert>` class and
execute the :meth:`launch() <ambertools.cpptraj_convert.CpptrajConvert.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_dry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Dry class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -170,8 +171,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(PurePath(self.instructions_file).parent)
])
self.remove_tmp_files()

Expand All @@ -180,7 +181,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_dry(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: dict = None, **kwargs) -> int:
def cpptraj_dry(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajDry <ambertools.cpptraj_dry.CpptrajDry>` class and
execute the :meth:`launch() <ambertools.cpptraj_dry.CpptrajDry.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Image class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -170,8 +171,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(PurePath(self.instructions_file).parent)
])
self.remove_tmp_files()

Expand All @@ -180,7 +181,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_image(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: dict = None, **kwargs) -> int:
def cpptraj_image(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajImage <ambertools.cpptraj_image.CpptrajImage>` class and
execute the :meth:`launch() <ambertools.cpptraj_image.CpptrajImage.launch>` method."""

Expand Down
9 changes: 5 additions & 4 deletions biobb_analysis/ambertools/cpptraj_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Input 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
Expand Down Expand Up @@ -65,9 +66,9 @@ def create_instrucions_file(self):
instructions_list = []
output_instructions_path = fu.create_name(prefix=self.prefix, step=self.step, name=get_default_value("instructions_file"))

instructions_list.append('parm ' + self.input_top_path)
instructions_list.append('trajin ' + self.input_traj_path)
instructions_list.append('trajout ' + self.output_cpptraj_path + ' ' + get_default_value("format"))
instructions_list.append('parm ' + str(self.input_top_path))
instructions_list.append('trajin ' + str(self.input_traj_path))
instructions_list.append('trajout ' + str(self.output_cpptraj_path) + ' ' + get_default_value("format"))

with open(output_instructions_path, 'w') as mdp:
for line in instructions_list:
Expand Down Expand Up @@ -101,7 +102,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_input(input_instructions_path: str, properties: dict = None, **kwargs) -> int:
def cpptraj_input(input_instructions_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajInput <ambertools.cpptraj_input.CpptrajInput>` class and
execute the :meth:`launch() <ambertools.cpptraj_input.CpptrajInput.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Mask class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -169,8 +170,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(PurePath(self.instructions_file).parent)
])
self.remove_tmp_files()

Expand All @@ -179,7 +180,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_mask(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: dict = None, **kwargs) -> int:
def cpptraj_mask(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajMask <ambertools.cpptraj_mask.CpptrajMask>` class and
execute the :meth:`launch() <ambertools.cpptraj_mask.CpptrajMask.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_rgyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Rgyr class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -162,8 +163,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(PurePath(self.instructions_file).parent)
])
self.remove_tmp_files()

Expand All @@ -172,7 +173,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_rgyr(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: dict = None, **kwargs) -> int:
def cpptraj_rgyr(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajRgyr <ambertools.cpptraj_rgyr.CpptrajRgyr>` class and
execute the :meth:`launch() <ambertools.cpptraj_rgyr.CpptrajRgyr.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_rms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Rms class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -188,8 +189,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(PurePath(self.instructions_file).parent)
])
self.remove_tmp_files()

Expand All @@ -198,7 +199,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_rms(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, input_exp_path: str = None, output_traj_path: str = None, properties: dict = None, **kwargs) -> int:
def cpptraj_rms(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, input_exp_path: Optional[str] = None, output_traj_path: Optional[str] = None, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajRms <ambertools.cpptraj_rms.CpptrajRms>` class and
execute the :meth:`launch() <ambertools.cpptraj_rms.CpptrajRms.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_rmsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Rmsf class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -174,8 +175,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(PurePath(self.instructions_file).parent)
])
self.remove_tmp_files()

Expand All @@ -184,7 +185,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_rmsf(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, input_exp_path: str = None, properties: dict = None, **kwargs) -> int:
def cpptraj_rmsf(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, input_exp_path: Optional[str] = None, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajRmsf <ambertools.cpptraj_rmsf.CpptrajRmsf>` class and
execute the :meth:`launch() <ambertools.cpptraj_rmsf.CpptrajRmsf.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Slice class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -164,8 +165,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(PurePath(self.instructions_file).parent)
])
self.remove_tmp_files()

Expand All @@ -174,7 +175,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_slice(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: dict = None, **kwargs) -> int:
def cpptraj_slice(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajSlice <ambertools.cpptraj_slice.CpptrajSlice>` class and
execute the :meth:`launch() <ambertools.cpptraj_slice.CpptrajSlice.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Snapshot class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -158,8 +159,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(PurePath(self.instructions_file).parent)
])
self.remove_tmp_files()

Expand All @@ -168,7 +169,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_snapshot(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: dict = None, **kwargs) -> int:
def cpptraj_snapshot(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajSnapshot <ambertools.cpptraj_snapshot.CpptrajSnapshot>` class and
execute the :meth:`launch() <ambertools.cpptraj_snapshot.CpptrajSnapshot.launch>` method."""

Expand Down
7 changes: 4 additions & 3 deletions biobb_analysis/ambertools/cpptraj_strip.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Module containing the Cpptraj Strip class and the command line interface."""
import argparse
from typing import Optional
from pathlib import PurePath
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -169,8 +170,8 @@ def launch(self) -> int:

# remove temporary folder(s)
self.tmp_files.extend([
self.stage_io_dict.get("unique_dir"),
PurePath(self.instructions_file).parent
self.stage_io_dict.get("unique_dir", ""),
str(PurePath(self.instructions_file).parent)
])
self.remove_tmp_files()

Expand All @@ -179,7 +180,7 @@ def launch(self) -> int:
return self.return_code


def cpptraj_strip(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: dict = None, **kwargs) -> int:
def cpptraj_strip(input_top_path: str, input_traj_path: str, output_cpptraj_path: str, properties: Optional[dict] = None, **kwargs) -> int:
"""Execute the :class:`CpptrajStrip <ambertools.cpptraj_strip.CpptrajStrip>` class and
execute the :meth:`launch() <ambertools.cpptraj_strip.CpptrajStrip.launch>` method."""

Expand Down
Loading

0 comments on commit 6135504

Please sign in to comment.