Skip to content

Commit

Permalink
fix: format doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Kohulan committed Jan 17, 2024
1 parent 2029334 commit f47dc80
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 65 deletions.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ repos:
- id: check-yaml
- id: debug-statements
- id: requirements-txt-fixer
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: v0.7.3
hooks:
- id: pydocstringformatter
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
Expand Down
3 changes: 2 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ async def root():
)
def get_health() -> HealthCheck:
"""
## Perform a Health Check
## Perform a Health Check.
Endpoint to perform a health check on. This endpoint can primarily be used by Docker
to ensure a robust container orchestration and management are in place. Other
services that rely on the proper functioning of the API service will not deploy if this
Expand Down
2 changes: 2 additions & 0 deletions app/modules/all_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
def get_all_rdkit_descriptors(molecule: any) -> Union[tuple, str]:
"""
Calculate a selected set of molecular descriptors using RDKit.
This function takes an input SMILES string and calculates various molecular descriptors
using RDKit.
Expand Down Expand Up @@ -80,6 +81,7 @@ def get_all_rdkit_descriptors(molecule: any) -> Union[tuple, str]:
def get_all_cdk_descriptors(molecule: any) -> Union[tuple, str]:
"""
Calculate a set of molecular descriptors using the CDK.
This function takes a SMILES string as input and calculates various molecular descriptors
using the CDK. The calculated descriptors are returned as a tuple.
Expand Down
3 changes: 2 additions & 1 deletion app/modules/classyfire.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

async def classify(smiles: str) -> dict:
"""
This function queries the ClassyFire API to classify a chemical compound
This function queries the ClassyFire API to classify a chemical compound.
represented by a SMILES string.
Args:
Expand Down
4 changes: 0 additions & 4 deletions app/modules/coconut/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def get_mol_block(input_text: str) -> str:
Raises:
ValueError: If input_text is not a valid Mol or SMILES.
"""
check = rdkitmodules.is_valid_molecule(input_text)

Expand All @@ -47,7 +46,6 @@ def get_molecule_hash(molecule: any) -> dict:
Returns:
dict: Dictionary containing Formula, Isomeric SMILES, and Canonical SMILES.
"""
if molecule:
Formula = Chem.rdMolDescriptors.CalcMolFormula(molecule)
Expand Down Expand Up @@ -75,7 +73,6 @@ def get_representations(molecule: any) -> dict:
Returns:
dict: Dictionary containing InChI, InChi Key, and Murko framework.
"""
if molecule:
InChI = Chem.inchi.MolToInchi(molecule)
Expand All @@ -96,7 +93,6 @@ def get_COCONUT_preprocessing(input_text: str) -> dict:
Returns:
dict: COCONUT preprocessed data.
"""
original_mol = get_mol_block(input_text)
standarised_mol_block = standardizer.standardize_molblock(original_mol)
Expand Down
3 changes: 2 additions & 1 deletion app/modules/depiction.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def get_cdk_depiction(
unicolor=False,
):
"""
This function takes the user input SMILES and Depicts it
This function takes the user input SMILES and Depicts it.
using the CDK Depiction Generator.
Args:
Expand Down
11 changes: 7 additions & 4 deletions app/modules/toolkits/cdk_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def get_CDK_IAtomContainer(smiles: str):

def get_CDK_SDG(molecule: any):
"""
This function takes the input IAtomContainer and Creates a
This function takes the input IAtomContainer and Creates a.
Structure Diagram Layout using the CDK.
Args:
Expand Down Expand Up @@ -125,7 +126,8 @@ def get_CDK_SDG_mol(molecule: any, V3000=False) -> str:

def get_murko_framework(molecule: any) -> str:
"""
This function takes the user input SMILES and returns
This function takes the user input SMILES and returns.
the Murko framework
Args:
Expand Down Expand Up @@ -198,7 +200,8 @@ def get_vander_waals_volume(molecule: any) -> float:

def get_CDK_descriptors(molecule: any) -> Union[tuple, str]:
"""
Take an input SMILES and generate a selected set of molecular
Take an input SMILES and generate a selected set of molecular.
descriptors generated using CDK as a list.
Args (str):
Expand Down Expand Up @@ -366,6 +369,7 @@ def get_tanimoto_similarity_PubChem_CDK(mol1: any, mol2: any) -> str:
def get_tanimoto_similarity_ECFP_CDK(mol1: any, mol2: any, ECFP: int = 2) -> str:
"""
Calculate the Tanimoto similarity index between two molecules using CircularFingerprinter fingerprints.
https://cdk.github.io/cdk/2.8/docs/api/org/openscience/cdk/fingerprint/CircularFingerprinter.html
Args:
Expand Down Expand Up @@ -447,7 +451,6 @@ def get_cip_annotation(molecule: any) -> str:
Returns:
str: A CIP annotated molecule block.
"""
SDGMol = get_CDK_SDG(molecule)
centres_base = "com.simolecule.centres"
Expand Down
4 changes: 3 additions & 1 deletion app/modules/toolkits/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def parse_input(input: str, framework: str = "rdkit", standardize: bool = False)

