Hi Anthony,

You're on the right track. "etab" is gone now, as you've found.
"ob.GetAtomicNum(element)" is the replacement you're looking for.

Looking through the code, I think it should work now. FYI, if you want to
use Python 3 instead of Python 2, you may also need to replace "f.next()"
with "next(f)".

Regards,
- Noel

On Fri, 19 Jun 2020 at 17:32, C Anthony Lewis <cale...@plymouth.ac.uk>
wrote:

> Dear Colleagues,
>
>
>
> I hope you are all safe and well at this extraordinary time.
>
>
>
> This is a follow-up to messages I sent to the list in late 2013 and early
> 2014 regarding an old DOS-based program 'SMOG' (see CCL archives
> http://www.ccl.net/cca/software/MS-DOS/SMOG/index.shtml and
> http://pubs.acs.org/doi/abs/10.1021/ci950393z) that generates isomers
> given a molecular formula and a set of structural constraints. Although the
> output is in the form of a connection table it was not understood by other
> applications I was aware of and I thought OpenBabel might work. However, at
> the time this was not an option and Noel kindly provided me with a Python
> script (smog.py – attached as a txt file) that took the SMOG output and
> generated SMILES. I believe there was an intention to include this in
> future versions of Open Babel but I appreciate there are many calls on time
> and I don’t think this has yet happened.
>
>
>
> Fast forwarding seven years or so, during which my attention was taken by
> other duties, I have now returned to working on the additional SMOG output
> I have available and I naively thought I would be able to install current
> versions of Open Babel and Python, fire up the script and everything would
> work as before. Unfortunately, things didn’t go quite to plan and the
> following is what happened.
>
>
>
> I Installed Anaconda Powershell and OpenBabel 3.0.0 and, I think, the
> bindings ('pip install -U openbabel') correctly.
>
>
>
> I ran through the commands given in the ‘Test the installation’ box on
> https://open-babel.readthedocs.io/en/latest/UseTheLibrary/PythonInstall.html
> and obtained a structure in a separate window so it seemed that things were
> working okay. I then ran smog.py as attached and got the following:
>
>
>
> (base) PS C:\users\anthony\anaconda2> python smog.py myfile.res
> myoutputfile.smi
>
> Traceback (most recent call last):
>
>   File "smog.py", line 5, in <module>
>
>     import pybel
>
> ImportError: No module named pybel
>
>
>
> Having looked at
> https://open-babel.readthedocs.io/en/latest/UseTheLibrary/PythonInstall.html
> again and also the ‘Updating to Open Babel 3.0 from 2.x’ page (
> https://open-babel.readthedocs.io/en/latest/UseTheLibrary/migration.html),
> I changed line 5 in smog.py from ‘import pybel’ to ‘from openbabel import
> pybel’ and ran smog.py again with the following result:
>
>
>
> (base) PS C:\users\anthony\anaconda2> python smog.py myfile.res
> myoutputfile.smi
>
> Traceback (most recent call last):
>
>   File "smog.py", line 60, in <module>
>
>     for mol in readSMOG(options['inputfile']):
>
>   File "smog.py", line 41, in readSMOG
>
>     yield smog2mol(lines)
>
>   File "smog.py", line 16, in smog2mol
>
>     atm.SetAtomicNum(ob.cvar.etab.GetAtomicNum(element))
>
> AttributeError: Unknown C global variable 'etab'
>
>
>
> At this point I am well beyond my capabilities but I assume there have
> been changes since version 2.x'ish that I used in the past and the global
> variable 'etab' and is absent. I did find 'etab' defined on line 468 at
> https://github.com/openbabel/documentation/blob/master/pybel.py (dated 14
> Oct 2012) but I don't know what to do with this information!
>
>
>
> I guess this is a similar issue to one posted to the list at the end of
> May and I'm hoping that someone can provide some assistance and, if it's
> possible, show me how I can get the smog.py working again. Maybe this is my
> chance to learn Python after all the times I’ve said I would…
>
>
>
> My apologies for the lengthy post and many thanks for any assistance
> received,
>
>
>
> Anthony
>
>
>
>
>
>
>
> C. Anthony Lewis
>
> Petroleum & Environmental Geochemistry Group & Centre for Chemical
> Sciences,
>
> School of Geography, Earth and Environmental Sciences,
>
> Plymouth University,
>
> Plymouth, Devon PL4 8AA, U.K.
>
>
>
> tel: +44 (0)1752 584554
>
> email: cale...@plymouth.ac.uk
>
> web: http://www.pegg.org.uk
>
> http://www.plymouth.ac.uk/chemistry
>
>
> ------------------------------
> <http://www.plymouth.ac.uk/worldclass>
>
> This email and any files with it are confidential and intended solely for
> the use of the recipient to whom it is addressed. If you are not the
> intended recipient then copying, distribution or other use of the
> information contained is strictly prohibited and you should not rely on it.
> If you have received this email in error please let the sender know
> immediately and delete it from your system(s). Internet emails are not
> necessarily secure. While we take every care, University of Plymouth
> accepts no responsibility for viruses and it is your responsibility to scan
> emails and their attachments. University of Plymouth does not accept
> responsibility for any changes made after it was sent. Nothing in this
> email or its attachments constitutes an order for goods or services unless
> accompanied by an official order form.
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to