forked from enviPath/enviPy
[Fix] Catch invalid reactions smiles on reaction creation (#431)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#431
This commit is contained in:
@ -1918,6 +1918,21 @@ def package_reactions(request, package_uuid):
|
||||
reaction_name = request.POST.get("reaction-name")
|
||||
reaction_description = request.POST.get("reaction-description")
|
||||
reaction_smiles = request.POST.get("reaction-smiles")
|
||||
|
||||
if reaction_smiles is None or reaction_smiles.strip() == "":
|
||||
return error(
|
||||
request,
|
||||
"Reaction SMILES is empty / missing",
|
||||
"No reaction SMILES provided. Please provide a SMILES for the reaction.",
|
||||
)
|
||||
|
||||
if not FormatConverter.is_valid_smirks(reaction_smiles):
|
||||
return error(
|
||||
request,
|
||||
"Reaction SMILES is invalid",
|
||||
f"The provided reactions SMILES {reaction_smiles} is invalid",
|
||||
)
|
||||
|
||||
educts = reaction_smiles.split(">>")[0].split(".")
|
||||
products = reaction_smiles.split(">>")[1].split(".")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user