-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented surge - structure generator
- Loading branch information
Showing
4 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from subprocess import Popen, PIPE | ||
|
||
|
||
def generateStructures(mf: str): | ||
"""This function uses the sugar removal utility and checks | ||
whether a molecule has ring or linear sugars | ||
Args: | ||
smiles (string): SMILES string given by the user. | ||
Returns: | ||
(boolean): True or false values whtehr or not molecule has sugar. | ||
""" | ||
smiles = [] | ||
process = Popen( | ||
["surge", "-P", "-T", "-B1,2,3,4,5,7,9", "-t0", "-f0", "-S", mf], | ||
stdout=PIPE, | ||
stderr=PIPE, | ||
) | ||
for line in iter(process.stdout.readline, b""): | ||
smiles.append(line.decode("utf-8").rstrip()) | ||
return smiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from fastapi import APIRouter | ||
from app.modules.tools.surge import generateStructures | ||
|
||
router = APIRouter( | ||
prefix="/tools", | ||
tags=["tools"], | ||
dependencies=[], | ||
responses={404: {"description": "Not found"}}, | ||
) | ||
|
||
|
||
@router.get("/") | ||
async def tools_index(): | ||
return {"module": "tools", "message": "Successful", "status": 200} | ||
|
||
|
||
@router.get("/generate-structures") | ||
async def Generate_Structures(molecular_formula: str): | ||
""" | ||
Extract chemical structure depictions and convert them into SMILES using DECIMER: | ||
- **Images**: required (query) | ||
""" | ||
return generateStructures(molecular_formula) |