Unified retrieval and property mapping for materials databases (Materials Project, JARVIS, AFLOW, Alexandria, Materials Cloud, MPDS)
Project description
mat_ret
Unified retrieval and property mapping for materials databases, with a PyQt6 GUI for materials search, structure viewing, and XRD generation.
Supported Databases
- Materials Project
- JARVIS
- AFLOW
- Alexandria
- Materials Cloud
- MPDS
- OQMD
- OPTIMADE providers (registry search)
Installation
Install as package:
pip install .
Install editable for development:
pip install -e .
Install editable with test dependencies:
pip install -e ".[dev]"
Quick Start
- Configure API keys (
MP_API_KEY,MPDS_API_KEY) via environment variables orconfig.py. - Run examples:
python example_fetch.py
python example_single_fetch.py
- Use the Python API:
from mat_ret.api import fetch_all_databases
results = fetch_all_databases(
formula="MgO",
limit_per_database=3,
mp_api_key="YOUR_MP_KEY",
mpds_api_key="YOUR_MPDS_KEY",
)
print(results["materials_project"][0])
Direct Client Usage
You can call specific clients from mat_ret.databases directly:
from mat_ret.databases import MaterialsProjectClient
client = MaterialsProjectClient(api_key="YOUR_MP_KEY")
results = client.get_structures("MgO", limit=1)
if results:
entry = results[0]
print(entry["material_id"])
OPTIMADE Search
When OPTIMADE is selected in the GUI, providers are shown as a tree. Select the parent to toggle all providers or select individual providers. The search filter applies to each provider, and limit is applied per provider.
Running in a Virtual Environment
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
GUI
mat_ret includes a PyQt6 desktop GUI.
Launch GUI
mat-ret-gui
# or
python -m mat_ret.gui
GUI Features
- Database selection and API key controls
- OPTIMADE provider tree with per-provider toggles
- Formula search (e.g.,
Fe2O3,LiFePO4) across selected databases - Element-set search via periodic-table picker icon next to the search box
- Chemsys text format:
Fe-O,Li-Fe-O - Element mode uses contains-all semantics
- Unsupported providers/databases are skipped with explicit status messages (e.g., OQMD)
- Chemsys text format:
- Results table and JSON views
- Structure viewer with CIF export
- File menu exports (JSON/CSV)
- Tools menu:
- XRD Generator
XRD Generator
Open Tools -> XRD Generator... in the GUI.
Capabilities:
- Input sources:
- Any CIF file from disk
- Currently selected structure from the main results window
- Radiation presets from pymatgen (including
CuKa,CuKa1,CuKa2, etc.) - Optional custom wavelength (Angstrom)
- Scan controls:
2theta min,2theta max,2theta step - Profile controls:
StickGaussianLorentzianPseudo-Voigt(witheta)
- Peak broadening width control (
FWHM, degrees in 2theta) - Peak finder controls using SciPy:
- minimum height
- prominence
- minimum distance
- minimum width
- theoretical peak match tolerance
- Interactive plot view + peak table
- Exports:
- plot (
PNG,SVG,PDF) - profile/stick CSV
- peaks CSV
- plot (
Defaults:
- Radiation:
CuKa(1.54184 A) - Scan range:
5to90deg (2theta), step0.02 - Profile:
Pseudo-Voigt - FWHM:
0.15deg - Eta:
0.5
Detailed XRD notes are in doc/XRD_GENERATOR_GUIDE.md.
XRD API
from mat_ret import XRDConfig, generate_xrd_pattern_from_cif
cfg = XRDConfig(
radiation="CuKa",
two_theta_min=5.0,
two_theta_max=90.0,
two_theta_step=0.02,
profile="pseudo_voigt",
fwhm=0.15,
)
result = generate_xrd_pattern_from_cif("example.cif", config=cfg)
print(result.wavelength, len(result.peaks))
Tests
Run XRD tests:
pytest tests/test_xrd.py
Run all tests:
pytest
Project Structure
mat_ret/
├── src/mat_ret/
│ ├── api.py
│ ├── databases.py
│ ├── property_mapping.py
│ ├── xrd.py
│ └── gui/
│ ├── main.py
│ ├── main_window.py
│ ├── workers.py
│ ├── utils.py
│ └── widgets/
│ ├── database_selector.py
│ ├── results_view.py
│ ├── structure_viewer.py
│ └── xrd_generator_window.py
├── tests/
│ └── test_xrd.py
├── doc/
│ ├── PROPERTY_MAPPING_GUIDE.md
│ └── XRD_GENERATOR_GUIDE.md
├── README.md
├── pyproject.toml
└── requirements.txt
Contributing
Issues and pull requests are welcome: https://github.com/Aadhityan-A/mat_ret
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mat_ret-0.3.4.tar.gz.
File metadata
- Download URL: mat_ret-0.3.4.tar.gz
- Upload date:
- Size: 117.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cd6ec4b2154098345df0b77fa3a7b003bba94f7e6ef0edae469ac859b06a8b0
|
|
| MD5 |
7b7e234426bad1deec7fcc9b9c6ec004
|
|
| BLAKE2b-256 |
7894283267faa05b60be8a9bbfc3f9b8f7ad22d633e1ff9b9385758a42720b6e
|
File details
Details for the file mat_ret-0.3.4-py3-none-any.whl.
File metadata
- Download URL: mat_ret-0.3.4-py3-none-any.whl
- Upload date:
- Size: 119.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8806ed10d09a72a57d4bddf60bbf116b6b75ee601d635d63cf22ff55bdd4a1dc
|
|
| MD5 |
6c4f11d59e500044bc8272463ce3453c
|
|
| BLAKE2b-256 |
4a00841f7806eea81415a31f80d196dbab1bbe2fd5552f7b89229c02877c53c3
|