Skip to content

Commit

Permalink
feat: Add RDKit 3D mol block #153
Browse files Browse the repository at this point in the history
  • Loading branch information
Kohulan committed May 17, 2023
1 parent 15406fd commit 0aa7836
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions app/routers/chem.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def chem_index():
@router.get("/stereoisomers")
async def SMILES_to_Stereo_Isomers(smiles: str):
"""
Enumerate all possible stereoisomers based on the chiral centers in the given SMILES:
Enumerate all possible stereoisomers based on the chiral centres in the given SMILES:
- **SMILES**: required (query parameter)
"""
Expand Down Expand Up @@ -119,7 +119,7 @@ async def NPlikeliness_Score(smiles: str):
@router.get("/classyfire/classify")
async def ClassyFire_Classify(smiles: str):
"""
Generate ClassyFire based classifications using SMILES as input.
Generate ClassyFire-based classifications using SMILES as input.
- **SMILES**: required (query)
"""
Expand All @@ -143,22 +143,43 @@ async def ClassyFire_result(id: str):
@router.get("/cdk2d")
async def CDK2D_Coordinates(smiles: str):
"""
Generate 2D Coordinates using CDK Strcture diagram generator and return the mol block.
Generate 2D Coordinates using the CDK Structure diagram generator and return the mol block.
- **SMILES**: required (query)
"""
if smiles:
mol = Chem.MolFromSmiles(smiles)
if mol:
return getCDKSDGMol(smiles)
return Response(
content=getCDKSDGMol(smiles).replace("$$$$\n", ""),
media_type="text/plain",
)
else:
return "Error reading SMILES string, check again."


@router.get("/rdkit3d")
async def RDKit3D_Mol(smiles: str):
"""
Generate 3D Coordinates using RDKit and return the mol block.
- **SMILES**: required (query)
"""
if smiles:
mol = Chem.MolFromSmiles(smiles)
if mol:
return Response(
content=get3Dconformers(smiles).replace("$$$$\n", ""),
media_type="text/plain",
)
else:
return "Error reading SMILES string, check again."


@router.get("/tanimoto")
async def Tanimoto_Similarity(smiles: str, toolkit: Optional[str] = "cdk"):
"""
Generate Tanimoto similarity index for a given pair of SMILES strings.
Generate the Tanimoto similarity index for a given pair of SMILES strings.
- **SMILES**: required (query)
- **toolkit**: optional (defaults: cdk)
Expand All @@ -172,15 +193,15 @@ async def Tanimoto_Similarity(smiles: str, toolkit: Optional[str] = "cdk"):
Tanimoto = getTanimotoSimilarityCDK(smiles1, smiles2)
return Tanimoto
except ValueError:
return 'Please give a SMILES pair with "," seperated. (Example: api.naturalproducts.net/chem/tanimoto?smiles=CN1C=NC2=C1C(=O)N(C(=O)N2C)C,CN1C=NC2=C1C(=O)NC(=O)N2C)'
return 'Please give a SMILES pair with "," separated. (Example: api.naturalproducts.net/chem/tanimoto?smiles=CN1C=NC2=C1C(=O)N(C(=O)N2C)C,CN1C=NC2=C1C(=O)NC(=O)N2C)'
elif len(smiles.split(",")) > 2:
try:
matrix = getTanimotoSimilarity(smiles, toolkit)
return Response(content=matrix, media_type="text/html")
except ValueError:
return 'Please give a SMILES pair with "," seperated. (Example: api.naturalproducts.net/chem/tanimoto?smiles=CN1C=NC2=C1C(=O)N(C(=O)N2C)C,CN1C=NC2=C1C(=O)NC(=O)N2C)'
return 'Please give a SMILES pair with "," separated. (Example: api.naturalproducts.net/chem/tanimoto?smiles=CN1C=NC2=C1C(=O)N(C(=O)N2C)C,CN1C=NC2=C1C(=O)NC(=O)N2C)'
else:
return 'Please give a SMILES pair with "," seperated. (Example: api.naturalproducts.net/chem/tanimoto?smiles=CN1C=NC2=C1C(=O)N(C(=O)N2C)C,CN1C=NC2=C1C(=O)NC(=O)N2C)'
return 'Please give a SMILES pair with "," separated. (Example: api.naturalproducts.net/chem/tanimoto?smiles=CN1C=NC2=C1C(=O)N(C(=O)N2C)C,CN1C=NC2=C1C(=O)NC(=O)N2C)'


@router.get("/depict")
Expand Down Expand Up @@ -218,7 +239,7 @@ async def Depict2D_molecule(
@router.get("/checkerrors")
async def Check_Errors(smiles: str, fix: Optional[bool] = False):
"""
Check issues for a given SMILES string and standardize it using ChEMBL curation pipeline.
Check issues for a given SMILES string and standardize it using the ChEMBL curation pipeline.
- **SMILES**: required (query)
- **fix**: optional (defaults: False)
Expand Down

0 comments on commit 0aa7836

Please sign in to comment.