Skip to content

Commit

Permalink
fix: removed exception for empty IAtomContainer - returning empty str…
Browse files Browse the repository at this point in the history
…ing for now (needs a more informative json response in future releases)
  • Loading branch information
CS76 committed Sep 11, 2023
1 parent 8025fff commit 85fb17f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions app/modules/tools/sugar_removal.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ def remove_linear_sugar(molecule: any) -> str:

if hasLinearSugar:
MoleculeWithoutSugars = SugarRemovalUtility.removeLinearSugars(molecule, True)
L_SMILES = SmilesGenerator.create(MoleculeWithoutSugars)
return str(L_SMILES)
if not MoleculeWithoutSugars.isEmpty():
L_SMILES = SmilesGenerator.create(MoleculeWithoutSugars)
return str(L_SMILES)
else:
return ""

Check warning on line 68 in app/modules/tools/sugar_removal.py

View check run for this annotation

Codecov / codecov/patch

app/modules/tools/sugar_removal.py#L68

Added line #L68 was not covered by tests
else:
return "No Linear sugar found"

Expand Down Expand Up @@ -94,8 +97,11 @@ def remove_circular_sugar(molecule: any) -> str:
if hasCircularSugar:
SugarRemovalUtility.setDetectCircularSugarsOnlyWithOGlycosidicBondSetting(True)
MoleculeWithoutSugars = SugarRemovalUtility.removeCircularSugars(molecule, True)
C_SMILES = SmilesGenerator.create(MoleculeWithoutSugars)
return str(C_SMILES)
if not MoleculeWithoutSugars.isEmpty():
C_SMILES = SmilesGenerator.create(MoleculeWithoutSugars)
return str(C_SMILES)
else:
return ""

Check warning on line 104 in app/modules/tools/sugar_removal.py

View check run for this annotation

Codecov / codecov/patch

app/modules/tools/sugar_removal.py#L104

Added line #L104 was not covered by tests
else:
return "No Circular sugars found"

Expand Down Expand Up @@ -129,15 +135,13 @@ def remove_linear_and_circular_sugar(molecule: any):
MoleculeWithoutSugars = SugarRemovalUtility.removeCircularAndLinearSugars(
molecule, True
)
if MoleculeWithoutSugars.isEmpty():
raise Exception(
"Molecule is empty after removal of circular and linear sugars"
)
else:
if not MoleculeWithoutSugars.isEmpty():
try:
S_SMILES = SmilesGenerator.create(MoleculeWithoutSugars)
return str(S_SMILES)
except Exception as e:
raise Exception(f"{str(e)}")
else:
return ""

Check warning on line 145 in app/modules/tools/sugar_removal.py

View check run for this annotation

Codecov / codecov/patch

app/modules/tools/sugar_removal.py#L145

Added line #L145 was not covered by tests
else:
return "No Linear or Circular sugars found"

0 comments on commit 85fb17f

Please sign in to comment.