Remove unused arguments, replace mutable defaults

Closes https://github.com/jensengroup/propka/issues/53
Closes https://github.com/jensengroup/propka/issues/56
This commit is contained in:
Thomas Holder
2023-12-21 22:42:51 +01:00
parent 9ea6d8815d
commit c8d93f6f01
4 changed files with 22 additions and 21 deletions

View File

@@ -202,7 +202,7 @@ def add_iterative_ion_pair(object1: "Iterative", object2: "Iterative",
object2.determinants['sidechain'].append(interaction) 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. """Add determinants iteratively.
The iterative pKa scheme. Later it is all added in 'calculateTotalPKA' The iterative pKa scheme. Later it is all added in 'calculateTotalPKA'

View File

@@ -8,10 +8,11 @@ Implements many of the main functions used to call PROPKA.
import logging import logging
import argparse import argparse
from pathlib import Path 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: if TYPE_CHECKING:
from propka.atom import Atom from propka.atom import Atom
from propka.conformation_container import ConformationContainer
T = TypeVar("T") T = TypeVar("T")
@@ -46,7 +47,8 @@ class Options:
window: Tuple[float, float, float] = (0.0, 14.0, 1.0) 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. """Check protein for correct number of atoms, etc.
Args: Args:
@@ -55,7 +57,7 @@ def protein_precheck(conformations, names):
for name in names: for name in names:
atoms = conformations[name].atoms atoms = conformations[name].atoms
# Group the atoms by their residue: # Group the atoms by their residue:
atoms_by_residue = {} atoms_by_residue: Dict[str, List[Atom]] = {}
for atom in atoms: for atom in atoms:
if atom.element != 'H': if atom.element != 'H':
res_id = resid_from_atom(atom) res_id = resid_from_atom(atom)

View File

@@ -195,7 +195,7 @@ class MolecularContainer:
stability_range = (min(stable_values), max(stable_values)) stability_range = (min(stable_values), max(stable_values))
return profile, opt, range_80pct, stability_range 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. """Get charge profile for conformation as function of pH.
Args: Args:
@@ -212,13 +212,13 @@ class MolecularContainer:
charge_profile.append([ph, q_unfolded, q_folded]) charge_profile.append([ph, q_unfolded, q_folded])
return charge_profile 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]: precision: float = 1e-4) -> Tuple[float, float]:
"""Get the isoelectric points for folded and unfolded states. """Get the isoelectric points for folded and unfolded states.
Args: Args:
conformation: conformation to test conformation: conformation to test
grid: grid of pH values [min, max, step] grid: pH window [min, max]
precision: Compute pI up to this precision precision: Compute pI up to this precision
Returns: Returns:
1. Folded state PI 1. Folded state PI

View File

@@ -14,7 +14,7 @@ from datetime import date
from decimal import Decimal from decimal import Decimal
from os import PathLike from os import PathLike
from pathlib import Path 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 import warnings
from .parameters import Parameters from .parameters import Parameters
@@ -75,22 +75,19 @@ def write_pdb_for_conformation(conformation: "ConformationContainer",
def write_pka(protein: "MolecularContainer", def write_pka(protein: "MolecularContainer",
parameters: Parameters, parameters: Parameters,
filename: Optional[_PathArg] = None, filename: Optional[_PathArg] = None,
conformation='1A', conformation: str = '1A',
reference="neutral", _="folding", verbose=False, reference: str = "neutral",
__=None): *,
verbose: bool = True):
"""Write the pKa-file based on the given protein. """Write the pKa-file based on the given protein.
Args: Args:
protein: protein object protein: protein object
filename: output file name filename: output file name
conformation: TODO - figure this out conformation: specific conformation
reference: reference state reference: reference state
_: "folding" or other
verbose: Boolean flag for verbosity verbose: Boolean flag for verbosity
__: options object
""" """
# TODO - the code immediately overrides the verbose argument; why?
verbose = True
if filename is None: if filename is None:
filename = "{0:s}.pka".format(protein.name) filename = "{0:s}.pka".format(protein.name)
if verbose: if verbose:
@@ -196,8 +193,11 @@ def get_summary_section(protein: "MolecularContainer", conformation: str,
def get_folding_profile_section( def get_folding_profile_section(
protein: "MolecularContainer", protein: "MolecularContainer",
conformation='AVR', direction="folding", reference="neutral", conformation: str = 'AVR',
window=[0., 14., 1.0], _=False, __=None): direction: str = "folding",
reference: str = "neutral",
window: Tuple[float, float, float] = (0., 14., 1.),
):
"""Returns string with the folding profile section of the results. """Returns string with the folding profile section of the results.
Args: Args:
@@ -206,8 +206,6 @@ def get_folding_profile_section(
direction: 'folding' or other direction: 'folding' or other
reference: reference state reference: reference state
window: pH window [min, max, step] window: pH window [min, max, step]
_: Boolean for verbose output
__: options object
Returns: Returns:
string string
""" """
@@ -253,7 +251,8 @@ def get_folding_profile_section(
return str_ 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. """Returns string with the charge profile section of the results.
Args: Args: