From c8d93f6f01042b13a924ec24115784f8db454dc6 Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Thu, 21 Dec 2023 22:42:51 +0100 Subject: [PATCH] Remove unused arguments, replace mutable defaults Closes https://github.com/jensengroup/propka/issues/53 Closes https://github.com/jensengroup/propka/issues/56 --- propka/iterative.py | 2 +- propka/lib.py | 8 +++++--- propka/molecular_container.py | 6 +++--- propka/output.py | 27 +++++++++++++-------------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/propka/iterative.py b/propka/iterative.py index 2ada994..fc32995 100644 --- a/propka/iterative.py +++ b/propka/iterative.py @@ -202,7 +202,7 @@ def add_iterative_ion_pair(object1: "Iterative", object2: "Iterative", object2.determinants['sidechain'].append(interaction) -def add_determinants(iterative_interactions: List[Interaction], version: Version, _=None): +def add_determinants(iterative_interactions: List[Interaction], version: Version): """Add determinants iteratively. The iterative pKa scheme. Later it is all added in 'calculateTotalPKA' diff --git a/propka/lib.py b/propka/lib.py index 65a4ee3..e2d6b07 100644 --- a/propka/lib.py +++ b/propka/lib.py @@ -8,10 +8,11 @@ Implements many of the main functions used to call PROPKA. import logging import argparse from pathlib import Path -from typing import Iterable, Iterator, List, TYPE_CHECKING, NoReturn, Optional, Tuple, TypeVar +from typing import Dict, Iterable, Iterator, List, TYPE_CHECKING, NoReturn, Optional, Tuple, TypeVar if TYPE_CHECKING: from propka.atom import Atom + from propka.conformation_container import ConformationContainer T = TypeVar("T") @@ -46,7 +47,8 @@ class Options: window: Tuple[float, float, float] = (0.0, 14.0, 1.0) -def protein_precheck(conformations, names): +def protein_precheck(conformations: Dict[str, "ConformationContainer"], + names: Iterable[str]): """Check protein for correct number of atoms, etc. Args: @@ -55,7 +57,7 @@ def protein_precheck(conformations, names): for name in names: atoms = conformations[name].atoms # Group the atoms by their residue: - atoms_by_residue = {} + atoms_by_residue: Dict[str, List[Atom]] = {} for atom in atoms: if atom.element != 'H': res_id = resid_from_atom(atom) diff --git a/propka/molecular_container.py b/propka/molecular_container.py index 394ae6f..7be3251 100644 --- a/propka/molecular_container.py +++ b/propka/molecular_container.py @@ -195,7 +195,7 @@ class MolecularContainer: stability_range = (min(stable_values), max(stable_values)) return profile, opt, range_80pct, stability_range - def get_charge_profile(self, conformation: str = 'AVR', grid=[0., 14., .1]): + def get_charge_profile(self, conformation: str = 'AVR', grid=(0., 14., .1)): """Get charge profile for conformation as function of pH. Args: @@ -212,13 +212,13 @@ class MolecularContainer: charge_profile.append([ph, q_unfolded, q_folded]) return charge_profile - def get_pi(self, conformation: str = 'AVR', grid=[0., 14., 1], *, + def get_pi(self, conformation: str = 'AVR', grid=(0., 14.), *, precision: float = 1e-4) -> Tuple[float, float]: """Get the isoelectric points for folded and unfolded states. Args: conformation: conformation to test - grid: grid of pH values [min, max, step] + grid: pH window [min, max] precision: Compute pI up to this precision Returns: 1. Folded state PI diff --git a/propka/output.py b/propka/output.py index d124e6e..48fdac8 100644 --- a/propka/output.py +++ b/propka/output.py @@ -14,7 +14,7 @@ from datetime import date from decimal import Decimal from os import PathLike from pathlib import Path -from typing import IO, AnyStr, List, Optional, Union, TYPE_CHECKING +from typing import IO, AnyStr, List, Optional, Tuple, Union, TYPE_CHECKING import warnings from .parameters import Parameters @@ -75,22 +75,19 @@ def write_pdb_for_conformation(conformation: "ConformationContainer", def write_pka(protein: "MolecularContainer", parameters: Parameters, filename: Optional[_PathArg] = None, - conformation='1A', - reference="neutral", _="folding", verbose=False, - __=None): + conformation: str = '1A', + reference: str = "neutral", + *, + verbose: bool = True): """Write the pKa-file based on the given protein. Args: protein: protein object filename: output file name - conformation: TODO - figure this out + conformation: specific conformation reference: reference state - _: "folding" or other verbose: Boolean flag for verbosity - __: options object """ - # TODO - the code immediately overrides the verbose argument; why? - verbose = True if filename is None: filename = "{0:s}.pka".format(protein.name) if verbose: @@ -196,8 +193,11 @@ def get_summary_section(protein: "MolecularContainer", conformation: str, def get_folding_profile_section( protein: "MolecularContainer", - conformation='AVR', direction="folding", reference="neutral", - window=[0., 14., 1.0], _=False, __=None): + conformation: str = 'AVR', + direction: str = "folding", + reference: str = "neutral", + window: Tuple[float, float, float] = (0., 14., 1.), +): """Returns string with the folding profile section of the results. Args: @@ -206,8 +206,6 @@ def get_folding_profile_section( direction: 'folding' or other reference: reference state window: pH window [min, max, step] - _: Boolean for verbose output - __: options object Returns: string """ @@ -253,7 +251,8 @@ def get_folding_profile_section( return str_ -def get_charge_profile_section(protein, conformation='AVR', _=None): +def get_charge_profile_section(protein: "MolecularContainer", + conformation: str = 'AVR'): """Returns string with the charge profile section of the results. Args: