Skip to content

Commit

Permalink
Merge pull request #187 from speleo3/remove-unused
Browse files Browse the repository at this point in the history
Remove unused code
  • Loading branch information
speleo3 authored Feb 19, 2024
2 parents 6ee0df8 + 25ed65e commit 27e0ad2
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 418 deletions.
11 changes: 11 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
Changelog
*********

Upcoming release (TBD)
======================

Changes
-------

* Removed the following unused command line options: ``-t``, ``--thermophile``,
``-a``, ``--alignment``, ``-m``, ``--mutation``, ``--mutator``,
``--mutator-option``
* Removed several unused API functions

Current
=======

Expand Down
29 changes: 2 additions & 27 deletions docs/source/command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ PROPKA predicts the pKa values of ionizable groups in proteins and
protein-ligand complexes based in the 3D structure. The
:program:`propka3` command has the following options::
propka3 [-h] [-f FILENAMES] [-r REFERENCE] [-c CHAINS] [-i TITRATE_ONLY] [-t THERMOPHILES] [-a ALIGNMENT] [-m MUTATIONS]
propka3 [-h] [-f FILENAMES] [-r REFERENCE] [-c CHAINS] [-i TITRATE_ONLY]
[-v VERSION_LABEL] [-p PARAMETERS] [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-o PH] [-w WINDOW WINDOW WINDOW]
[-g GRID GRID GRID] [--mutator MUTATOR] [--mutator-option MUTATOR_OPTIONS] [-d] [-l] [-k] [-q] [--protonate-all]
[-g GRID GRID GRID] [-d] [-l] [-k] [-q] [--protonate-all]
input_pdb


Expand Down Expand Up @@ -47,21 +47,6 @@ protein-ligand complexes based in the 3D structure. The
should be a comma-separated list of "chain:resnum"
values; for example: ``-i "A:10,A:11"`` (default: None)

.. option:: -t THERMOPHILES, --thermophile THERMOPHILES

defining a thermophile filename; usually used in
'alignment-mutations' (default: None)

.. option:: -a ALIGNMENT, --alignment ALIGNMENT

alignment file connecting <filename> and <thermophile>
[<thermophile>.pir] (default: None)

.. option:: -m MUTATIONS, --mutation MUTATIONS

specifying mutation labels which is used to modify
<filename> according to, e.g. N25R/N181D (default: None)

.. option:: --version

show program's version number and exit
Expand Down Expand Up @@ -90,16 +75,6 @@ protein-ligand complexes based in the 3D structure. The
setting the pH-grid to calculate e.g. stability related
properties (default: (0.0, 14.0, 0.1))

.. option:: --mutator MUTATOR

setting approach for mutating <filename>
[alignment/scwrl/jackal] (default: None)

.. option:: --mutator-option MUTATOR_OPTIONS

setting property for mutator [e.g. type="side-chain"]
(default: None)

.. option:: -d, --display-coupled-residues

Displays alternative pKa values due to coupling of
Expand Down
54 changes: 1 addition & 53 deletions propka/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"""

import string
from typing import cast, List, NoReturn, Optional, TYPE_CHECKING
import warnings
from typing import List, Optional, TYPE_CHECKING

from propka.lib import make_tidy_atom_label
from . import hybrid36
Expand Down Expand Up @@ -46,7 +45,6 @@ class Atom:
group: Optional["Group"] = None
group_type: Optional[str] = None
cysteine_bridge: bool = False
residue: NoReturn = None # type: ignore[assignment]
conformation_container: Optional["ConformationContainer"] = None
molecular_container: Optional["MolecularContainer"] = None
is_protonated: bool = False
Expand Down Expand Up @@ -87,7 +85,6 @@ def __init__(self, line: Optional[str] = None):
Args:
line: Line from a PDB file to set properties of atom.
"""
self.number_of_bonded_elements: NoReturn = cast(NoReturn, {}) # FIXME unused?
self.bonded_atoms: List[Atom] = []
self.set_properties(line)
fmt = "{r.name:3s}{r.res_num:>4d}{r.chain_id:>2s}"
Expand Down Expand Up @@ -302,45 +299,6 @@ def make_mol2_line(self, id_):
atom_label=make_tidy_atom_label(self.name, self.element))
return str_

