Skip to main content

Python SDK for Valthos API

Project description

Valthos Python SDK

Python SDK for the Valthos bioinformatics platform.

Installation

pip install valthos-sdk

Quick Start

Authentication

First, authenticate with your Valthos account:

import valthos_sdk

# Interactive login (prompts for credentials)
session = valthos_sdk.login()

# Or provide credentials directly
session = valthos_sdk.login(root_domain="valthos.com", token="your-personal-access-token")

Credentials are stored securely in ~/.valthos/credentials.

Working with Workspaces

# List your workspaces
workspaces = session.list_workspaces()
for ws in workspaces:
    print(f"{ws.name}: {ws.status}")

# Get a specific workspace
workspace = session.workspace(name="My Project")

# Create a new workspace
workspace = session.create_workspace(name="New Analysis", description="My analysis project")

File Operations

# Upload a file
workspace.add('/local/path/data.csv', 'data/input.csv')

# List workspace contents
files = workspace.list()
for f in files:
    print(f"{f.path} - {f.size} bytes")

# Create folders
workspace.create_folder('results')

# Copy, rename, delete
workspace.copy('data.csv', 'backup/data.csv')
workspace.rename('old_name.txt', 'new_name.txt')
workspace.delete('temporary_file.txt')

Analysis Tools

Run bioinformatics analyses through the tools interface:

# Fitness analysis
fitness = workspace.tools.Fitness(
    input_path='proteins.parquet',
    output_path='results/fitness.parquet'
)

# Validate inputs
validation = fitness.validate()
if validation['status'] == 'valid':
    # Get runtime estimate
    estimate = fitness.estimate()
    print(f"Estimated time: {estimate['estimated_time_minutes']} minutes")

    # Run the analysis
    result = fitness.run()
    print(f"Job ID: {result['job_id']}")

# Sequence profiling
profiler = workspace.tools.SequenceProfiling(
    input='protein.fasta',
    output='results/profile.json',
    methods=["world"]
)

# Genome profiling
genome_profiler = workspace.tools.GenomeProfiling(
    input='genome.fasta',
    output='results/genome_profile.json',
    min_orf_length=90
)

API Reference

Session Methods

  • session.list_workspaces(status=None, limit=None, offset=None) - List workspaces
  • session.workspace(name=None, rid=None) - Get a workspace by name or ID
  • session.create_workspace(name, description=None) - Create a new workspace
  • session.archive_workspace(name=None, rid=None) - Archive a workspace

Workspace Methods

  • workspace.add(local_path, workspace_path=None) - Upload a file
  • workspace.list(path=None, offset=None, limit=None) - List contents
  • workspace.create_folder(path) - Create a folder
  • workspace.rename(old_path, new_path) - Rename/move a file or folder
  • workspace.copy(source_path, dest_path) - Copy a file
  • workspace.delete(path) - Delete a file or folder

Available Tools

  • Fitness - Protein fitness inference using ESM2-based models
  • SequenceProfiling - Multi-method analysis of protein sequences
  • GenomeProfiling - ORF detection and protein profiling from genomes
  • SequenceSearch - MMseqs2-based protein similarity search

Error Handling

from valthos import (
    ValthosError,
    AuthenticationError,
    TokenExpiredError,
    APIError,
    WorkspaceNotFoundError,
    FileUploadError
)

try:
    workspace = session.workspace(name="NonExistent")
except WorkspaceNotFoundError:
    print("Workspace not found")
except AuthenticationError:
    print("Please login again")

Requirements

  • Python 3.8+
  • requests
  • pydantic

License

MIT License - see LICENSE for details.

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

valthos_sdk-0.1.1.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

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

valthos_sdk-0.1.1-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for valthos_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f0b99517d8a1d6d18aee5ac426b083b1b62473672ac312f4bf43b4badbac82a1
MD5 c382d4988561dead045e46af45152248
BLAKE2b-256 5cf5a57a83a40c3ec4d1b82f2c4f6e4e6c36b9b4f4a6b0e79bea9d369f0912cb

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for valthos_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53c50c80bad41b98ea973868a3201476b8e41313ccf076975877b9f6064cfdca
MD5 2c650eddb0a85c7132419e44bdd5886e
BLAKE2b-256 c5dae3e8eb154b52c21fdab782c524b20d896c4741d0b517929bc2bc942ec274

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