Skip to content

Commit

Permalink
fix: flake8 linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Kohulan committed Mar 10, 2023
1 parent 0767d0c commit 63d03b7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseSettings, Field, PostgresDsn
from pydantic import BaseSettings, Field


class Settings(BaseSettings):
Expand Down
3 changes: 2 additions & 1 deletion app/database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .config import settings
import psycopg2
import sys
from .config import settings


class Database:
Expand Down
3 changes: 2 additions & 1 deletion app/modules/depict.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def getRDKitDepiction(smiles, molSize=(512, 512), rotate=0, kekulize=True):
if kekulize:
try:
Chem.Kekulize(mc)
except:
except Exception as e:
print(e, flush=True)
mc = Chem.Mol(mol.ToBinary())
if not mc.GetNumConformers():
rdDepictor.Compute2DCoords(mc)
Expand Down
8 changes: 4 additions & 4 deletions app/modules/descriptor_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def checkRo5Violations(mol):
"""
num_of_violations = 0
if Descriptors.MolLogP(mol) > 5:
rule_break += 1
num_of_violations += 1
if Descriptors.MolWt(mol) > 500:
rule_break += 1
num_of_violations += 1
if Lipinski.NumHAcceptors(mol) > 10:
rule_break += 1
num_of_violations += 1
if Lipinski.NumHDonors(mol) > 5:
rule_break += 1
num_of_violations += 1
return num_of_violations


Expand Down
8 changes: 2 additions & 6 deletions app/modules/npscorer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# calculation of natural product-likeness as described in:
#
# Natural Product-likeness Score and Its Application for Prioritization of Compound Libraries
# Natural Product-likeness Score and Its Application for
# Prioritization of Compound Libraries
# Peter Ertl, Silvio Roggo, and Ansgar Schuffenhauer
# Journal of Chemical Information and Modeling, 48, 68-74 (2008)
# http://pubs.acs.org/doi/abs/10.1021/ci700286x
Expand Down Expand Up @@ -32,11 +33,6 @@
fscore = pickle.load(gzip.open(model_path))


def getnp_model(model_path):
fscore = pickle.load(gzip.open(model_path.as_posix()))
return fscore


def getnp_model(model_path):
fscore = pickle.load(gzip.open(model_path.as_posix()))
return fscore
Expand Down
11 changes: 8 additions & 3 deletions app/routers/chem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Optional
from rdkit import Chem
import urllib.request

# from ..database import db
# from fastapi_pagination import Page, add_pagination, paginate
from rdkit.Chem.EnumerateStereoisomers import (
Expand Down Expand Up @@ -110,7 +111,7 @@ async def smiles_iupac(smiles: Optional[str]):


@router.post("/iupac/smiles")
async def standardise_mol(request: Request):
async def iupac_smiles(request: Request):
body = await request.json()
query = body["query"]
if query:
Expand Down Expand Up @@ -163,7 +164,8 @@ async def depick_molecule(
content=getRDKitDepiction(smiles, [width, height], rotate),
media_type="image/svg+xml",
)



@router.post("/process")
async def extract_chemicalinfo(request: Request):
body = await request.json()
Expand All @@ -174,7 +176,10 @@ async def extract_chemicalinfo(request: Request):
urllib.request.urlretrieve(image_path, filename)
smiles = predict_SMILES(filename)
os.remove(filename)
return JSONResponse(content={ "reference" : reference, "smiles": smiles.split(".")})
return JSONResponse(
content={"reference": reference, "smiles": smiles.split(".")}
)


# @app.get("/molecules/", response_model=List[schemas.Molecule])
# def read_molecules(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
Expand Down

0 comments on commit 63d03b7

Please sign in to comment.