replication problem, example of kekulization
Closed this issue · 1 comments
A local installation of partialsmiles
encounters a problem if replicating the kekulization error (documentation).
observations:
Following your instruction how to install partialsmiles
, there was a small nuisance:
$ python3 -m pip install -U partialsmiles
Defaulting to user installation because normal site-packages is not writeable
Collecting partialsmiles
Using cached partialsmiles-1.0-py3-none-any.whl (13 kB)
Installing collected packages: partialsmiles
Successfully installed partialsmiles-1.0
$
$ python3
Python 3.9.11 (main, Mar 17 2022, 07:20:01)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import partialsmiles as ps
>>> ps.__version__
'1.0'
>>> mol = ps.ParseSmiles("CC(", partial=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/norwid/.local/lib/python3.9/site-packages/partialsmiles/smiparser.py", line 548, in ParseSmiles
mol = sp.parse(smi)
File "/home/norwid/.local/lib/python3.9/site-packages/partialsmiles/smiparser.py", line 174, in parse
self.handleError(SMILESSyntaxError, self.validateSyntax())
File "/home/norwid/.local/lib/python3.9/site-packages/partialsmiles/smiparser.py", line 191, in handleError
raise errtype(msg, self.smi, self.idx)
partialsmiles.exceptions.SMILESSyntaxError: 1 branch has not been closed
CC(
^
The two examples about syntax and valence errors were replicated successfully; reports are as documented by you. However, the check on kekulization is more verbose as if there is a problem using your code:
$ python3
Python 3.9.11 (main, Mar 17 2022, 07:20:01)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import sys
>>> import partialsmiles as ps
>>>
>>> try:
... ps.ParseSmiles("C(C)(C)(C)(C)C", partial=False)
... except ps.KekulizationError as e:
... print(repr(e), file=sys.stderr)
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/home/norwid/.local/lib/python3.9/site-packages/partialsmiles/smiparser.py", line 548, in ParseSmiles
mol = sp.parse(smi)
File "/home/norwid/.local/lib/python3.9/site-packages/partialsmiles/smiparser.py", line 181, in parse
self.handleError(ValenceError, self.validateValence())
File "/home/norwid/.local/lib/python3.9/site-packages/partialsmiles/smiparser.py", line 189, in handleError
raise errtype(msg[0], self.smi, msg[1])
partialsmiles.exceptions.ValenceError: Uncommon valence or charge state
C(C)(C)(C)(C)C
^
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
AttributeError: module 'partialsmiles' has no attribute 'KekulizationError'
>>>
Deinstallation of partialsmiles
from the user profile (which was successful) with pip
:
$ python3 -m pip uninstall partialsmiles
Found existing installation: partialsmiles 1.0
Uninstalling partialsmiles-1.0:
Would remove:
/home/norwid/.local/lib/python3.9/site-packages/partialsmiles-1.0.dist-info/*
/home/norwid/.local/lib/python3.9/site-packages/partialsmiles/*
Proceed (Y/n)? y
Successfully uninstalled partialsmiles-1.0
A subsequent installation with elevated permissions (sudo -H python3 -m pip install -U partialsmiles
, which as such was successful) is similar in the results to the above:
$ python3
Python 3.9.11 (main, Mar 17 2022, 07:20:01)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import sys
>>> import partialsmiles as ps
>>>
>>> try:
... ps.ParseSmiles("C(C)(C)(C)(C)C", partial=False)
... except ps.KekulizationError as e:
... print(repr(e), file=sys.stderr)
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/usr/local/lib/python3.9/dist-packages/partialsmiles/smiparser.py", line 548, in ParseSmiles
mol = sp.parse(smi)
File "/usr/local/lib/python3.9/dist-packages/partialsmiles/smiparser.py", line 181, in parse
self.handleError(ValenceError, self.validateValence())
File "/usr/local/lib/python3.9/dist-packages/partialsmiles/smiparser.py", line 189, in handleError
raise errtype(msg[0], self.smi, msg[1])
partialsmiles.exceptions.ValenceError: Uncommon valence or charge state
C(C)(C)(C)(C)C
^
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
AttributeError: module 'partialsmiles' has no attribute 'KekulizationError'
>>> exit()
(After this test, this sudo installation was uninstalled.)
questions:
- Are you able to replicate the observations made in an installation of Linux Debian 12/bookworm (branch testing)?
- Are there additional parameters to set/permissions to adjust which would allow running your code more smoothly?
The issue report is going to be closed after taking note that the installation and subsequent work depends on the environment at disposition. In an instance of Linux Xubuntu 20.04 LTS/focal (which never experienced the cohabitation of Python 2 and Python 3) with the installation via pip and consequently still deploying the old syntax of Kekulization failure instead of error:
xubuntu@xubuntu:~$ pip3 install -U partialsmiles
Collecting partialsmiles
Using cached partialsmiles-1.0-py3-none-any.whl (13 kB)
Installing collected packages: partialsmiles
Successfully installed partialsmiles-1.0
xubuntu@xubuntu:~$
xubuntu@xubuntu:~$ python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import partialsmiles as ps
>>> ps.__version__
'1.0'
>>>
>>> mol = ps.ParseSmiles("CC(", partial=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/xubuntu/.local/lib/python3.8/site-packages/partialsmiles/smiparser.py", line 548, in ParseSmiles
mol = sp.parse(smi)
File "/home/xubuntu/.local/lib/python3.8/site-packages/partialsmiles/smiparser.py", line 174, in parse
self.handleError(SMILESSyntaxError, self.validateSyntax())
File "/home/xubuntu/.local/lib/python3.8/site-packages/partialsmiles/smiparser.py", line 191, in handleError
raise errtype(msg, self.smi, self.idx)
partialsmiles.exceptions.SMILESSyntaxError: 1 branch has not been closed
CC(
^
>>> import sys
>>> import partialsmiles as ps
>>>
>>> try:
... ps.ParseSmiles("c1cc[nH]cc1", partial=False)
... except ps.KekulizationFailure as e:
... print(repr(e), file=sys.stderr)
...
KekulizationFailure('Aromatic system cannot be kekulized', 'c1cc[nH]cc1', 3)
>>>