def make_pdb_line2(self, numb=None, name=None, res_name=None, chain_id=None,
res_num=None, x=None, y=None, z=None, occ=None,
beta=None):
"""Create a PDB line.
TODO - this could/should be a @property method/attribute
TODO - figure out difference between make_pdb_line, and make_pdb_line2
Returns:
String with PDB line.
"""
warnings.warn("only used by unused function")
if numb is None:
numb = self.numb
if name is None:
name = self.name
if res_name is None:
res_name = self.res_name
if chain_id is None:
chain_id = self.chain_id
if res_num is None:
res_num = self.res_num
if x is None:
x = self.x
if y is None:
y = self.y
if z is None:
z = self.z
if occ is None:
occ = self.occ
if beta is None:
beta = self.beta
str_ = PDB_LINE_FMT2.format(
numb=numb, res_name=res_name, chain_id=chain_id, res_num=res_num,
x=x, y=y, z=z, occ=occ, beta=beta,
atom_label=make_tidy_atom_label(name, self.element)
)
return str_

def get_tidy_label(self):
"""Returns a 'tidier' atom label for printing the new pdbfile
Expand All @@ -353,13 +311,3 @@ def get_tidy_label(self):
def __str__(self):
"""Return an undefined-format string version of this atom."""
return STR_FMT.format(r=self)

def set_residue(self, residue: NoReturn):
""" Makes a reference to the parent residue
Args:
residue: the parent residue
"""
raise NotImplementedError("unused")
if self.residue is None:
self.residue = residue
88 changes: 0 additions & 88 deletions propka/bonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,63 +87,6 @@ def __init__(self):
self.backbone_atoms = list(self.intra_residue_backbone_bonds.keys())
self.terminal_oxygen_names = ['OXT', 'O\'\'']

def find_bonds_for_protein(self, protein):
"""Bonds proteins based on the way atoms normally bond.
Args:
protein: the protein to search for bonds
"""
raise NotImplementedError("unused")
_LOGGER.info('++++ Side chains ++++')
# side chains
for chain in protein.chains:
for residue in chain.residues:
if residue.res_name.replace(' ', '') not in ['N+', 'C-']:
self.find_bonds_for_side_chain(residue.atoms)
_LOGGER.info('++++ Backbones ++++')
# backbone
last_residues = []
for chain in protein.chains:
for i in range(1, len(chain.residues)):
if (chain.residues[i-1].res_name.replace(' ', '')
not in ['N+', 'C-']):
if (chain.residues[i].res_name.replace(' ', '')
not in ['N+', 'C-']):
self.connect_backbone(chain.residues[i-1],
chain.residues[i])
last_residues.append(chain.residues[i])
_LOGGER.info('++++ terminal oxygen ++++')
# terminal OXT
for last_residue in last_residues:
self.find_bonds_for_terminal_oxygen(last_residue)
_LOGGER.info('++++ cysteines ++++')
# Cysteines
for chain in protein.chains:
for i in range(0, len(chain.residues)):
if chain.residues[i].res_name == 'CYS':
for j in range(0, len(chain.residues)):
if chain.residues[j].res_name == 'CYS' and j != i:
self.check_for_cysteine_bonds(chain.residues[i],
chain.residues[j])

def check_for_cysteine_bonds(self, cys1, cys2):
"""Looks for potential bonds between two cysteines.
Args:
cys1: one of the cysteines to check
cys1: one of the cysteines to check
"""
raise NotImplementedError("unused")
for atom1 in cys1.atoms:
if atom1.name == 'SG':
for atom2 in cys2.atoms:
if atom2.name == 'SG':
dist = propka.calculations.squared_distance(atom1,
atom2)
# TODO - is SS_dist_squared an attribute of this class?
if dist < self.SS_dist_squared:
self.make_bond(atom1, atom2)

def find_bonds_for_terminal_oxygen(self, residue):
"""Look for bonds for terminal oxygen.
Expand Down Expand Up @@ -423,34 +366,3 @@ def make_bond(atom1, atom2):
atom2.bonded_atoms.append(atom1)
if atom2 not in atom1.bonded_atoms:
atom1.bonded_atoms.append(atom2)

