GA4GH DRS Client

raw JSON →
0.1.7 verified Sat May 09 auth: no python

A Python client for retrieving omics data from Data Repository Service (DRS) web services compliant with the GA4GH specification. Current version is 0.1.7. Release cadence is low; the library is in early stable development.

pip install ga4gh-drs-client
error ModuleNotFoundError: No module named 'ga4gh'
cause Package not installed or installed in wrong environment.
fix
Run pip install ga4gh-drs-client in the target Python environment.
error ImportError: cannot import name 'DRSClient' from 'drspy'
cause Trying to import from the wrong module; many users expect the package name to map directly.
fix
Use from ga4gh.drs.client import DRSClient.
error ga4gh.drs.client.exceptions.DRSException: Access denied
cause Missing or invalid authentication token.
fix
Set the DRS_AUTH_TOKEN environment variable with a valid token, or pass auth_token to the constructor.
gotcha DRS IDs should be passed as full DRS URIs (e.g., drs://hostname/object-id) not plain IDs.
fix Prepend 'drs://' to your object ID if missing.
gotcha The `auth_token` parameter must be set either in the constructor or via the DRS_AUTH_TOKEN environment variable; otherwise anonymous access is attempted.
fix Set DRS_AUTH_TOKEN environment variable or pass token explicitly.
deprecated The `get_object_access_url()` method is deprecated in favor of `get_object_access()`.
fix Use `get_object_access(object_id, access_id)` instead.

Connects to a DRS server, retrieves object metadata, and downloads its contents.

from ga4gh.drs.client import DRSClient

# Initialize client (token can be passed via env var DRS_AUTH_TOKEN)
client = DRSClient(base_url='https://drs.example.com', auth_token=os.environ.get('DRS_AUTH_TOKEN', ''))

# Access an object by its DRS ID
object_info = client.get_object('drs://example.org/object-id')
print(object_info['id'])

# Download object bytes
data = client.get_object_bytes('drs://example.org/object-id')
print(f'Downloaded {len(data)} bytes')