Python client and CLI for the METT Data Portal API
Project description
METT Data Portal Client
Python client library and command-line interface (CLI) for the METT Data Portal API. Access genomic data, experimental results, and protein interactions for gut microbiome research.
Features
- ๐ High-level Python API - Clean, intuitive interface for programmatic access
- ๐ป Command-line Interface - Powerful CLI with tab completion and rich output
- ๐ Multiple Output Formats - JSON, TSV, and formatted tables
- ๐ Flexible Authentication - Environment variables or config file support
- ๐ Comprehensive Documentation - Auto-generated API reference with examples
- ๐ Auto-generated SDK - Stays in sync with the API schema
Quick Start
Installation
pip install mett
CLI Usage
# List all species
mett species list
# Search genomes
mett genomes search --query "Bacteroides" --per-page 5
# Get gene information
mett genes get BU_ATCC8492_00001
Python API
from mett_dataportal import DataPortalClient
# Initialize client
client = DataPortalClient()
# List species
species = client.list_species()
print(f"Found {len(species)} species")
# Search genomes
result = client.search_genomes(query="Bacteroides", per_page=5)
print(f"Found {len(result.items)} genomes")
Documentation
Quick Links
- ๐ API Reference - Complete API documentation with tabbed examples (Quarto format)
- ๐ Usage Guide - Detailed usage examples for CLI and Python API
- โ๏ธ Configuration Guide - Authentication and configuration options
- ๐ง Development Guide - Setup, testing, and contributing
- ๐ฆ Architecture Guide - Package architecture and design decisions
Viewing API Documentation
The API reference is in Quarto format (.qmd). To view it:
# Generate from OpenAPI spec (if needed)
python3 scripts/generate-api-docs.py
# Render to HTML
quarto render docs/reference/api-reference.qmd
# Open in browser
open docs/reference/api-reference.html
Or use preview mode (auto-reloads on changes):
quarto preview docs/reference/api-reference.qmd
The rendered HTML includes interactive tabs showing examples in three formats:
- Friendly CLI - High-level
mettcommands - Generic CLI -
mett api requestcommands - cURL - Raw HTTP requests
For more information, see the Documentation README.
Installation
From PyPI
pip install mett
From Source
Recommended (with uv)
git clone https://github.com/your-org/mett-dataportal-client.git
cd mett-dataportal-client
# Create a virtual environment and install all dependencies from pyproject.toml
uv sync --all-extras --dev
# Run the CLI via uv (no manual activation needed)
uv run mett --help
Running tests and linting
With uv (recommended):
# Install all dev dependencies (if not already done)
uv sync --all-extras --dev
# Run tests
uv run pytest -v
# Run Ruff lint and formatting checks
uv run ruff check mett_dataportal/ scripts/ tests/
uv run ruff format --check mett_dataportal/ scripts/ tests/
# (Optional) Run pre-commit hooks on all files
uv run pre-commit run --all-files
Alternative (classic pip workflow)
If you prefer not to use uv, you can still work with a standard virtual environment:
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -e ".[dev]"
# CLI is now on PATH inside the venv
mett --help
Requirements
- Python 3.10+
- See
pyproject.tomlfor full dependency list
Project Structure
mett-dataportal-client/
โโโ mett_dataportal/ # Main package
โ โโโ cli/ # CLI commands (organized by API type)
โ โ โโโ core/ # Core APIs (system, species, genomes, genes)
โ โ โโโ experimental/ # Experimental APIs (drugs, proteomics, etc.)
โ โ โโโ interactions/ # Interaction APIs (PPI, TTP)
โ โโโ client.py # High-level API client
โ โโโ config.py # Configuration management
โ โโโ utils.py # Utility functions
โโโ mett_dataportal_sdk/ # Auto-generated SDK
โโโ docs/ # Documentation
โ โโโ guides/ # User guides
โ โ โโโ USAGE.md # Usage examples
โ โ โโโ CONFIGURATION.md # Configuration guide
โ โโโ developers/ # Developer documentation
โ โ โโโ DEVELOPMENT.md # Development guide
โ โโโ reference/ # API reference
โ โ โโโ api-reference.qmd # Main API reference (Quarto)
โ โ โโโ cli-examples*.md # Example files
โ โโโ assets/ # Static assets (CSS, etc.)
โโโ scripts/ # Utility scripts
โโโ tests/ # Test suite
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting (see Running tests and linting above)
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/feature/amazing-feature) - Open a Pull Request
License
MIT License - see LICENSE file for details.
Support
- Issues: GitHub Issues
- Documentation: See docs/ directory
- Email: vikasg@ebi.ac.uk
Acknowledgments
Built for the METT Data Portal project. Special thanks to all contributors.
Note: For development environments without SSL certificates, you may need to set:
export METT_VERIFY_SSL=false
Project details
Release history Release notifications | RSS feed
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 mett-0.0.1a2.tar.gz.
File metadata
- Download URL: mett-0.0.1a2.tar.gz
- Upload date:
- Size: 87.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c136b9d2b03ce999f671eaf765e80145440a72c1582f38d0d39fa029f45e6868
|
|
| MD5 |
876ad32f8b0fc3a4a00ba26ebc0dd6c5
|
|
| BLAKE2b-256 |
bc7f6ca772c5cdb4c22bea67f29f6c06f2c5f928400f57fb3da7521e8aa8c4ec
|
File details
Details for the file mett-0.0.1a2-py3-none-any.whl.
File metadata
- Download URL: mett-0.0.1a2-py3-none-any.whl
- Upload date:
- Size: 188.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8094f6ca7c49b22ec33d5b1246236b69f09179cab9d5298ff183847c8a47f641
|
|
| MD5 |
e3e7289ae0f276cbc2395df887691434
|
|
| BLAKE2b-256 |
8fd2c9f7328b7c9df6be4e5a6eb9d837f836e652d99f7fb6a5a942a9e9cf4557
|