prisma-api 0.3.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.
@@ -0,0 +1,245 @@
1
+ Metadata-Version: 2.4
2
+ Name: prisma_api
3
+ Version: 0.3.0
4
+ Summary: A package for interacting with PrISMa Platform APIs. PrISMa is a holistic system for numerical synthesis and assessment of Metal-Organic Frameworks and their applications, for Direct Air Capture of CO2. For more information, see: https://prisma.hw.ac.uk.
5
+ Author-email: RCCS-CaptureTeam <team@prisma-platform.org>
6
+ License: GNUv3
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy>=1.21.0
11
+ Requires-Dist: pandas>=1.3.0
12
+ Requires-Dist: pyyaml>=6.0
13
+ Requires-Dist: platformdirs>=2.5.0
14
+ Requires-Dist: requests>=2.27.0
15
+ Provides-Extra: dev
16
+ Requires-Dist: pytest>=8.0; extra == "dev"
17
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
18
+ Requires-Dist: responses>=0.25; extra == "dev"
19
+ Dynamic: license-file
20
+
21
+ # PrISMa-API
22
+ A package for interacting with `prisma_cloud`. PrISMa is a holistic system for numerical synthesis and assessment of Metal-Organic Frameworks and their applications. These applications include for Direct Air Capture (DAC) of CO<sub>2</sub>. For more information, see: https://prisma.hw.ac.uk.
23
+
24
+ This package is designed specifically as an integration layer between the `PrismaCloud` web service ([www.dun-eideann-labs.co.uk/prisma_cloud](www.dun-eideann-labs.co.uk/prisma_cloud)) and any client-side process, including (but not limited to) the PrISMa simulation environment. The main purpose of this package is to provide a set of easy-to-use wrapper functions for making REST API calls to the online database.
25
+
26
+
27
+
28
+ ---
29
+
30
+ ## 1. Installation
31
+
32
+ ### From PyPI
33
+
34
+ ```bash
35
+ pip install prisma_api
36
+ ```
37
+
38
+ ### From source (this repository)
39
+
40
+ ```bash
41
+ git clone https://github.com/RCCS-CaptureTeam/prisma_api.git
42
+ cd prisma_api
43
+ pip install .
44
+ ```
45
+
46
+ **Requirements:** Python ≥ 3.10, plus `numpy`, `pandas`, `pyyaml`,
47
+ `platformdirs`, and `requests` (installed automatically).
48
+
49
+ ---
50
+
51
+ ## 2. Configuration
52
+
53
+ The package authenticates using an API key stored in a local config file.
54
+ On first use, run the one-time setup:
55
+
56
+ ```python
57
+ import prisma_api
58
+
59
+ # Interactive prompt — enter your PrISMa API key when asked
60
+ api = prisma_api.prisma_api()
61
+ ```
62
+
63
+ The key is saved to a platform-specific config file and reused automatically
64
+ on every subsequent import:
65
+
66
+ | Platform | Config file location |
67
+ |----------|----------------------|
68
+ | macOS / Linux | `~/.config/prisma_api/config.yaml` |
69
+ | Windows | `%APPDATA%\prisma-api\prisma_api\config.yaml` |
70
+
71
+ To find the exact path on your system:
72
+
73
+ ```python
74
+ from prisma_api.config import locate_config
75
+ print(locate_config())
76
+ ```
77
+
78
+ To set or update the key programmatically (skips the interactive prompt):
79
+
80
+ ```python
81
+ from prisma_api.config import create_config_file
82
+ create_config_file(api_key="YOUR_API_KEY_HERE")
83
+ ```
84
+
85
+ ---
86
+
87
+ ## 3. Initialisation
88
+
89
+ ```python
90
+ import prisma_api
91
+
92
+ api = prisma_api.prisma_api() # reads key from config.yaml automatically
93
+ ```
94
+
95
+ All PSDI (and other v2) endpoints are accessed via the `api.v2` sub-object.
96
+
97
+ ---
98
+
99
+ ## 4. PSDI Endpoint
100
+
101
+ The **PSDI** (Physical Sciences Data Infrastructure) endpoint exposes
102
+ extended crystallographic and chemical metadata for every material in the
103
+ PrISMa database.
104
+
105
+ ### 4.1 List materials — `get_materials_psdi`
106
+
107
+ Returns a `pandas.DataFrame` with one row per material.
108
+
109
+ ```python
110
+ # All materials (up to default limit of 500)
111
+ df = api.v2.get_materials_psdi()
112
+
113
+ # Filter by name substring (case-insensitive)
114
+ df = api.v2.get_materials_psdi(name="ABEX")
115
+
116
+ # Pagination
117
+ df = api.v2.get_materials_psdi(limit=100, offset=200)
118
+ ```
119
+
120
+ **Columns returned:**
121
+
122
+ | Column | Description |
123
+ |--------|-------------|
124
+ | `id` | Integer primary key |
125
+ | `name` | Material name (slug identifier) |
126
+ | `cif_url` | URL to the CIF structure file |
127
+ | `cif_filename` | CIF filename |
128
+ | `formula_descriptive` | Human-readable chemical formula |
129
+ | `formula_hill` | Hill-notation formula |
130
+ | `formula_reduced` | Reduced formula |
131
+ | `formula_anonymous` | Anonymous formula |
132
+ | `formula` | Primary formula field |
133
+ | `formula_calculated` | Calculated formula |
134
+ | `chemical_name` | IUPAC / common chemical name |
135
+ | `periodic_dimensions` | Number of periodic dimensions |
136
+ | `smiles` | SMILES string |
137
+ | `spacegroup_hm` | Space group (Hermann–Mauguin) |
138
+ | `spacegroup_hall` | Space group (Hall notation) |
139
+ | `spacegroup_number` | Space group number |
140
+ | `cell_volume` | Unit cell volume (ų) |
141
+ | `cell_lengths` | Unit cell lengths a, b, c (Å) |
142
+ | `cell_angles` | Unit cell angles α, β, γ (°) |
143
+ | `cell_ratios` | Cell length ratios |
144
+ | `unit_cell` | Full unit cell parameter dict |
145
+
146
+ **Example — inspect the first few results:**
147
+
148
+ ```python
149
+ df = api.v2.get_materials_psdi(name="ABEX")
150
+ print(df[["name", "formula_hill", "spacegroup_hm", "cell_volume"]].head())
151
+ ```
152
+
153
+ ```
154
+ name formula_hill spacegroup_hm cell_volume
155
+ 0 ABEXEM C48 H24 N6 O9 Zn3 P-1 2134.5
156
+ 1 ABEXIQ C48 H24 N6 O9 Co3 P-1 2109.3
157
+ ```
158
+
159
+ ---
160
+
161
+ ### 4.2 Single material detail — `get_material_psdi`
162
+
163
+ Returns a `dict` with the full extended record for one material, including
164
+ all list-endpoint fields **plus** linker/node chemistry and elemental
165
+ composition.
166
+
167
+ ```python
168
+ # Look up by integer PK (obtain the id from get_materials_psdi)
169
+ record = api.v2.get_material_psdi(1)
170
+ ```
171
+
172
+ **Additional fields over the list endpoint:**
173
+
174
+ | Field | Description |
175
+ |-------|-------------|
176
+ | `smiles_linker` | SMILES of organic linker |
177
+ | `formula_linker` | Formula of organic linker |
178
+ | `smiles_linker_PubChem` | Canonical SMILES (PubChem pipeline) |
179
+ | `formula_linker_PubChem` | Formula from PubChem pipeline |
180
+ | `count_dict_PubChem` | Atom-count dict from PubChem |
181
+ | `smiles_node` | SMILES of inorganic node |
182
+ | `formula_node` | Formula of inorganic node |
183
+ | `elements` | List of `{symbol, atomic_number, mass_fraction}` dicts |
184
+
185
+ **Example:**
186
+
187
+ ```python
188
+ record = api.v2.get_material_psdi(1)
189
+
190
+ print(record["name"]) # 'ABEXEM'
191
+ print(record["formula_hill"]) # 'C48 H24 N6 O9 Zn3'
192
+ print(record["smiles_linker"]) # 'OC(=O)c1cncc(C(=O)O)c1'
193
+
194
+ for el in record["elements"]:
195
+ print(el["symbol"], el["mass_fraction"])
196
+ # Zn 0.2451
197
+ # C 0.3601
198
+ # ...
199
+ ```
200
+
201
+ ---
202
+
203
+ ### 4.3 Retrieve all materials (pagination helper)
204
+
205
+ The default `limit` is 500. To retrieve the full catalogue, increment
206
+ `offset` until fewer records than `limit` are returned:
207
+
208
+ ```python
209
+ import pandas as pd
210
+
211
+ all_rows = []
212
+ limit, offset = 500, 0
213
+
214
+ while True:
215
+ batch = api.v2.get_materials_psdi(limit=limit, offset=offset)
216
+ all_rows.append(batch)
217
+ if len(batch) < limit:
218
+ break
219
+ offset += limit
220
+
221
+ df_all = pd.concat(all_rows, ignore_index=True)
222
+ print(f"{len(df_all)} materials retrieved")
223
+ ```
224
+
225
+ ---
226
+
227
+ ### 4.4 Return format
228
+
229
+ By default all list endpoints return a `pandas.DataFrame`. To get plain
230
+ Python `list[dict]` instead:
231
+
232
+ ```python
233
+ api.set_return_format("json")
234
+ records = api.v2.get_materials_psdi(name="ABEX") # list[dict]
235
+
236
+ api.set_return_format("dataframe") # revert to default
237
+ ```
238
+
239
+ ---
240
+
241
+ ## 5. Further reading
242
+
243
+ - Full v2 API reference: [`API_REFERENCE.md`](API_REFERENCE.md)
244
+ - All available endpoints: `dir(api.v2)`
245
+ - PrISMa platform: <https://prisma-platform.org>
@@ -0,0 +1,9 @@
1
+ prisma_api/__init__.py,sha256=VfKuTUBAIvL_bMFVk-RKnDnmqIbNcOv5ZW6eayIGRuQ,342
2
+ prisma_api/config.py,sha256=2d6M-pEXE6fW6vBNd7rJ-cBXmhsU8UjLqZ5MbS74RrE,4843
3
+ prisma_api/prisma_api.py,sha256=2AInwSu-UObhq1fDyGtdKvNjSrw7zV74b_ORjFhctNI,22388
4
+ prisma_api/prisma_api_v2.py,sha256=XQLVFLmUwNEHBGvCw_FuJi5eeQ_xeFi71jfFoZOzCLY,65561
5
+ prisma_api-0.3.0.dist-info/licenses/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
6
+ prisma_api-0.3.0.dist-info/METADATA,sha256=HnqAkP3tKpzsphwOKoQj4pe2CaYCGkTw91TaD0zbhY8,7101
7
+ prisma_api-0.3.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
8
+ prisma_api-0.3.0.dist-info/top_level.txt,sha256=WBwk787hgmlrM6meox5ag8pwWpfphsOcuQPCcEoqtcw,11
9
+ prisma_api-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+