Skip to content

Commit

Permalink
New: Get reactions/products from SMILES
Browse files Browse the repository at this point in the history
  • Loading branch information
avcopan committed Jul 11, 2024
1 parent 906bf4f commit 35c7a68
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions automol/smiles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from automol.smiles.base._core import reaction_product
from automol.smiles.base._core import reaction_reactants
from automol.smiles.base._core import reaction_products
from automol.smiles.base._core import reaction_reactants_and_products
# # properties
from automol.smiles.base._core import parse_connected_molecule_properties
# L4
Expand Down Expand Up @@ -53,6 +54,7 @@
'reaction_product',
'reaction_reactants',
'reaction_products',
'reaction_reactants_and_products',
# # properties
'parse_connected_molecule_properties',
# L4
Expand Down
2 changes: 2 additions & 0 deletions automol/smiles/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from automol.smiles.base._core import reaction_product
from automol.smiles.base._core import reaction_reactants
from automol.smiles.base._core import reaction_products
from automol.smiles.base._core import reaction_reactants_and_products
# # properties
from automol.smiles.base._core import parse_connected_molecule_properties

Expand All @@ -33,6 +34,7 @@
'reaction_product',
'reaction_reactants',
'reaction_products',
'reaction_reactants_and_products',
# # properties
'parse_connected_molecule_properties',
]
12 changes: 12 additions & 0 deletions automol/smiles/base/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ def reaction_products(smi: str) -> List[str]:
return None if rsmi is None else rsmi.split('.')


def reaction_reactants_and_products(smi: str) -> tuple[list[str], list[str]]:
""" Get the reactants and products from a reaction SMILES string
Multiple reactants will be returned as one combined SMILES string
Returns `None` if it isn't a reaction
:param smi: A reaction SMILES string
:returns: The SMILES strings for the reactants and products
"""
return reaction_reactants(smi), reaction_products(smi)


# # properties
def parse_connected_molecule_properties(smi):
""" Parse all properties from a SMILES string
Expand Down

0 comments on commit 35c7a68

Please sign in to comment.