Skip to main content

python3 version of mol2chemfig

Project description

mol2chemfigPy3

Current version 1.5.2 (transferred from mol2chemfig v1.5).

This is NOT an official version of mol2chemfig for python 3.

There are always too few free tools for chemistry, while mol2chemfig is a good one of them. But it was written in python2. Nowadays, who are still using py2? LOL

Simply applying 2to3 to it doesn't work, alas.

mol2chemfigPy3 is a simple translation from py2 to py3 based on old mol2chemfig version 1.5 (the python codes are the same as 1.4🤔 mol2chemfig (uwaterloo.ca)).

Install

build from source

this requires setuptools and wheel installed

  • first cd to where setup.py locates

    $ cd <path>
    
  • then run

    $ pip install .
    

If you prefer installing from wheel, you can download here.

install from PyPi

Downloads

$ pip install -U mol2chemfigPy3

Usage

Use in command line

Attention: to render the colours on Windows platform, run it in modern terminals, e.g. Windows Terminal.

Run, for example:

$ mol2chemfig -zw -i direct "C1=CC=C(C=C1)O"

it will give you \chemfig{OH-[:180,,1]=_[:240]-[:180]=_[:120]-[:60]=_(-[:300])}

Run, for another example:

$ mol2chemfig -zw -i direct "C1=CC=C(C=C1)O" > phenol-smi-terse.tex

it will write result to file phenol-smi-terse.tex

Run, for again another example:

$ mol2chemfig -zw -i pubchem 99

it will give you

\chemfig{O=[:137.9]P(-[:47.9]O-[:107.9,0.62]H)(-[:137.9]O-[:197.9,0.62]H)%
-[:227.9]O-[:287.9](-[:44.9,0.62]H)-[:233.9](-[:179.9]O-[:119.9,0.62]H)(%
-[:116.9,0.62]H)-[:305.9](-[:251.9]N-[:197.8,0.994]=^[:150]N-[:210](%
-[:150,0.62]H)=^[:270]N-[:330](=^[:30](-[:90])-[:342.1,0.994]N%
=^[:54.1,0.994](-[,0.62]H)-[:126,0.994]\phantom{N})-[:270]N(-[:330,0.62]H)%
-[:210,0.62]H)(-[:314.9,0.62]H)-[:17.9]O-[:89.9](-[:161.9])(-[:332.9,0.62]H%
)-[:35.9](-[:55.9,0.62]H)(-[:135.9,0.62]H)-[:335.9]O-[:35.9]P(-[:305.9]O%
-[:245.9,0.62]H)(=[:125.9]O)-[:35.9]O-[:335.9]P(-[:65.9]O-[:125.9,0.62]H)(%
=[:245.9]O)-[:335.9]O-[:35.9](-[:55.9,0.62]H)(-[:135.9,0.62]H)-[:335.9](%
-[:65.9](-[:65.9,0.62]H)(-[:155.9,0.62]H)-[:335.9,0.62]H)(-[:245.9](%
-[:245.9,0.62]H)(-[:335.9,0.62]H)-[:155.9,0.62]H)-[:335.9](-[:275.9]O%
-[:335.9,0.62]H)(-[:215.9,0.62]H)-[:35.9](=[:95.9]O)-[:335.9]N(%
-[:275.9,0.62]H)-[:35.9](-[:55.9,0.62]H)(-[:135.9,0.62]H)-[:335.9](%
-[:235.9,0.62]H)(-[:315.9,0.62]H)-[:35.9](=[:95.9]O)-[:335.9]N(%
-[:275.9,0.62]H)-[:35.9](-[:55.9,0.62]H)(-[:135.9,0.62]H)-[:335.9](%
-[:235.9,0.62]H)(-[:315.9,0.62]H)-[:35.9]S-[:335.9](=[:275.9]O)-[:35.9](%
-[:95.9,0.62]H)=[:335.9](-[:35.9](-[:35.9,0.62]H)(-[:125.9,0.62]H)%
-[:305.9,0.62]H)-[:275.9](-[:185.9,0.62]H)(-[:275.9,0.62]H)-[:5.9,0.62]H}

(it's Coenzyme A, S-(3-methyl-2-butenoate) by the way 😜)

Use as a python package (new add in to this python 3 version)

This is not included in the old Py2 version of mol2chemfig.

mol2chemfigPy3.mol2chemfig(content: str, *args: str, rotate: float = 0.0, aromatic: bool = True, marker: Optional[str] = None, name: Optional[str] = None, relative_angle: bool = False, show_carbon: bool = False, show_methyl: bool = False, inline: bool = False)

e. g.

from mol2chemfigPy3 import mol2chemfig

mol2chemfig('996')  # search the PubChem database

mol2chemfig('C1=CC=C(C=C1)O')  # transfer InChI/SMILES to chemfig

mol2chemfig('.\methanol.smi')  # from a file

Document

See official document mol2chemfig-doc.pdf (uwaterloo.ca)

License

MIT license

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mol2chemfigPy3-1.5.2.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

mol2chemfigPy3-1.5.2-py3-none-any.whl (35.0 kB view details)

Uploaded Python 3

File details

Details for the file mol2chemfigPy3-1.5.2.tar.gz.

File metadata

  • Download URL: mol2chemfigPy3-1.5.2.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for mol2chemfigPy3-1.5.2.tar.gz
Algorithm Hash digest
SHA256 8355dbfe8f9a9a6b6039b3c2b6cf097dfe601d9eb762c7e69ff273dc482f2e23
MD5 b1490163c2199f10eef634398ef77389
BLAKE2b-256 a78b028cdbcbbaaa9e4613ff2c8be0ea982e346669e0f3024567c2077ec4a7e5

See more details on using hashes here.

File details

Details for the file mol2chemfigPy3-1.5.2-py3-none-any.whl.

File metadata

  • Download URL: mol2chemfigPy3-1.5.2-py3-none-any.whl
  • Upload date:
  • Size: 35.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for mol2chemfigPy3-1.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e8f7642794aecc2afb959a6fc2076f066dc05ffa9b0e6db1f518fb93ba2d2091
MD5 dad7edfb5fe82eb8eab677f9fc72c3f4
BLAKE2b-256 3197899eb827aba5baa1b5a3f009f833b3520c0a548941b47ce22b7684d76538

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page