Skip to content

Commit

Permalink
adjust doc strings and add error message
Browse files Browse the repository at this point in the history
  • Loading branch information
fgrunewald committed Jul 9, 2024
1 parent 9c8e40d commit 18685d6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cgsmiles/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ def from_string(cls, cgsmiles_str, last_all_atom=True):
@classmethod
def from_graph(cls, cgsmiles_str, meta_graph, last_all_atom=True):
"""
Initiate a MoleculeResolver instance from a cgsmiles string.
Initiate a MoleculeResolver instance from a cgsmiles string
and a `meta_graph` that describes the lowest resolution.
Parameters
----------
Expand Down Expand Up @@ -423,7 +424,8 @@ def from_graph(cls, cgsmiles_str, meta_graph, last_all_atom=True):
@classmethod
def from_fragment_dicts(cls, cgsmiles_str, fragment_dicts, last_all_atom=True):
"""
Initiate a MoleculeResolver instance from a cgsmiles string.
Initiate a MoleculeResolver instance from a cgsmiles string, describing
one molecule and fragment_dicts containing fragments for each resolution.
Parameters
----------
Expand All @@ -441,6 +443,10 @@ def from_fragment_dicts(cls, cgsmiles_str, fragment_dicts, last_all_atom=True):
"""
# here we figure out how many resolutions we are dealing with
elements = re.findall(r"\{[^\}]+\}", cgsmiles_str)
if len(elements) > 1:
msg = ("Your cgsmiles string can only describe one "
"resolution of a molecule when using this function.")
raise IOError(msg)
# the first one describes our lowest resolution
molecule = read_cgsmiles(elements[0])
resolver_obj = cls(molecule_graph=molecule,
Expand Down

0 comments on commit 18685d6

Please sign in to comment.