Connection Options

The DnaerysClient constructor accepts several parameters to control connection behaviour.

TLS (default)

By default, the client creates a secure TLS channel using default SSL credentials:

from dnaerys import DnaerysClient

# Uses default SSL credentials
client = DnaerysClient("db.dnaerys.org:443")

Custom TLS credentials

Pass your own grpc.ChannelCredentials for custom certificate authority chains or mutual TLS:

import grpc
from dnaerys import DnaerysClient

creds = grpc.ssl_channel_credentials(
    root_certificates=open("ca.pem", "rb").read(),
)
client = DnaerysClient("db.dnaerys.org:443", credentials=creds)

Plain HTTP (no TLS)

For local development or testing without TLS:

from dnaerys import DnaerysClient

client = DnaerysClient("localhost:50051", tls=False)

Note

Providing credentials with tls=False raises ValueError.

Timeouts

Default timeout

Set a default timeout (in seconds) for all RPC calls:

from dnaerys import DnaerysClient

client = DnaerysClient("db.dnaerys.org:443", default_timeout=30.0)

Per-call override

Every method accepts a timeout keyword argument that overrides the default:

result = client.health(timeout=5.0)

If neither the per-call nor default timeout is set, calls have no timeout (they will block until the server responds or the connection drops).

Reference assembly

The default reference assembly for all queries is GRCh38. Set a different default at construction time:

from dnaerys import DnaerysClient, RefAssembly

client = DnaerysClient(
    "db.dnaerys.org:443",
    assembly=RefAssembly.GRCh37,
)

Or override per-call:

from dnaerys import Region

result = client.count_variants(
    region=Region("chr17", 7661779, 7687546),
    assembly="GRCh38",
)

Assembly values can be passed as RefAssembly enum members or case-insensitive strings ("GRCh37", "grch38").

Context manager

DnaerysClient implements the context manager protocol. Using with ensures the underlying gRPC channel is closed on exit:

from dnaerys import DnaerysClient

with DnaerysClient("db.dnaerys.org:443") as client:
    result = client.health()
    print(result.status)
# Channel is closed here

You can also close manually:

client = DnaerysClient("db.dnaerys.org:443")
# ... use client ...
client.close()

Constructor reference

class dnaerys.DnaerysClient[source]

Bases: object

Client for the Dnaerys genomic data service.

Parameters:
  • target (str, default: 'db.dnaerys.org:443') – Server address in host:port format.

  • tls (bool, default: True) – If True (default), create a secure TLS channel.

  • credentials (ChannelCredentials | None, default: None) – Custom TLS credentials. If None and tls is True, default SSL credentials are used.

  • options (dict[str, Any] | None, default: None) – gRPC channel options as {key: value} pairs.

  • default_timeout (float | None, default: None) – Default per-call timeout in seconds. None means no timeout.

  • assembly (RefAssembly | str, default: <RefAssembly.GRCh38: 2>) – Default reference assembly for all queries. Can be overridden per-method.

  • Usage::

    with DnaerysClient(“db.dnaerys.org:443”) as client:
    for v in client.select_variants(region=Region(“chr1”, 1000, 5000)):

    print(v)

__init__(target='db.dnaerys.org:443', *, tls=True, credentials=None, options=None, default_timeout=None, assembly=RefAssembly.GRCh38)[source]
Parameters:
Return type:

None

classmethod __new__(*args, **kwargs)