From 0b02c33e2f23158f1c04a184e8da6251da77c5b2 Mon Sep 17 00:00:00 2001 From: Kiyoon Kim Date: Mon, 16 Dec 2024 10:26:37 +0900 Subject: [PATCH 1/8] refactor: fix Residue -> DefinitionResidue --- pdb2pqr/aa.py | 106 +++++++++++++++++++++++------------------- pdb2pqr/structures.py | 20 ++++++-- setup.py | 7 +-- 3 files changed, 76 insertions(+), 57 deletions(-) diff --git a/pdb2pqr/aa.py b/pdb2pqr/aa.py index 82df94d9..810f3f80 100644 --- a/pdb2pqr/aa.py +++ b/pdb2pqr/aa.py @@ -6,12 +6,16 @@ .. codeauthor:: Nathan Baker """ +from __future__ import annotations + import logging from . import quatfit as quat from . import residue from . import structures as struct from . import utilities as util +from .definitions import DefinitionResidue +from .pdb import ATOM, HETATM _LOGGER = logging.getLogger(__name__) @@ -22,7 +26,7 @@ class Amino(residue.Residue): This class provides standard features of the amino acids. """ - def __init__(self, atoms, ref): + def __init__(self, atoms: list[ATOM | HETATM], ref: DefinitionResidue): """Initialize object. .. todo:: need to see whether :func:`super().__init__()` should be @@ -34,16 +38,16 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ sample_atom = atoms[-1] - self.atoms = [] + self.atoms: list[struct.Atom] = [] self.name = sample_atom.res_name self.chain_id = sample_atom.chain_id self.res_seq = sample_atom.res_seq self.ins_code = sample_atom.ins_code self.ffname = self.name - self.map = {} + self.map: dict[str, struct.Atom] = {} self.dihedrals = [] self.patches = [] self.peptide_c = None @@ -66,7 +70,11 @@ def __init__(self, atoms, ref): else: _LOGGER.debug(f"Ignoring atom {atom_.name}") - def create_atom(self, atomname, newcoords): + def create_atom( + self, + atomname: str, + newcoords: list[float] | tuple[float, float, float], + ): """Create an atom. .. todo:: Determine why this is different than superclass method. @@ -90,7 +98,7 @@ def create_atom(self, atomname, newcoords): newatom.added = 1 self.add_atom(newatom) - def add_atom(self, atom): + def add_atom(self, atom: struct.Atom): """Add atom to residue. Override the existing add_atom; include the link to the reference @@ -260,7 +268,7 @@ def rebuild_tetrahedral(self, atomname): class ALA(Amino): """Alanine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -269,7 +277,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -286,7 +294,7 @@ def letter_code(self) -> str: class ARG(Amino): """Arginine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -295,7 +303,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -318,7 +326,7 @@ def set_state(self): class ASN(Amino): """Asparagine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -327,7 +335,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -344,7 +352,7 @@ def letter_code(self): class ASP(Amino): """Aspartic acid class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -353,7 +361,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -376,7 +384,7 @@ def set_state(self): class CYS(Amino): """Cysteine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -385,7 +393,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -418,7 +426,7 @@ def set_state(self): class GLN(Amino): """Glutamine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -427,7 +435,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -444,7 +452,7 @@ def letter_code(self): class GLU(Amino): """Glutamic acid class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -453,7 +461,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -476,7 +484,7 @@ def set_state(self): class GLY(Amino): """Glycine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -485,7 +493,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -502,7 +510,7 @@ def letter_code(self): class HIS(Amino): """Histidine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -511,7 +519,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -574,7 +582,7 @@ def set_state(self): class ILE(Amino): """Isoleucine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -583,7 +591,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -600,7 +608,7 @@ def letter_code(self): class LEU(Amino): """Leucine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -609,7 +617,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -626,7 +634,7 @@ def letter_code(self): class LYS(Amino): """Lysine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -635,7 +643,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -658,7 +666,7 @@ def set_state(self): class MET(Amino): """Methionine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -667,7 +675,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -684,7 +692,7 @@ def letter_code(self): class PHE(Amino): """Phenylalanine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -693,7 +701,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -710,7 +718,7 @@ def letter_code(self): class PRO(Amino): """Proline class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -719,7 +727,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -749,7 +757,7 @@ def set_state(self): class SER(Amino): """Serine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -758,7 +766,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -775,7 +783,7 @@ def letter_code(self): class THR(Amino): """Threonine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -784,7 +792,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -801,7 +809,7 @@ def letter_code(self): class TRP(Amino): """Tryptophan class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -810,7 +818,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -827,7 +835,7 @@ def letter_code(self): class TYR(Amino): """Tyrosine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -836,7 +844,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -859,7 +867,7 @@ def set_state(self): class VAL(Amino): """Valine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -868,7 +876,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the amino acid. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ Amino.__init__(self, atoms, ref) self.reference = ref @@ -891,7 +899,7 @@ class WAT(residue.Residue): water_residue_names = ["HOH", "WAT"] - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize object. :param atoms: A list of :class:`Atom` objects to be stored in this @@ -900,7 +908,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the residue. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ sample_atom = atoms[-1] self.atoms = [] @@ -988,7 +996,7 @@ def __init__(self, atoms, ref): :param ref: The reference object for the residue. Used to convert from the alternate naming scheme to the main naming scheme. - :type ref: Residue + :type ref: DefinitionResidue """ sample_atom = atoms[-1] self.atoms = [] diff --git a/pdb2pqr/structures.py b/pdb2pqr/structures.py index a7bf94e4..c2d61024 100644 --- a/pdb2pqr/structures.py +++ b/pdb2pqr/structures.py @@ -8,8 +8,12 @@ """ # from . import pdb +from __future__ import annotations + +from typing_extensions import Self from .config import BACKBONE +from .pdb import ATOM, HETATM class Chain: @@ -19,7 +23,7 @@ class Chain: :class:`Biomolecule` object. """ - def __init__(self, chain_id): + def __init__(self, chain_id: str): """Initialize the class. :param chain_id: ID for this chain as denoted in the PDB @@ -74,7 +78,12 @@ class Atom: :class:`HETATM` objects into a single class. """ - def __init__(self, atom=None, type_="ATOM", residue=None): + def __init__( + self, + atom: ATOM | HETATM | Self | None = None, + type_="ATOM", + residue=None, + ): """Initialize the new Atom object by using the old object. :param atom: the original ATOM object (could be None) @@ -136,10 +145,11 @@ def __init__(self, atom=None, type_="ATOM", residue=None): self.element = atom.element self.charge = atom.charge self.residue = residue - try: - self.mol2charge = atom.mol2charge - except AttributeError: + if isinstance(atom, ATOM): + # ATOM class doesn't have mol2charge self.mol2charge = None + else: + self.mol2charge = atom.mol2charge @classmethod def from_pqr_line(cls, line): diff --git a/setup.py b/setup.py index 3fd2a693..a34da00b 100644 --- a/setup.py +++ b/setup.py @@ -25,8 +25,6 @@ to the biomedical community. """ -from sys import version_info - from setuptools import find_packages, setup # NOTE: The following reads the version number and makes @@ -36,7 +34,7 @@ with open("pdb2pqr/_version.py") as fobj: exec(fobj.read()) -with open("README.md", "r") as fobj: +with open("README.md") as fobj: LONG_DESCRIPTION = fobj.read() setup( @@ -57,6 +55,7 @@ "propka >= 3.5", "requests", "docutils < 0.18", + "typing-extensions", ], url="http://www.poissonboltzmann.org", packages=find_packages( @@ -94,6 +93,8 @@ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Scientific/Engineering :: Bio-Informatics", "Topic :: Scientific/Engineering :: Chemistry", ], From 162d4b6378f34e66c9f2b4afca9d5f9588bcf76b Mon Sep 17 00:00:00 2001 From: Kiyoon Kim Date: Mon, 16 Dec 2024 10:34:25 +0900 Subject: [PATCH 2/8] build: ruff ignore magic-value-comparison --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index ff710239..a67012c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,6 +94,7 @@ ignore = [ "UP017", # datetime.timezone.utc -> datetime.UTC "SIM108", # use ternary operator instead of if-else "TRY003", # long message in except + "PLW2004", # magic value comparison ] [tool.ruff.lint.per-file-ignores] From e5a91c08da445de637b96bf9f670ffaac3391ea5 Mon Sep 17 00:00:00 2001 From: Kiyoon Kim Date: Mon, 16 Dec 2024 10:39:59 +0900 Subject: [PATCH 3/8] build: ruff fix wrong setting --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a67012c4..10eb4b27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,7 +94,7 @@ ignore = [ "UP017", # datetime.timezone.utc -> datetime.UTC "SIM108", # use ternary operator instead of if-else "TRY003", # long message in except - "PLW2004", # magic value comparison + "PLR2004", # magic value comparison ] [tool.ruff.lint.per-file-ignores] From 27eb2a773df9f9904acf85f6e48bbe10bac44cf7 Mon Sep 17 00:00:00 2001 From: Kiyoon Kim Date: Mon, 16 Dec 2024 11:43:39 +0900 Subject: [PATCH 4/8] refactor: Residue -> DefinitionResidue in na.py --- pdb2pqr/na.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/pdb2pqr/na.py b/pdb2pqr/na.py index b01d7625..c3e95a82 100644 --- a/pdb2pqr/na.py +++ b/pdb2pqr/na.py @@ -6,24 +6,28 @@ .. codeauthor:: Nathan Baker """ +from __future__ import annotations + from . import residue from . import structures as struct +from .definitions import DefinitionResidue +from .pdb import ATOM, HETATM class Nucleic(residue.Residue): """This class provides standard features of the nucleic acids listed below.""" - def __init__(self, atoms, ref): + def __init__(self, atoms: list[ATOM | HETATM], ref: DefinitionResidue): sample_atom = atoms[-1] - self.atoms = [] + self.atoms: list[struct.Atom] = [] self.name = sample_atom.res_name self.chain_id = sample_atom.chain_id self.res_seq = sample_atom.res_seq self.ins_code = sample_atom.ins_code self.ffname = self.name - self.map = {} + self.map: dict[str, struct.Atom] = {} self.dihedrals = [] self.patches = [] self.is3term = 0 @@ -42,7 +46,11 @@ def __init__(self, atoms, ref): atom_ = struct.Atom(atom, "ATOM", self) self.add_atom(atom_) - def create_atom(self, atomname, newcoords): + def create_atom( + self, + atomname: str, + newcoords: list[float] | tuple[float, float, float], + ): """Create an atom. Overrides the generic residue's create_atom(). @@ -66,7 +74,7 @@ def create_atom(self, atomname, newcoords): newatom.added = 1 self.add_atom(newatom) - def add_atom(self, atom): + def add_atom(self, atom: struct.Atom): """Add existing atom to system. Override the existing add_atom - include the link to the reference @@ -109,7 +117,7 @@ def set_state(self): class ADE(Nucleic): """Adenosine class.""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize residue. :param atoms: add atoms to residue @@ -140,7 +148,7 @@ def set_state(self): class CYT(Nucleic): """Cytidine class""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize residue. :param atoms: add atoms to residue @@ -171,7 +179,7 @@ def set_state(self): class GUA(Nucleic): """Guanosine class""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize residue. :param atoms: add atoms to residue @@ -202,7 +210,7 @@ def set_state(self): class THY(Nucleic): """Thymine class""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize residue. :param atoms: add atoms to residue @@ -231,7 +239,7 @@ def set_state(self): class URA(Nucleic): """Uridine class""" - def __init__(self, atoms, ref): + def __init__(self, atoms, ref: DefinitionResidue): """Initialize residue. :param atoms: add atoms to residue From e2dc211b2b4dc27ea02ff27fe4f7b154cb562ddf Mon Sep 17 00:00:00 2001 From: Kiyoon Kim Date: Fri, 27 Dec 2024 08:48:06 +0900 Subject: [PATCH 5/8] chore: remove __future__ annotations --- pdb2pqr/aa.py | 2 -- pdb2pqr/main.py | 2 -- pdb2pqr/na.py | 2 -- pdb2pqr/residue.py | 2 -- pdb2pqr/structures.py | 3 --- 5 files changed, 11 deletions(-) diff --git a/pdb2pqr/aa.py b/pdb2pqr/aa.py index 810f3f80..569e8a92 100644 --- a/pdb2pqr/aa.py +++ b/pdb2pqr/aa.py @@ -6,8 +6,6 @@ .. codeauthor:: Nathan Baker """ -from __future__ import annotations - import logging from . import quatfit as quat diff --git a/pdb2pqr/main.py b/pdb2pqr/main.py index bc82bdc8..f2fc72ea 100644 --- a/pdb2pqr/main.py +++ b/pdb2pqr/main.py @@ -7,8 +7,6 @@ .. codeauthor:: Nathan Baker (et al.) """ -from __future__ import annotations - import argparse import logging import sys diff --git a/pdb2pqr/na.py b/pdb2pqr/na.py index c3e95a82..c2ad4782 100644 --- a/pdb2pqr/na.py +++ b/pdb2pqr/na.py @@ -6,8 +6,6 @@ .. codeauthor:: Nathan Baker """ -from __future__ import annotations - from . import residue from . import structures as struct from .definitions import DefinitionResidue diff --git a/pdb2pqr/residue.py b/pdb2pqr/residue.py index 54f7731f..743f7fd8 100644 --- a/pdb2pqr/residue.py +++ b/pdb2pqr/residue.py @@ -4,8 +4,6 @@ .. codeauthor:: Nathan Baker """ -from __future__ import annotations - import logging from . import pdb, structures diff --git a/pdb2pqr/structures.py b/pdb2pqr/structures.py index c2d61024..69615608 100644 --- a/pdb2pqr/structures.py +++ b/pdb2pqr/structures.py @@ -7,9 +7,6 @@ .. codeauthor:: Nathan Baker """ -# from . import pdb -from __future__ import annotations - from typing_extensions import Self from .config import BACKBONE From 94974337e889169a8dd759215e5e7aa211ab1e21 Mon Sep 17 00:00:00 2001 From: Kiyoon Kim Date: Fri, 27 Dec 2024 12:20:07 +0900 Subject: [PATCH 6/8] build: pyproject.toml --- pyproject.toml | 86 +++++++++++++++++++++++++++++++++++++ setup.cfg | 2 - setup.py | 114 ------------------------------------------------- 3 files changed, 86 insertions(+), 116 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml index 10eb4b27..a687bf35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,89 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.version] +source = "code" +path = "pdb2pqr/_version.py" +# expression = "__version__" # default + +[tool.hatch.build.targets.sdist] +include = [ + "pdb2pqr", + "docs", + "examples", + "tests", +] + +[tool.hatch.build.targets.wheel] +packages = ["pdb2pqr"] + +[project] +name = "pdb2pqr" +dynamic = ["version"] +description = """ +Automates many of the common tasks of preparing structures for \ +continuum solvation calculations as well as many other types of \ +biomolecular structure modeling, analysis, and simulation.""" +authors = [ + { name = "Jens Erik Nielsen" }, + { name = "Nathan Baker", email = "nathanandrewbaker@gmail.com" }, +] +readme = "README.md" +license = { file = "LICENSE.md" } +requires-python = ">=3.11,<4" +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Topic :: Scientific/Engineering :: Bio-Informatics", + "Topic :: Scientific/Engineering :: Chemistry", +] +keywords = ["science", "chemistry", "molecular biology"] + +dependencies = [ + "mmcif_pdbx>=1.1.2", + "numpy", + "propka >= 3.5", + "requests", + "docutils < 0.18", +] + +[project.optional-dependencies] +dev = ["check-manifest"] +test = [ + "ruff", + "coverage", + "pandas >= 1.0", + "pytest", + "testfixtures", +] + +[project.urls] +"Homepage" = "https://www.poissonboltzmann.org" +"Documentation"= "https://pdb2pqr.readthedocs.io/" +"Get help"= "https://github.com/Electrostatics/pdb2pqr/issues" +"Publications"= "https://pubmed.ncbi.nlm.nih.gov/?term=R01+GM069702" +"Funding"= "https://bit.ly/apbs-funding" +"Source"= "https://github.com/Electrostatics/pdb2pqr" + +[project.scripts] +pdb2pqr = "pdb2pqr.main:main" +pdb2pqr30 = "pdb2pqr.main:main" +dx2cube = "pdb2pqr.main:dx_to_cube" +inputgen = "pdb2pqr.inputgen:main" + + [tool.pytest.ini_options] testpaths = ["tests"] log_cli = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3c6e79cf..00000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal=1 diff --git a/setup.py b/setup.py deleted file mode 100644 index 637628bc..00000000 --- a/setup.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/python3 - -""" -The use of continuum solvation methods such as APBS requires accurate and -complete structural data as well as force field parameters such as atomic -charges and radii. Unfortunately, the limiting step in continuum electrostatics -calculations is often the addition of missing atomic coordinates to molecular -structures from the Protein Data Bank and the assignment of parameters to these -structures. To adds this problem, we have developed PDB2PQR. This software -automates many of the common tasks of preparing structures for continuum -solvation calculations as well as many other types of biomolecular structure -modeling, analysis, and simulation. These tasks include: - -* Adding a limited number of missing heavy (non-hydrogen) atoms to biomolecular - structures. -* Estimating titration states and protonating biomolecules in a manner - consistent with favorable hydrogen bonding. -* Assigning charge and radius parameters from a variety of force fields. -* Generating "PQR" output compatible with several popular computational - modeling and analysis packages. - -This service is intended to facilitate the setup and execution of -electrostatics calculations for both experts and non-experts and thereby -broaden the accessibility of biomolecular solvation and electrostatics analyses -to the biomedical community. -""" - -from setuptools import find_packages, setup - -# NOTE: The following reads the version number and makes -# if available to the packaging tools before installation. -# REF: https://stackoverflow.com/questions/458550/standard-way-to-embed-version-into-python-package # noqa: E501 -# This makes __version__ valid below -with open("pdb2pqr/_version.py") as fobj: - exec(fobj.read()) - -with open("README.md") as fobj: - LONG_DESCRIPTION = fobj.read() - -setup( - name="pdb2pqr", - version=__version__, # noqa: F821 - author="Jens Erik Nielsen, Nathan Baker, and many others.", - author_email="nathanandrewbaker@gmail.com", - description=( - "Automates many of the common tasks of preparing structures for " - "continuum solvation calculations as well as many other types of " - "biomolecular structure modeling, analysis, and simulation." - ), - long_description=LONG_DESCRIPTION, - long_description_content_type="text/markdown", - install_requires=[ - "mmcif_pdbx>=1.1.2", - "numpy", - "propka >= 3.5", - "requests", - "docutils < 0.18", - "typing-extensions", - ], - url="http://www.poissonboltzmann.org", - packages=find_packages( - exclude=["pdb2pka", "*.pdb2pka", "pdb2pka.*", "*.pdb2pka.*"] - ), - package_data={"pdb2pqr": ["dat/*.xml", "dat/*.DAT", "dat/*.names"]}, - python_requires=">=3.8", - extras_require={ - "dev": ["check-manifest"], - "test": [ - "ruff", - "coverage[toml]", - "pandas >= 1.0", - "pytest", - "testfixtures", - ], - }, - tests_require=[ - "pandas >= 1.0", - "pytest", - "testfixtures", - ], - test_suite="tests", - license="BSD", - classifiers=[ - "Development Status :: 4 - Beta", - "Environment :: Console", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: BSD License", - "Natural Language :: English", - "Operating System :: MacOS", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Topic :: Scientific/Engineering :: Bio-Informatics", - "Topic :: Scientific/Engineering :: Chemistry", - ], - project_urls={ - "Documentation": "https://pdb2pqr.readthedocs.io/", - "Get help": "https://github.com/Electrostatics/pdb2pqr/issues", - "Publications": "https://pubmed.ncbi.nlm.nih.gov/?term=R01+GM069702", - "Funding": "https://bit.ly/apbs-funding", - "Source": "https://github.com/Electrostatics/pdb2pqr", - }, - keywords="science chemistry molecular biology", - entry_points={ - "console_scripts": [ - "pdb2pqr=pdb2pqr.main:main", - "pdb2pqr30=pdb2pqr.main:main", - "dx2cube=pdb2pqr.main:dx_to_cube", - "inputgen=pdb2pqr.inputgen:main", - ] - }, -) From 2023a72829e1475d3e17671999263a3b3d96f923 Mon Sep 17 00:00:00 2001 From: Kiyoon Kim Date: Fri, 27 Dec 2024 12:20:31 +0900 Subject: [PATCH 7/8] chore: remove unnecessary lint (not active anyway) --- ruff_essential.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/ruff_essential.toml b/ruff_essential.toml index 8ffc4af1..e76e4ee5 100644 --- a/ruff_essential.toml +++ b/ruff_essential.toml @@ -7,5 +7,4 @@ select = [ "F63", "F7", "F82", - "FA102", # Python 3.10-style union typing is used so we need to import `from __future__ import annotations` ] From e2708a54715c336672403f8f6d15ef1a7651236a Mon Sep 17 00:00:00 2001 From: Kiyoon Kim Date: Fri, 27 Dec 2024 12:28:06 +0900 Subject: [PATCH 8/8] fix: python version in pyright --- pdb2pqr/structures.py | 2 +- pyproject.toml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pdb2pqr/structures.py b/pdb2pqr/structures.py index 69615608..4d21e749 100644 --- a/pdb2pqr/structures.py +++ b/pdb2pqr/structures.py @@ -7,7 +7,7 @@ .. codeauthor:: Nathan Baker """ -from typing_extensions import Self +from typing import Self from .config import BACKBONE from .pdb import ATOM, HETATM diff --git a/pyproject.toml b/pyproject.toml index a687bf35..d3f4f16a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ authors = [ ] readme = "README.md" license = { file = "LICENSE.md" } +# NOTE: make sure you change [tool.pyright] pythonVersion to match this requires-python = ">=3.11,<4" classifiers = [ "Development Status :: 4 - Beta", @@ -105,7 +106,7 @@ typeCheckingMode = "standard" useLibraryCodeForTypes = true autoImportCompletions = true -pythonVersion = "3.8" +pythonVersion = "3.11" # pythonPlatform = "Linux" reportDuplicateImport = true