From d22e587be2518358619ebf02394f79e4d415c8a0 Mon Sep 17 00:00:00 2001 From: FNTwin Date: Tue, 20 Feb 2024 11:12:52 -0700 Subject: [PATCH] Black + simple test --- safe/converter.py | 8 ++++++-- tests/test_safe.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/safe/converter.py b/safe/converter.py index 61ee7a9..7bd0ee0 100644 --- a/safe/converter.py +++ b/safe/converter.py @@ -333,8 +333,12 @@ def encoder( # we cannot have anything of the form "\([@=-#-$/\]*\d+\)" attach_regexp = re.compile(r"(" + re.escape(attach) + r")") # check if we have at least 2 matches, if not, we have a dummy - n_matches= len(attach_regexp.findall(scaffold_str)) - scaffold_str = attach_regexp.sub(val, scaffold_str) if n_matches > 1 else scaffold_str.replace(attach, "*") + n_matches = len(attach_regexp.findall(scaffold_str)) + scaffold_str = ( + attach_regexp.sub(val, scaffold_str) + if n_matches > 1 + else scaffold_str.replace(attach, "*") + ) starting_num += 1 # now we need to remove all the parenthesis around digit only number wrong_attach = re.compile(r"\(([\%\d]*)\)") diff --git a/tests/test_safe.py b/tests/test_safe.py index fdfc288..b266249 100644 --- a/tests/test_safe.py +++ b/tests/test_safe.py @@ -85,6 +85,7 @@ def test_rdkit_smiles_parser_issues(): "c1cc2c(cc1[C@@H]1CCC[NH2+]1)OCCO2", "[13C]1CCCCC1C[238U]C[NH3+]", "COC[CH2:1][CH2:2]O[CH:2]C[OH:3]", + "C1*CCC1COO", ], ) def test_bracket_smiles_issues(input_sm):