Skip to main content

A parser for molecule formula. Nested brackets are supported.

Project description

pymolecule-parser: A parser for a molecule formula that supports nested brackets

Installation

pip install pymolecule-parser

Usage

from pymolecule_parser import parse

parse("H2O") # {'H': 2, 'O': 1}
parse("3H2O") # {'H': 6, 'O': 3}
parse("H2O2(OH)2") # {'H': 4, 'O': 4}
parse("[Co(NH3)6]Cl3") # {'Co': 1, 'N': 6, 'H': 18, 'Cl': 3}

Limitations

The following notations are not supported.

  • Ion notations
    • For example, [Cu(NH3)4]2+ is not supported. Use Cu(NH3)4 instead.
  • middle dot ·
    • For example, CuSO4·5H2O is not supported. Use CuSO4(H2O)5 instead.

License

Apache License 2.0

Author

Kohei Noda

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

pymolecule_parser-0.0.0.tar.gz (10.1 kB view hashes)

Uploaded Source

Built Distribution

pymolecule_parser-0.0.0-py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 3

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