Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Babel Error for two-character elements #1536

Closed
yohsama opened this issue Mar 7, 2022 · 2 comments · Fixed by #1537
Closed

Open Babel Error for two-character elements #1536

yohsama opened this issue Mar 7, 2022 · 2 comments · Fixed by #1537
Assignees
Labels
bug Something isn't working released

Comments

@yohsama
Copy link
Contributor

yohsama commented Mar 7, 2022

==============================
*** Open Babel Error  in ParseSimple
  SMILES string contains a character 'l' which is invalid
==============================

The problem is shown in handling isomer contains chlorine.
it seems the Cl will be replaced as [C]l. I changed the priority in regular matching, make two character elements get match first and it works. Hope it helps.

smi="[H]c(Cl)C([H])Cl"
print(R.atomname)
elements = "|".join([((an.upper() + "|" + an.lower()) if len(an)==1 else an) for an in R.atomname if an != 'H'])
print(elements)
resmi=re.sub(r'(?<!\[)(' + elements + r')(?!H)', r'[\1]', smi)
print(resmi)
Satom=sorted(R.atomname,key = lambda i:len(i),reverse=True)
elements = "|".join([((an.upper() + "|" + an.lower()) if len(an)==1 else an) for an in Satom if an != 'H'])
print(elements)
resmi=re.sub(r'(?<!\[)(' + elements + r')(?!H)', r'[\1]', smi)
print(resmi)
['C' 'Cl' 'H']
C|c|Cl
[H][c]([C]l)[C]([H])[C]l
['Cl', 'C', 'H']
Cl|C|c
[H][c]([Cl])[C]([H])[Cl]
@njzjz njzjz self-assigned this Mar 7, 2022
@njzjz njzjz added the bug Something isn't working label Mar 7, 2022
@njzjz
Copy link
Member

njzjz commented Mar 8, 2022

@yohsama I made a pull request in #1537. Could you review it?

@njzjz
Copy link
Member

njzjz commented Apr 14, 2022

🎉 This issue has been resolved in version 1.4.166 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@njzjz njzjz added the released label Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants