chemql-python 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chemql/__init__.py +3154 -0
- chemql/__main__.py +4 -0
- chemql/data/BondEnergies.json +602 -0
- chemql/data/MoleculeBonds.json +5708 -0
- chemql/data/Molecules.json +9270 -0
- chemql/data/PeriodicTableJSON.json +6268 -0
- chemql/data/Reactions.json +46749 -0
- chemql/data/THIRD_PARTY_LICENSES/PeriodicTableJSON.txt +10 -0
- chemql/data/THIRD_PARTY_LICENSES/RHEA.txt +14 -0
- chemql/html/periodic_table.html +14124 -0
- chemql_python-0.1.0.dist-info/METADATA +297 -0
- chemql_python-0.1.0.dist-info/RECORD +16 -0
- chemql_python-0.1.0.dist-info/WHEEL +5 -0
- chemql_python-0.1.0.dist-info/entry_points.txt +2 -0
- chemql_python-0.1.0.dist-info/licenses/LICENSE +21 -0
- chemql_python-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chemql-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A chemistry-focused query language and REPL
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: prompt_toolkit>=3.0
|
|
9
|
+
Provides-Extra: test
|
|
10
|
+
Requires-Dist: pytest>=8.0; extra == "test"
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# ChemQL
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
|
|
17
|
+
## What ChemQL does
|
|
18
|
+
|
|
19
|
+
ChemQL supports:
|
|
20
|
+
|
|
21
|
+
- Searching the built-in `elements`, `molecules`, and `reactions` datasets
|
|
22
|
+
- Filtering by field, comparison operator, pattern matching, and boolean logic
|
|
23
|
+
- Quick lookup commands like `findel`, `findmol`, and `findre`
|
|
24
|
+
- Reaction setup with temperature, pressure, and catalyst configuration
|
|
25
|
+
- Running reactions with `react`
|
|
26
|
+
- Embedding Python in `[ ... ]` blocks and templates in `{{ ... }}`
|
|
27
|
+
- Running from a terminal REPL or executing a command/file from the shell
|
|
28
|
+
|
|
29
|
+
## Install the library
|
|
30
|
+
|
|
31
|
+
Install from this `chemql/` directory, which contains `pyproject.toml`:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cd /path/to/ChemQL/Language/chemql
|
|
35
|
+
python -m pip install -e ".[test]"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This installs the Python package and the `chemql` CLI:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
chemql -c "search elements name = 'Hydrogen'"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Start the interactive REPL with:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
python -m chemql
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
You will see the interactive prompt:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
>>>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Type:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
help
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
or:
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
?
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
to display the built-in help.
|
|
69
|
+
|
|
70
|
+
## Command-line usage
|
|
71
|
+
|
|
72
|
+
You can also execute a single ChemQL command or a file:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
chemql -c 'search elements name = "Hydrogen"'
|
|
76
|
+
chemql -f examples/script.cql
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The Python package is `chemql`. Its query engine, chemistry types, and bundled
|
|
80
|
+
datasets can be imported directly:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from chemql import execute_query_text
|
|
84
|
+
|
|
85
|
+
result = execute_query_text('search elements name = "Hydrogen"')
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Core query syntax
|
|
89
|
+
|
|
90
|
+
### Search a dataset
|
|
91
|
+
|
|
92
|
+
```text
|
|
93
|
+
search elements
|
|
94
|
+
search molecules
|
|
95
|
+
search reactions
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Search with filters
|
|
99
|
+
|
|
100
|
+
```text
|
|
101
|
+
search elements atomic_number > 10 and atomic_number < 20
|
|
102
|
+
search molecules name like "*water*"
|
|
103
|
+
search reactions reaction_type = "combustion"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Sort, limit, and count
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
search molecules sort molecular_weight desc
|
|
110
|
+
search molecules limit 10
|
|
111
|
+
search molecules count
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Return selected fields
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
search molecules molecular_weight < 20 return name formula molecular_weight
|
|
118
|
+
search reactions reversible = true return name conditions
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Set the current source
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
source elements
|
|
125
|
+
source molecules
|
|
126
|
+
source reactions
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### List available keys
|
|
130
|
+
|
|
131
|
+
```text
|
|
132
|
+
list all
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Convenience lookup commands
|
|
136
|
+
|
|
137
|
+
```text
|
|
138
|
+
findel "He"
|
|
139
|
+
findel "Hydrogen"
|
|
140
|
+
|
|
141
|
+
findmol "H2O"
|
|
142
|
+
findmol "Water"
|
|
143
|
+
|
|
144
|
+
findre "Haber process"
|
|
145
|
+
findre "RHEA:10000" return name equation source
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Reactions
|
|
149
|
+
|
|
150
|
+
Set reaction conditions before running a reaction:
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
set temperature 723K
|
|
154
|
+
set temperature standard
|
|
155
|
+
set pressure 20265000pa
|
|
156
|
+
set pressure room
|
|
157
|
+
set catalysts iron zinc
|
|
158
|
+
add catalyst "Vanadium oxide"
|
|
159
|
+
remove catalyst "Vanadium oxide"
|
|
160
|
+
conditions
|
|
161
|
+
react N2 3H2
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
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.
|
|
165
|
+
|
|
166
|
+
## Operators
|
|
167
|
+
|
|
168
|
+
ChemQL supports these comparison operators:
|
|
169
|
+
|
|
170
|
+
- `=`
|
|
171
|
+
- `>`
|
|
172
|
+
- `<`
|
|
173
|
+
- `>=`
|
|
174
|
+
- `<=`
|
|
175
|
+
- `like`
|
|
176
|
+
- `like!`
|
|
177
|
+
- `has`
|
|
178
|
+
|
|
179
|
+
Boolean logic:
|
|
180
|
+
|
|
181
|
+
```text
|
|
182
|
+
and
|
|
183
|
+
or
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Parentheses may be used to group expressions.
|
|
187
|
+
|
|
188
|
+
## Result controls
|
|
189
|
+
|
|
190
|
+
```text
|
|
191
|
+
search molecules first
|
|
192
|
+
search molecules last
|
|
193
|
+
search molecules sort atomic_number desc limit 5
|
|
194
|
+
search molecules count
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## General commands
|
|
198
|
+
|
|
199
|
+
```text
|
|
200
|
+
list all
|
|
201
|
+
view
|
|
202
|
+
clear
|
|
203
|
+
dump my_session.txt
|
|
204
|
+
help
|
|
205
|
+
exit
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
`view` opens the periodic table in a browser. `dump` writes recent command history to a file.
|
|
209
|
+
|
|
210
|
+
## Hybrid Python mode
|
|
211
|
+
|
|
212
|
+
ChemQL can be mixed with Python inside square-bracket blocks:
|
|
213
|
+
|
|
214
|
+
```text
|
|
215
|
+
[x = 10]
|
|
216
|
+
[print(x)]
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Conditional and loop blocks are also supported:
|
|
220
|
+
|
|
221
|
+
```text
|
|
222
|
+
[for x in range(3)]
|
|
223
|
+
[print(x)]
|
|
224
|
+
[endblock]
|
|
225
|
+
|
|
226
|
+
[if x > 0]
|
|
227
|
+
[print("positive")]
|
|
228
|
+
[else]
|
|
229
|
+
[print("not positive")]
|
|
230
|
+
[endblock]
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
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:
|
|
234
|
+
|
|
235
|
+
```text
|
|
236
|
+
[print({{ search elements number = 1 }})]
|
|
237
|
+
[for i in {{search elements number <= 10}}]
|
|
238
|
+
[print(i.name)]
|
|
239
|
+
[endblock]
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
The `{{ ... }}` form is a convenient way to make a query return actual data to Python, rather than only writing a plain query line.
|
|
243
|
+
|
|
244
|
+
## Line continuation
|
|
245
|
+
|
|
246
|
+
If a line ends with `\`, it continues onto the next line:
|
|
247
|
+
|
|
248
|
+
```text
|
|
249
|
+
search elements \
|
|
250
|
+
name = "Hydrogen"
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
This is treated as:
|
|
254
|
+
|
|
255
|
+
```text
|
|
256
|
+
search elements name = "Hydrogen"
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Examples
|
|
260
|
+
|
|
261
|
+
```text
|
|
262
|
+
search elements name = "Hydrogen"
|
|
263
|
+
findel "He"
|
|
264
|
+
findmol "H2O"
|
|
265
|
+
|
|
266
|
+
search molecules molecular_weight < 20 \
|
|
267
|
+
return name formula molecular_weight
|
|
268
|
+
|
|
269
|
+
search elements atomic_number > 10 \
|
|
270
|
+
and atomic_number < 20 \
|
|
271
|
+
sort atomic_number desc \
|
|
272
|
+
limit 5
|
|
273
|
+
|
|
274
|
+
search molecules count
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Repository layout
|
|
278
|
+
|
|
279
|
+
```text
|
|
280
|
+
chemql/
|
|
281
|
+
├── pyproject.toml
|
|
282
|
+
├── src/
|
|
283
|
+
│ └── chemql/
|
|
284
|
+
│ ├── __init__.py
|
|
285
|
+
│ ├── __main__.py
|
|
286
|
+
│ ├── data/
|
|
287
|
+
│ └── html/
|
|
288
|
+
├── tests/
|
|
289
|
+
├── scripts/
|
|
290
|
+
└── examples/
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
The installable package contains the language implementation and its bundled
|
|
294
|
+
chemical datasets.
|
|
295
|
+
|
|
296
|
+
Created by [Mohammad Rakibul Islam](https://github.com/rakibulofficial1017).
|
|
297
|
+
Source code: [rakibulofficial1017/ChemQL](https://github.com/rakibulofficial1017/ChemQL).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
chemql/__init__.py,sha256=8Rw3NyzL_ahAEQJY0kjVon6knK9CjaLwAOM0lO2E-hY,88988
|
|
2
|
+
chemql/__main__.py,sha256=3Q52s0hyuouhvSSqFEQFDr6mtJ-azkCwI2AD4c7f7A8,28
|
|
3
|
+
chemql/data/BondEnergies.json,sha256=QZN3iWZrD8125jV41EG1GiRohBtP0CzAP_EDQTfaEKc,8269
|
|
4
|
+
chemql/data/MoleculeBonds.json,sha256=Iw2shYxJScH_tI80IytBYoqVDSbgT7OSqPJUIgKZme4,84262
|
|
5
|
+
chemql/data/Molecules.json,sha256=wsRLJZMDg4BIu-0RZlDnk1rg0OMlSYzDmCTIIZkOE84,171956
|
|
6
|
+
chemql/data/PeriodicTableJSON.json,sha256=3yxD7BPivhx-oHIVBX883e8iT9D33G8K1xLZ_9z8w2A,281004
|
|
7
|
+
chemql/data/Reactions.json,sha256=BFpkKEWwLzG54ot96BVOWwU3btpimRJlOM57yGclGgc,1593723
|
|
8
|
+
chemql/data/THIRD_PARTY_LICENSES/PeriodicTableJSON.txt,sha256=9wih5q8s58qR3vJEGpooa4ESyAGZHcmGvzwMMkMHNKk,322
|
|
9
|
+
chemql/data/THIRD_PARTY_LICENSES/RHEA.txt,sha256=nXTeCP6vJBW5B_mtaVGFLr0w7vnjrSTBnv6_eOk3KKo,634
|
|
10
|
+
chemql/html/periodic_table.html,sha256=ftVgXWjRO2AsTAGEekTrvgE5ZvcwRfoby9UWoixc9Y8,361560
|
|
11
|
+
chemql_python-0.1.0.dist-info/licenses/LICENSE,sha256=o4ywHC0EwRy2zgIASiRD2sK3Vcsf7LBcTHjDvoJgRE0,1079
|
|
12
|
+
chemql_python-0.1.0.dist-info/METADATA,sha256=FPFgK-zL-27jDCw1y4CevChSj9HB1rFpkkGj--dfpEo,5610
|
|
13
|
+
chemql_python-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
14
|
+
chemql_python-0.1.0.dist-info/entry_points.txt,sha256=j98ObVWR743an524z24AiWeRsppag-py5cc7l0D0HkI,39
|
|
15
|
+
chemql_python-0.1.0.dist-info/top_level.txt,sha256=9UzHwnk_F6W19Q9nayaFgVyAELQXXwoYjeBgB6MWNr8,7
|
|
16
|
+
chemql_python-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohammad Rakibul Islam
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
chemql
|