Skip to content

Commit

Permalink
feat: added classyfire module
Browse files Browse the repository at this point in the history
  • Loading branch information
CS76 committed Mar 7, 2023
1 parent 52a1fed commit 76295c7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app/modules/classyfire.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import requests
import json

async def classify(smiles):
url = "http://classyfire.wishartlab.com/queries/?format=json"

payload = json.dumps({
"label": "curl_test",
"query_input": smiles,
"query_type": "STRUCTURE"
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
return response.json()


async def result(id):
url = "http://classyfire.wishartlab.com/queries/"+str(id)+"?format=json"

headers = {
'Content-Type': 'application/json'
}
response = requests.request("GET", url, headers=headers, data={})
return response.json()
14 changes: 14 additions & 0 deletions app/routers/chem.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from rdkit.Chem.rdMolDescriptors import Properties
from STOUT import translate_forward, translate_reverse
from app.modules.npscorer import getnp_score
from app.modules.classyfire import classify, result

router = APIRouter(
prefix="/chem",
Expand Down Expand Up @@ -120,6 +121,19 @@ async def nplikeliness_score(smiles: Optional[str]):
if smiles:
np_score = getnp_score(smiles)
return np_score


@router.get("/classyfire/{smiles}/classify")
async def classyfire_classify(smiles: Optional[str]):
if smiles:
data = await classify(smiles)
return data

@router.get("/classyfire/{id}/result")
async def classyfire_result(id: Optional[str]):
if id:
data = await result(id)
return data


# @app.get("/molecules/", response_model=List[schemas.Molecule])
Expand Down

0 comments on commit 76295c7

Please sign in to comment.