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.1a1.tar.gz (87.3 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.1a1-py3-none-any.whl (188.1 kB view details)

Uploaded Python 3

File details

Details for the file mett-0.0.1a1.tar.gz.

File metadata

  • Download URL: mett-0.0.1a1.tar.gz
  • Upload date:
  • Size: 87.3 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.1a1.tar.gz
Algorithm Hash digest
SHA256 e16724991cd1e829a60b2ad085519f5a2919735ba680de7165393a38cc010883
MD5 4a4f7e004cc6ee27521504d4b2455698
BLAKE2b-256 5152a80c9586d37e25bc86c343901fbe200a0bd87aca247929cf46d76ffac660

See more details on using hashes here.

File details

Details for the file mett-0.0.1a1-py3-none-any.whl.

File metadata

  • Download URL: mett-0.0.1a1-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.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 a41c2883becc24cdd8c47879e9ddd07bcd3c49e64afc0c641f19a4825e7a4cc5
MD5 e197e6b6a8b84c91443522995bbd1607
BLAKE2b-256 1dd2410c504b8a8252faeec3ab7f36a1476ab3df15f857b86bc3a442a250d69e

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