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-dataportal

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-dataportal

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_dataportal-0.1.1.tar.gz (90.1 kB view details)

Uploaded Source

Built Distribution

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

mett_dataportal-0.1.1-py3-none-any.whl (188.2 kB view details)

Uploaded Python 3

File details

Details for the file mett_dataportal-0.1.1.tar.gz.

File metadata

  • Download URL: mett_dataportal-0.1.1.tar.gz
  • Upload date:
  • Size: 90.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for mett_dataportal-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e78d10220c0f10f16a60a1754a9e069a3d623063481cbb27f621e583c47902d6
MD5 1dc96ab56f3fcda24ceba8de87bb15de
BLAKE2b-256 17e2aad2a56025f7b65f96dd84c2ec24897c6c0539bb4230fb256cd5d85f4bd0

See more details on using hashes here.

File details

Details for the file mett_dataportal-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mett_dataportal-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 188.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for mett_dataportal-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a65d5f2c122758071eaa4bde26033eb5d25115da9d4dced1b80eaacd2cf0f3a
MD5 229aa165060560712c47fdcc6e3e11c9
BLAKE2b-256 e9a98316fc7eb7dce0e2ad6f4b6c557cd7812f3d8fef4de82fc8dcf1df5e535f

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