Skip to main content

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

  1. Materials Project
  2. JARVIS
  3. AFLOW
  4. Alexandria
  5. Materials Cloud
  6. MPDS
  7. OQMD
  8. 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

  1. Configure API keys (MP_API_KEY, MPDS_API_KEY) via environment variables or config.py.
  2. Run examples:
python example_fetch.py
python example_single_fetch.py
  1. 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.

mat_ret GUI Screenshot

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)
  • 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:
    • Stick
    • Gaussian
    • Lorentzian
    • Pseudo-Voigt (with eta)
  • 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

Defaults:

  • Radiation: CuKa (1.54184 A)
  • Scan range: 5 to 90 deg (2theta), step 0.02
  • Profile: Pseudo-Voigt
  • FWHM: 0.15 deg
  • 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

mat_ret-0.3.1.tar.gz (89.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mat_ret-0.3.1-py3-none-any.whl (91.9 kB view details)

Uploaded Python 3

File details

Details for the file mat_ret-0.3.1.tar.gz.

File metadata

  • Download URL: mat_ret-0.3.1.tar.gz
  • Upload date:
  • Size: 89.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for mat_ret-0.3.1.tar.gz
Algorithm Hash digest
SHA256 d816f68a4398c7d2d11fadc95240b317bdace4fdde977166693cb26a21062db1
MD5 bc39028cfcceaa6fe5e1a6cbd85eca57
BLAKE2b-256 cac716ea61377bc5f2f746ed0b7e96250058b35862e09f9f0e0366142272d264

See more details on using hashes here.

File details

Details for the file mat_ret-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: mat_ret-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 91.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for mat_ret-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 151dc453111b67ce2869dc14e2f87e678afc4957bf7329dc292786caf08bca67
MD5 8691fc136373aab71ad607b3ce020ae4
BLAKE2b-256 7162d23bc1557afd411850652acbbc9fd14b8fe46a15a14ded676c0d26f40c55

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page