ChemQL
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, andreactionsdatasets - Filtering by field, comparison operator, pattern matching, and boolean logic
- Quick lookup commands like
findel,findmol, andfindre - 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 execute_query_text
result = execute_query_text('search elements name = "Hydrogen"')
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
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.
Operators
ChemQL supports these comparison operators:
=><>=<=likelike!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.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| chemql_python-0.1.0.tar.gz | 212.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chemql_python-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 432.3 kB
Release files / chemql_python-0.1.0.tar.gz
| Download URL | chemql_python-0.1.0.tar.gz |
|---|---|
| Size | 212.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f2be327ef932c3b65d0a32a0fbf6d711b83b417492b4687fb7c66c74d35b04b7
|
|
BLAKE2b-256 checksum How to use checksums |
376d20c4cf5de3f1ce314c226adde4a6f3f1fcafc794b58ccaac324a2392201a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / chemql_python-0.1.0-py3-none-any.whl
| Download URL | chemql_python-0.1.0-py3-none-any.whl |
|---|---|
| Size | 219.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3fc865d97c970f22689db9f1bd170d1b5a90d9733b9cd56df7b02055bbd85d64
|
|
BLAKE2b-256 checksum How to use checksums |
e1751246a5fafde03a22bf3e729cd2a1d3aab93c21583b397dada88bda2e5c91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|