def parse_SMILES(smiles: str, framework: str = "rdkit", standardize: bool = False):
"""
Check whether the input SMILES string is valid. If not, attempt to standardize
Check whether the input SMILES string is valid.
If not, attempt to standardize
the molecule using the ChEMBL standardization pipeline.
Args:
Expand Down
11 changes: 5 additions & 6 deletions app/modules/toolkits/rdkit_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def get_3d_conformers(molecule: any, depict=True) -> Chem.Mol:
Returns:
str or rdkit.Chem.rdchem.Mol: If `depict` is True, returns the 3D structure in MolBlock format.
Otherwise, returns an RDKit Mol object.
"""
if molecule:
molecule = Chem.AddHs(molecule)
Expand Down Expand Up @@ -192,6 +191,7 @@ def get_tanimoto_similarity_rdkit(
async def get_rdkit_HOSE_codes(molecule: any, noOfSpheres: int) -> List[str]:
"""
Calculate and retrieve RDKit HOSE codes for a given SMILES string.
This function takes a SMILES string as input and returns the calculated HOSE codes.
Args:
Expand Down Expand Up @@ -361,7 +361,8 @@ def get_sas_score(molecule: any) -> float:

def get_PAINS(molecule: any) -> Union[bool, Tuple[str, str]]:
"""
Check if a molecule contains a PAINS (Pan Assay INterference compoundS)
Check if a molecule contains a PAINS (Pan Assay INterference compoundS).
substructure.
Parameters:
Expand Down Expand Up @@ -481,7 +482,6 @@ def get_REOSFilter(molecule: any) -> bool:
Returns:
bool: True if the molecule passes the REOS filter, False otherwise.
"""
MW = Descriptors.ExactMolWt(molecule)
logP = Descriptors.MolLogP(molecule)
Expand Down Expand Up @@ -523,7 +523,6 @@ def get_RuleofThree(molecule: any) -> bool:
Returns:
bool: True if the molecule meets the Rule of Three criteria, False otherwise.
"""
MW = Descriptors.ExactMolWt(molecule)
logP = Descriptors.MolLogP(molecule)
Expand All @@ -539,7 +538,8 @@ def get_RuleofThree(molecule: any) -> bool:

def get_ertl_functional_groups(molecule: any) -> list:
"""
This function takes an organic molecule as input and uses the algorithm proposed by Peter Ertl to
This function takes an organic molecule as input and uses the algorithm proposed by Peter Ertl to.
identify functional groups within the molecule. The identification is based on the analysis of
chemical fragments present in the molecular structure.
Expand All @@ -556,7 +556,6 @@ def get_ertl_functional_groups(molecule: any) -> list:
If no functional groups are found, the function returns a list with a single element:
[{'None': 'No fragments found'}]
"""
if molecule:
fragments = ifg.identify_functional_groups(molecule)
Expand Down
8 changes: 5 additions & 3 deletions app/modules/tools/sugar_removal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
def get_sugar_info(molecule: any) -> tuple:
"""
Analyzes a molecule represented by a SMILES string to determine if it contains sugars.
This function utilizes the Sugar Removal Utility to check for the presence of circular or linear sugars.
Args:
Expand Down Expand Up @@ -36,7 +37,8 @@ def get_sugar_info(molecule: any) -> tuple:

def remove_linear_sugar(molecule: any) -> str:
"""
Detects and removes linear sugars from a given SMILES string using the CDK-based
Detects and removes linear sugars from a given SMILES string using the CDK-based.
sugar removal utility.
Args:
Expand Down Expand Up @@ -119,14 +121,14 @@ def remove_circular_sugar(molecule: any) -> str:


def remove_linear_and_circular_sugar(molecule: any):
"""This fucntion detects and removes linear and circular sugars from a give
"""This fucntion detects and removes linear and circular sugars from a give.
SMILES string. Uses the CDK based sugar removal utility.
Args:
molecule (IAtomContainer): CDK molecule object.
Returns:
smiles (str): SMILES string without linear and circular sugars.
"""
cdk_base = "org.openscience.cdk"
SCOB = cdk.JClass(cdk_base + ".silent.SilentChemObjectBuilder")
Expand Down
1 change: 0 additions & 1 deletion app/modules/tools/surge.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def get_heavy_atom_count(formula: str) -> int:
Returns:
count (int): The number of heavy atoms in the molecule.
"""

elements = re.findall(r"[A-Z][a-z]*\d*", formula)
Expand Down
22 changes: 7 additions & 15 deletions app/routers/chem.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
)
def get_health() -> HealthCheck:
"""
## Perform a Health Check
## Perform a Health Check.
Endpoint to perform a health check on. This endpoint can primarily be used by Docker
to ensure a robust container orchestration and management are in place. Other
services that rely on the proper functioning of the API service will not deploy if this
Expand Down Expand Up @@ -131,7 +132,7 @@ async def get_stereoisomers(
),
):
"""
For a given SMILES string this function enumerates all possible stereoisomers
For a given SMILES string this function enumerates all possible stereoisomers.
Parameters:
- **SMILES**: required (query parameter): The SMILES string to be enumerated.
Expand All @@ -141,7 +142,6 @@ async def get_stereoisomers(
Raises:
- ValueError: If the SMILES string is not provided or is invalid.
"""
mol = parse_input(smiles, "rdkit", False)
if mol:
Expand Down Expand Up @@ -205,7 +205,6 @@ async def get_descriptors(
Raises:
- None
"""
data = get_COCONUT_descriptors(smiles, toolkit)
if format == "html":
Expand Down Expand Up @@ -293,7 +292,6 @@ async def get_multiple_descriptors(
- Request: GET /descriptors/multiple?smiles=CCC
Response: "Error invalid SMILES"
"""
molecules = [m.strip() for m in smiles.split(",")]

Expand Down Expand Up @@ -376,7 +374,6 @@ async def hose_codes(
Raises:
- ValueError: If the SMILES string is not provided or is invalid.
"""
if toolkit == "cdk":
mol = parse_input(smiles, "cdk", False)
Expand Down Expand Up @@ -428,7 +425,8 @@ async def standardize_mol(
],
):
"""
Standardize molblock using the ChEMBL curation pipeline
Standardize molblock using the ChEMBL curation pipeline.
and return the standardized molecule, SMILES, InChI, and InCHI-Key.
Parameters:
Expand All @@ -443,7 +441,6 @@ async def standardize_mol(
Raises:
- ValueError: If the SMILES string is not provided or is invalid.
"""
try:
if data:
Expand Down Expand Up @@ -534,7 +531,6 @@ async def check_errors(
Notes:
- If the SMILES string contains spaces, they will be replaced with "+" characters before processing.
- If the SMILES string cannot be read, the function returns the string "Error reading SMILES string, check again."
"""
mol = Chem.MolFromSmiles(smiles, sanitize=False)
if mol:
Expand Down Expand Up @@ -609,7 +605,6 @@ async def np_likeness_score(
Raises:
- ValueError: If the SMILES string is not provided or is invalid.
"""
mol = parse_input(smiles, "rdkit", False)
try:
Expand Down Expand Up @@ -777,7 +772,6 @@ async def coconut_preprocessing(
Raises:
- HTTPException: If there is an error reading the SMILES string.
"""
try:
data = get_COCONUT_preprocessing(smiles)
Expand Down Expand Up @@ -839,7 +833,6 @@ async def classyfire_classify(
Note:
- ClassyFire is a chemical taxonomy classification tool that predicts the chemical class and subclass of a compound based on its structural features.
- This service pings the http://classyfire.wishartlab.com server for information retrieval.
"""
mol = parse_input(smiles, "rdkit", False)
if mol:
Expand All @@ -864,6 +857,7 @@ async def classyfire_classify(
async def classyfire_result(jobid: str):
"""
Retrieve the ClassyFire classification results based on the provided Job ID.
To obtain the results from ClassyFire, please initiate a new request and obtain a unique job ID.
Once you have the job ID, you need to submit another request using this ID in order to retrieve the desired outcome.
Expand All @@ -876,7 +870,6 @@ async def classyfire_result(jobid: str):
Returns:
- The ClassyFire classification results as JSON.
"""

if jobid:
Expand Down Expand Up @@ -1076,7 +1069,7 @@ async def get_functional_groups(
),
):
"""
For a given SMILES string this function generates a list of identified functional groups
For a given SMILES string this function generates a list of identified functional groups.
Parameters:
- **SMILES**: required (query parameter): The SMILES string to be checked for functional groups.
Expand All @@ -1086,7 +1079,6 @@ async def get_functional_groups(
Raises:
- ValueError: If the SMILES string is not provided or is invalid.
"""
mol = parse_input(smiles, "rdkit", False)
if mol:
Expand Down
Loading

0 comments on commit f47dc80

Please sign in to comment.