Skip to main content

ChemQL

ChemQL logo

ChemQL is a chemistry-focused query language and REPL for exploring element, molecule, and reaction datasets. It lets you search the built-in chemistry data, filter results with expressions, set reaction conditions, and combine queries with small Python snippets when needed.

What ChemQL does

ChemQL supports:

  • Searching the built-in elements, molecules, and reactions datasets
  • Filtering by field, comparison operator, pattern matching, and boolean logic
  • Quick lookup commands like findel, findmol, and findre
  • Reaction setup with temperature, pressure, and catalyst configuration
  • Running reactions with react
  • Embedding Python in [ ... ] blocks and templates in {{ ... }}
  • Running from a terminal REPL or executing a command/file from the shell

Install the library

Install from this chemql/ directory, which contains pyproject.toml:

cd /path/to/ChemQL/Language/chemql
python -m pip install -e ".[test]"

This installs the Python package and the chemql CLI:

chemql -c "search elements name = 'Hydrogen'"

Start the interactive REPL with:

python -m chemql

You will see the interactive prompt:

>>> 

Type:

help

or:

?

to display the built-in help.

Command-line usage

You can also execute a single ChemQL command or a file:

chemql -c 'search elements name = "Hydrogen"'
chemql -f examples/script.cql

The Python package is chemql. Its query engine, chemistry types, and bundled datasets can be imported directly:

from chemql import balance_stoichiometry, execute_query_text

result = execute_query_text('search elements name = "Hydrogen"')
reaction = balance_stoichiometry(["O2", "H2"], ["H2O"], reversible=True)
print(reaction)

Core query syntax

Search a dataset

search elements
search molecules
search reactions

Search with filters

search elements atomic_number > 10 and atomic_number < 20
search molecules name like "*water*"
search reactions reaction_type = "combustion"

Sort, limit, and count

search molecules sort molecular_weight desc
search molecules limit 10
search molecules count

Return selected fields

search molecules molecular_weight < 20 return name formula molecular_weight
search reactions reversible = true return name conditions

Set the current source

source elements
source molecules
source reactions

List available keys

list all

Convenience lookup commands

findel "He"
findel "Hydrogen"

findmol "H2O"
findmol "Water"

findre "Haber process"
findre "RHEA:10000" return name equation source

Reactions

Set reaction conditions before running a reaction:

set temperature 723K
set temperature standard
set pressure 20265000pa
set pressure room
set catalysts iron zinc
add catalyst "Vanadium oxide"
remove catalyst "Vanadium oxide"
conditions
react N2 3H2
balance O2 + H2 -> H2O
balance O2 + H2 <-> H2O

Temperature accepts C, F, or K; pressure accepts Pa, N/m^2, Nm^-2, bar, or atm. The keywords standard and room are also accepted.

balance accepts chemical formulas on each side, separated by +. It returns a Reaction with the smallest positive integer stoichiometric coefficients. The arrow determines reaction direction: -> is irreversible and <-> is reversible. // begins a comment, as it does elsewhere in ChemQL. The function API is balance_stoichiometry(reactants, products, reversible=None).

Operators

ChemQL supports these comparison operators:

  • =
  • >
  • <
  • >=
  • <=
  • like
  • like!
  • has

Boolean logic:

and
or

Parentheses may be used to group expressions.

Result controls

search molecules first
search molecules last
search molecules sort atomic_number desc limit 5
search molecules count

General commands

list all
view
clear
dump my_session.txt
help
exit

view opens the periodic table in a browser. dump writes recent command history to a file.

Hybrid Python mode

ChemQL can be mixed with Python inside square-bracket blocks:

[x = 10]
[print(x)]

Conditional and loop blocks are also supported:

[for x in range(3)]
[print(x)]
[endblock]

[if x > 0]
[print("positive")]
[else]
[print("not positive")]
[endblock]

Embedded ChemQL queries can also be used with double-brace syntax. This executes a query and uses the result as a value in the surrounding Python:

[print({{ search elements number = 1 }})]
[for i in {{search elements number <= 10}}]
    [print(i.name)]
[endblock]

The {{ ... }} form is a convenient way to make a query return actual data to Python, rather than only writing a plain query line.

Line continuation

If a line ends with \, it continues onto the next line:

search elements \
name = "Hydrogen"

This is treated as:

search elements name = "Hydrogen"

Examples

search elements name = "Hydrogen"
findel "He"
findmol "H2O"

search molecules molecular_weight < 20 \
return name formula molecular_weight

search elements atomic_number > 10 \
and atomic_number < 20 \
sort atomic_number desc \
limit 5

search molecules count

Repository layout

chemql/
├── pyproject.toml
├── src/
│   └── chemql/
│       ├── __init__.py
│       ├── __main__.py
│       ├── data/
│       └── html/
├── tests/
├── scripts/
└── examples/

The installable package contains the language implementation and its bundled chemical datasets.

Created by Mohammad Rakibul Islam. Source code: rakibulofficial1017/ChemQL.

Metadata

Release files for chemql-python 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chemql-python 0.2.2
File Size Uploaded Provenance
chemql_python-0.2.2.tar.gz 215.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for chemql-python 0.2.2
File Interpreter ABI Platform
chemql_python-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 437.1 kB

Release files / chemql_python-0.2.2.tar.gz

Download URL chemql_python-0.2.2.tar.gz
Size 215.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8e983fa7243143833ab02a7aee6e7a64528e67de8d8a13b37e334c4f7bcc4f91
BLAKE2b-256 checksum
How to use checksums
b7fac04171db41dcfb9d7be0e9998132b48340d0092d9b15c25f76c5fd68934e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / chemql_python-0.2.2-py3-none-any.whl

Download URL chemql_python-0.2.2-py3-none-any.whl
Size 221.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa13dc5d1dc478147d1e2b308cc2b1da08f2af00a4ea875d4fc631893ff23610
BLAKE2b-256 checksum
How to use checksums
54021dac5554a62027e86315f75e401ae8b938c5051c984667b522c781227f60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for chemql-python 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page