Skip to content

Commit

Permalink
Black + simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
FNTwin committed Feb 20, 2024
1 parent 0856c1c commit d22e587
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions safe/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]*)\)")
Expand Down
1 change: 1 addition & 0 deletions tests/test_safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit d22e587

Please sign in to comment.