From ea094d5a670063726dafc04aa200cefcf1eeb720 Mon Sep 17 00:00:00 2001 From: Jules Kreuer Date: Tue, 12 Mar 2024 15:39:49 +0100 Subject: [PATCH] improve docstrings --- src/blosum/__init__.py | 0 src/blosum/_blosum.py | 50 +++++++++++++++++++++++++----------------- src/blosum/_data.py | 0 3 files changed, 30 insertions(+), 20 deletions(-) mode change 100755 => 100644 src/blosum/__init__.py mode change 100755 => 100644 src/blosum/_blosum.py mode change 100755 => 100644 src/blosum/_data.py diff --git a/src/blosum/__init__.py b/src/blosum/__init__.py old mode 100755 new mode 100644 diff --git a/src/blosum/_blosum.py b/src/blosum/_blosum.py old mode 100755 new mode 100644 index 081d176..9fc4970 --- a/src/blosum/_blosum.py +++ b/src/blosum/_blosum.py @@ -19,19 +19,27 @@ def __init__(self, n: Union[int, str], default: float = float("-inf")): Object to easily access a blosum matrix. This reader supports asymetric data. - Input - ----- - Either n ϵ {45,50,62,80,90} or path - - n: int, which BLOSUM Matrix to use. - Choice between: 45,50,62,80 and 90 - Data gathered from https://www.ncbi.nlm.nih.gov/IEB/ToolBox/C_DOC/lxr/source/data/ - - path: string, path to a Blosum matrix. - File in a format like: - https://www.ncbi.nlm.nih.gov/IEB/ToolBox/C_DOC/lxr/source/data/BLOSUM62 - - default: float, default -inf + Parameters + ---------- + n: int or str + * If an integer (45, 50, 62, 80, or 90), selects the corresponding + standard BLOSUM matrix. + * If a string, provides a filepath to a custom BLOSUM matrix file. + default: float + The default value for missing entries in the matrix. + Defaults to -inf. + + Attributes + ---------- + n: int or str + The BLOSUM matrix identifier (version number or filepath). + default: float + The default value for missing entries. + + Examples + -------- + >>> blosum62 = BLOSUM(62) + >>> score = blosum62['W']['Y'] # Get the score for substituting W with Y """ self.n = n @@ -85,17 +93,19 @@ def loadMatrix( ) -> DefaultDict[str, DefaultDict[str, float]]: """ Reads a Blosum matrix from file. - File in a format like: - https://www.ncbi.nlm.nih.gov/IEB/ToolBox/C_DOC/lxr/source/data/BLOSUM62 + File in a format like: https://www.ncbi.nlm.nih.gov/IEB/ToolBox/C_DOC/lxr/source/data/BLOSUM62 - Input - ----- - path: str, path to a file. - default: float, default value "-inf" + Parameters + ---------- + path: str + Path to the file. + default: float + Default value "-inf". Returns ------- - blosumDict: Dictionary, The blosum dict + blosumDict: dict + The blosum dict. """ with open(path, "r") as f: diff --git a/src/blosum/_data.py b/src/blosum/_data.py old mode 100755 new mode 100644