-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
134 additions
and
32 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
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,54 @@ | ||
from modal import Image | ||
|
||
is_patented_image = Image.debian_slim(python_version=3.12).pip_install( | ||
["molbloom", "loguru"] | ||
) | ||
|
||
with is_patented_image.imports(): | ||
import molbloom | ||
from loguru import logger | ||
|
||
|
||
def _is_patented(smiles: str) -> bool: | ||
""" | ||
Check if a molecule is patented using Molbloom | ||
Args: | ||
smiles (str): SMILES string of the molecule | ||
Returns: | ||
str: "Patented" if the molecule is patented, "Novel" otherwise | ||
Raises: | ||
ValueError: If an error occurs while checking if the molecule is patented | ||
""" | ||
logger.debug(f"Checking if {smiles} is patented") | ||
try: | ||
r = molbloom.buy(smiles, canonicalize=True, catalog="surechembl") | ||
except Exception as e: | ||
raise ValueError(f"Error while checking if {smiles} is patented: {e}") | ||
if r: | ||
return True | ||
else: | ||
return False | ||
|
||
|
||
def _is_buyable(smiles: str) -> bool: | ||
""" | ||
Check if a molecule is buyable using Molbloom | ||
Args: | ||
smiles (str): SMILES string of the molecule | ||
Returns: | ||
str: "Buyable" if the molecule is buyable, "Not buyable" otherwise | ||
""" | ||
logger.debug(f"Checking if {smiles} is buyable") | ||
try: | ||
r = molbloom.buy(smiles, canonicalize=True) | ||
except Exception as e: | ||
raise ValueError(f"Error while checking if {smiles} is buyable: {e}") | ||
if r: | ||
return True | ||
else: | ||
return False |