def generate_protein_bond_dictionary(self, atoms):
"""Generate dictionary of protein bonds.
Args:
atoms: list of atoms for bonding
"""
for atom in atoms:
for bonded_atom in atom.bonded_atoms:
resi_i = atom.res_name
name_i = atom.name
resi_j = bonded_atom.res_name
name_j = bonded_atom.name
if name_i not in (
self.backbone_atoms
or name_j not in self.backbone_atoms):
if name_i not in (
self.terminal_oxygen_names
and name_j not in self.terminal_oxygen_names):
if resi_i not in list(self.protein_bonds.keys()):
self.protein_bonds[resi_i] = {}
if name_i not in self.protein_bonds[resi_i]:
self.protein_bonds[resi_i][name_i] = []
if name_j not in self.protein_bonds[resi_i][name_i]:
self.protein_bonds[resi_i][name_i].append(name_j)
if resi_j not in list(self.protein_bonds.keys()):
self.protein_bonds[resi_j] = {}
if name_j not in self.protein_bonds[resi_j]:
self.protein_bonds[resi_j][name_j] = []
if name_i not in self.protein_bonds[resi_j][name_j]:
self.protein_bonds[resi_j][name_j].append(name_i)
14 changes: 1 addition & 13 deletions propka/conformation_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
import logging
import functools
from typing import Callable, Dict, Iterable, Iterator, List, NoReturn, Optional, TYPE_CHECKING, Set
from typing import Callable, Dict, Iterable, Iterator, List, Optional, TYPE_CHECKING, Set

from propka.lib import Options
from propka.version import Version
Expand Down Expand Up @@ -497,18 +497,6 @@ def get_ions(self):
group for group in self.groups
if group.residue_type in self.parameters.ions.keys()]

def get_group_names(self, group_list: NoReturn) -> NoReturn: # FIXME unused?
"""Get names of groups in list.
Args:
group_list: list to check
Returns:
list of groups
"""
if TYPE_CHECKING:
assert False
return [group for group in self.groups if group.type in group_list]

def get_ligand_atoms(self) -> List["Atom"]:
"""Get atoms associated with ligands.
Expand Down
44 changes: 1 addition & 43 deletions propka/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""
import logging
import math
from typing import cast, Dict, Iterable, List, NoReturn, Optional
from typing import Dict, List, Optional

import propka.ligand
from propka.parameters import Parameters
Expand Down Expand Up @@ -119,8 +119,6 @@ def __init__(self, atom: Atom):
fmt = "{type:<3s}{name:>4s}{chain:>2s}"
self.label = fmt.format(
type=self.residue_type, name=atom.name, chain=atom.chain_id)
# container for squared distances
self.squared_distances: NoReturn = cast(NoReturn, {}) # FIXME unused?

def couple_covalently(self, other: "Group") -> None:
"""Couple this group with another group.
Expand Down Expand Up @@ -162,46 +160,6 @@ def get_non_covalently_coupled_groups(self):
"""
return self.non_covalently_coupled_groups

def share_determinants(self, others: Iterable["Group"]) -> None:
"""Share determinants between this group and others.
Args:
others: list of other groups
"""
raise NotImplementedError("unused")
# for each determinant type
for other in others:
if other == self:
the_other = other
continue
for type_ in ['sidechain', 'backbone', 'coulomb']:
for det in other.determinants[type_]:
self.share_determinant(det, type_)
# recalculate pka values
self.calculate_total_pka()
the_other.calculate_total_pka()

def share_determinant(self, new_determinant: Determinant, type_: str) -> None:
"""Add determinant to this group's list of determinants.
Args:
new_determinant: determinant to add
type_: type of determinant
"""
added = False
# first check if we already have a determinant with this label
for own_determinant in self.determinants[type_]:
if own_determinant.group == new_determinant.group:
# if so, find the average value
avr = 0.5*(own_determinant.value + new_determinant.value)
own_determinant.value = avr
new_determinant.value = avr
added = True
# otherwise we just add the determinant to our list
if not added:
self.determinants[type_].append(
Determinant(new_determinant.group, new_determinant.value))

def __eq__(self, other):
"""Needed for creating sets of groups."""
if self.atom.type == 'atom':
Expand Down
2 changes: 1 addition & 1 deletion propka/iterative.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Loading

0 comments on commit 27e0ad2

Please sign in to comment.