Skip to main content

Python client and CLI for the METT Data Portal API

Project description

METT Data Portal Client

Python 3.10+ License: MIT PyPI version

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

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 mett commands
  • Generic CLI - mett api request commands
  • 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.toml for 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.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and linting (see Running tests and linting above)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/feature/amazing-feature)
  7. Open a Pull Request

License

MIT License - see LICENSE file for details.

Support

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mett-0.0.1a2.tar.gz (87.4 kB view details)

Uploaded Source

Built Distribution

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

mett-0.0.1a2-py3-none-any.whl (188.1 kB view details)

Uploaded Python 3

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

Hashes for mett-0.0.1a2.tar.gz
Algorithm Hash digest
SHA256 c136b9d2b03ce999f671eaf765e80145440a72c1582f38d0d39fa029f45e6868
MD5 876ad32f8b0fc3a4a00ba26ebc0dd6c5
BLAKE2b-256 bc7f6ca772c5cdb4c22bea67f29f6c06f2c5f928400f57fb3da7521e8aa8c4ec

See more details on using hashes here.

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

Hashes for mett-0.0.1a2-py3-none-any.whl
Algorithm Hash digest
SHA256 8094f6ca7c49b22ec33d5b1246236b69f09179cab9d5298ff183847c8a47f641
MD5 e3e7289ae0f276cbc2395df887691434
BLAKE2b-256 8fd2c9f7328b7c9df6be4e5a6eb9d837f836e652d99f7fb6a5a942a9e9cf4557

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