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 This project is intended to extract materials data from various databases (see the supported databases section) and have a single property identifier for clear and unambiguous understanding.

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 in development mode:

pip install -e .

Or install as a package:

pip install .

Quick Start

  1. Configure API keys

    • Set MP_API_KEY and MPDS_API_KEY as environment variables or in config.py.
  2. Run tests and examples

    • Full test suite:
      python comprehensive_database_test.py --formula Al2O3 --limit 2
      
    • Demo fetch:
      python example_fetch.py
      
  3. Library usage

    • High-level fetch helper:
      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

Look into the example_single_fetch.py file to retive from a single database then save the information in json format and the sturcture in cif format. You can bypass the high-level helpers and use specific client classes from mat_ret.databases. For example, to fetch from Materials Project:

from mat_ret.databases import MaterialsProjectClient

# Initialize client with your API key
client = MaterialsProjectClient(api_key='YOUR_MP_KEY')
# Retrieve a single structure for MgO
results = client.get_structures('MgO', limit=1)
if results:
    entry = results[0]
    print(f"Material ID: {entry['material_id']}")
    for key, value in entry.items():
        if key != 'structure':
            print(f"{key}: {value}")

## OPTIMADE Search

mat_ret can query OPTIMADE providers through the registry when you select **OPTIMADE** in the database list. The GUI shows OPTIMADE providers as a tree: select the parent to toggle all providers or pick specific providers. The same formula filter (e.g., `MgO`) applies, and the **limit per DB** is applied **per provider**.

Running in a Virtual Environment (.venv)

To isolate dependencies, create and activate a Python virtual environment in your project root:

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Then run scripts using the environment's Python interpreter:

.venv/bin/python example_single_fetch.py
.venv/bin/python example_fetch.py
.venv/bin/python comprehensive_database_test.py --formula Al2O3 --limit 2

Graphical User Interface (GUI)

mat_ret includes a modern PyQt6-based graphical interface for easy materials retrieval.

mat_ret GUI Screenshot

Launching the GUI

# After installation, use the command-line entry point:
mat-ret-gui

# Or using Python module syntax:
python -m mat_ret.gui

GUI Features

  • Database Selection: Checkbox interface to select which databases to query
  • OPTIMADE Provider Tree: Select OPTIMADE providers individually or all at once
  • Composition Search: Enter any chemical formula (e.g., MgO, Fe2O3, LiFePO4)
  • Results Table: Interactive table showing material properties from all selected databases
  • Structure Viewer: 3D/2D visualization of crystal structures
    • Multiple view projections (3D, XY, XZ, YZ planes)
    • Adjustable atom sizes
    • Toggle bonds and unit cell display
  • Export Options: Save results as JSON/CSV, export structures as CIF files

Project Structure

mat_ret/
├── src/mat_ret/                # Core package code
│   ├── api.py                  # High-level fetch helpers
│   ├── property_mapping.py     # Mapping config and helpers
│   └── databases.py            # Database client implementations
├── gui/                        # Graphical user interface
│   ├── main.py                 # GUI entry point
│   ├── main_window.py          # Main application window
│   ├── workers.py              # Async fetch workers
│   ├── utils.py                # Utility functions and styling
│   └── widgets/                # UI widgets
│       ├── database_selector.py    # Database selection panel
│       ├── results_view.py         # Results table and JSON view
│       └── structure_viewer.py     # Crystal structure visualization
├── doc/                        # Documentation assets (CSV, guides)
├── example_fetch.py            # Demo script intended to retrieve information from all databases
├── example_single_fetch.py     # Demo script intended to retrieve information from one database
├── README.md                   # Project overview
├── requirements.txt            # Python dependencies
└── LICENSE                     # CeCILL license

Contributing

Keep in touch to contribute !!! We welcome others to develop/fix the functionalities of this python library with these existing databases and/or provide new databases. https://github.com/Aadhityan-A/mat_ret

Note: It's still in the developing phase. If you face any issues let us know through github issues. Also there are some lines of code not in use are for future development purpose.

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.0.tar.gz (74.8 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.0-py3-none-any.whl (77.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mat_ret-0.3.0.tar.gz
  • Upload date:
  • Size: 74.8 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.0.tar.gz
Algorithm Hash digest
SHA256 3356fd4cb5eded1444249c838a4df23c8a1a565bcfa0be1a47d5d269d1440e79
MD5 d3fa3f2efcdd9a6ea3ebfbf0e7b8842d
BLAKE2b-256 ca32f09f2d5d04095faf0a3859e36f2e717202358474bfcb3207cf1fc73a88b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mat_ret-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 77.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46bd4510e3411df2aa23cfd874485fb2f24432a7d9efe90fa3776063315e616b
MD5 4fc7ef92f93443b5f6987b338e3cc0cc
BLAKE2b-256 505635a5755079cfb783b95518beb4514ca3367dabb2128172e24974a02f1708

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