Skip to main content

Python bindings for the BasecallClient library.

Project description

ont-pybasecall-client-lib

ont-pybasecall-client-lib provides python bindings for connecting to a Dorado basecall server. It allows you to interact with the server to do anything you could normally do using the ont_basecall_client. This includes:

  • Basecalling

  • Barcoding / demultiplexing

  • Alignment

For example:

>>> from pybasecall_client_lib.pyclient import PyBasecallClient
>>> client = PyBasecallClient(
    "127.0.0.1:5555",
    "dna_r9.4.1_450bps_fast",
    align_ref="/path/to/index.mmi",
    bed_file="/path/to/targets.bed"
)
>>> client.connect()

Getting started

ont-pybasecall-client-lib is available on PyPI and may be installed via pip:

pip install ont-pybasecall-client-lib

ont-pybasecall-client-lib requires an instance of the Dorado basecall server is running. ont-dorado-server may be obtained from the Oxford Nanopore Community

The version of ont-pybasecall-client-lib should exactly match the version of ont-dorado-server being used. You can find your ont-dorado-server version like this:

$ <location of dorado_basecall_server>/dorado_basecall_server --version

For example, this Dorado basecall server is version 7.1.1:

$ ./ont-dorado-server/bin/dorado_basecall_server --version
: Dorado Basecall Service Software, (C) Oxford Nanopore Technologies,  Limited. Version 7.1.1+effbaf8, client-server API version 16.0.0

Install a specific version of ont-pybasecall-client-lib like this:

pip install ont-pybasecall-client-lib==<version>

Dependencies

ont-pybasecall-client-lib requires numpy in order to run. In order to use included helper functions for reading data from fast5 and/or pod5 files it is also necessary to manually install ont-fast5-api and/or pod5:

pip install ont-fast5-api pod5

Documentation and help

Information on the methods available may be viewed through Python’s help command::

>>> from pybasecall_client_lib import pyclient
>>> help(pyclient)
>>> from pybasecall_client_lib import client_lib
>>> help(client_lib)

Interface / Examples

ont-pybasecall-client-lib comprises three Python modules:

  1. pyclient A user-friendly wrapper around client_lib. This is what you should use to interact with a Dorado basecall server.

  2. client_lib A compiled library which provides direct Python bindings to Dorado’s C++ BasecallClient API.

  3. helper_functions A set of functions for running a Dorado basecall server and loading reads from fast5 and/or pod5 files.

Starting a basecall server

There must be a Dorado basecall server running in order to communicate with it. On most Oxford Nanopore devices a basecall server is always running on port 5555. On other devices, or if you want to run a separate basecall server, you must start one yourself:

from pybasecall_client_lib import helper_functions

# A basecall server requires:
#  * A location to put log files (on your PC)
#  * An initial config file to load
#  * A port to run on
server_args = ["--log_path", "/home/myuser/basecall_server_logs",
               "--config", "dna_r9.4.1_450bps_fast.cfg",
               "--port", 5556]
# The second argument is the directory where the
# dorado_basecall_server executable is found. Update this as
# appropriate.
helper_functions.run_server(server_args, "/home/myuser/ont-dorado/bin")

See the the DOCUMENTATION.md file in the ont-dorado-server archive for more information on server arguments.

Basecall and align using PyBasecallClient

from pybasecall_client_lib.pyclient import PyBasecallClient

client = PyBasecallClient(
    "127.0.0.1:5555",
    "dna_r9.4.1_450bps_fast",
    align_ref = "/path/to/align_ref.fasta",
    bed_file = "/path/to/bed_file.bed"
)
client.connect()

Note that the helper_functions module requires that ont-fast5-api and/or pod5 is installed.:

from pybasecall_client_lib.helper_functions import basecall_with_pybasecall_client

# Using the client generated in the previous example
called_reads = basecall_with_pybasecall_client(
    caller,
    "/path/to/input_folder"
)

for read in called_reads:
    read_id = read['metadata']['read_id']
    alignment_genome = read['metadata']['alignment_genome']
    sequence = read['datasets']['sequence']
    print(f"{read_id} sequence length is {len(sequence)}"
          f"alignment_genome is {alignment_genome}")

Basecall and get states, moves and modbases using BasecallClient

In order to retrieve the movement dataset, the move_enabled option must be set to True. NOTE: You shouldn’t turn on move_enabled if you don’t need it, because it generates a LOT of extra output data so it can hurt performance.

options = {'priority': PyBasecallClient.high_priority,
          'client_name': "test_client",
          'move_enabled': True }

client = PyBasecallClient(port_path, 'dna_r9.4.1_e8.1_modbases_5mc_cg_fast')
result = client.set_params(options)
result = client.connect()

called_reads = basecall_with_pybasecall_client(client, input_path)

for read in called_reads:
    base_mod_context = read['metadata']['base_mod_context']
    base_mod_alphabet = read['metadata']['base_mod_alphabet']

    sequence = read['datasets']['sequence']
    movement = read['datasets']['movement']
    base_mod_probs = read['datasets']['base_mod_probs']

    print(f"{read_id} sequence length is {len(sequence)}, "
          f"base_mod_context is {base_mod_context}, base_mod_alphabet is {base_mod_alphabet}, "
          f"movement size is {movement.shape}, base_mod_probs size is {base_mod_probs.shape}")

Glossary of Terms:

Dorado - Oxford Nanopore Technologies’ production basecaller, which translates electrical signals measured from nanopores into DNA or RNA bases.

Fast5 - an implementation of the HDF5 file format, with specific data schemas for Oxford Nanopore Technologies sequencing data.

Pod5 - a file format for storing nanopore dna data in an easily accessible way.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

ont_pybasecall_client_lib-7.6.8-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12 Windows x86-64

ont_pybasecall_client_lib-7.6.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

ont_pybasecall_client_lib-7.6.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

ont_pybasecall_client_lib-7.6.8-cp312-cp312-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

ont_pybasecall_client_lib-7.6.8-cp312-cp312-macosx_10_15_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.12 macOS 10.15+ x86-64

ont_pybasecall_client_lib-7.6.8-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11 Windows x86-64

ont_pybasecall_client_lib-7.6.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

ont_pybasecall_client_lib-7.6.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

ont_pybasecall_client_lib-7.6.8-cp311-cp311-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

ont_pybasecall_client_lib-7.6.8-cp311-cp311-macosx_10_15_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

ont_pybasecall_client_lib-7.6.8-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10 Windows x86-64

ont_pybasecall_client_lib-7.6.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

ont_pybasecall_client_lib-7.6.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

ont_pybasecall_client_lib-7.6.8-cp310-cp310-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

ont_pybasecall_client_lib-7.6.8-cp310-cp310-macosx_10_15_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

ont_pybasecall_client_lib-7.6.8-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9 Windows x86-64

ont_pybasecall_client_lib-7.6.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

ont_pybasecall_client_lib-7.6.8-cp39-cp39-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

ont_pybasecall_client_lib-7.6.8-cp39-cp39-macosx_10_15_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

ont_pybasecall_client_lib-7.6.8-cp38-cp38-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.8 Windows x86-64

ont_pybasecall_client_lib-7.6.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

ont_pybasecall_client_lib-7.6.8-cp38-cp38-macosx_10_15_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6beec2e3fccd76ca5065a6665e6f8890527c1381f550d747a81f4fe14cae3883
MD5 74058dbd47df9dd8758b3f07fc571cd4
BLAKE2b-256 3b9a4244be531811c4f73220119fb7f7ad8ced35085c4c4cdf44be810a80b032

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3ee771f02d27eb2c71ba6d3d3a2f16d180ff04ec390c83ebf537ffbc5b5f2a02
MD5 93ffc35ea7c4cad3efc4c83b7b4d0f95
BLAKE2b-256 f48374d9fe7f2bf088dc7abaa3c8cc25d88e8b7a4dacffd56aaac35ee390e4fe

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b6e3531e094f7d9b9ff716ce1b50e725b746d1e409c4064eedd469269202e2d5
MD5 8fbc35d5c0a904a9fe61d9633be64496
BLAKE2b-256 bb1fd97310b996d1dd6fa3d74ec9f0d8abe8488d1bcf8832e0c5a8d4d3f2d8e1

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f8d2ae00a2bc18552e7f9ec4e7597aa9d89b11676b0fe948f81900e4bac0a0a
MD5 c86c89283dfacc784b249e34c4eca4ee
BLAKE2b-256 8349e55e8884e37dc72b7e5a6fb00adffc0026582796ab1362d00d061b307a90

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 21a8d6909ce531a586ccae145ba620cd69c78f342269c077602e60bd8bc26bc6
MD5 e0a12f3b59c827ae9d7be567a661ce45
BLAKE2b-256 fab189c2b0dfb93af9e95a93a173518e4b848b5f3a7487a8ea971364b730ec12

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bef34ed844fe201f40d7cc1e51684039f0233fd30ba8e94920553c94aaeb4b0b
MD5 b6f14bed7b579ea963a5abd8013d5ce7
BLAKE2b-256 1ae0499d16beb4a3eaf2072a216c7cbb11b53c54a25fc39de9cfc1b6e4791d59

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cc7c08b2ec90abf57830dd58e48596db68882adcce5a30db8900809fc11413c1
MD5 f5cbfdafb194c0984665bad40c95fcf6
BLAKE2b-256 c4b0ec7082c672abd1dd171d62e222ec4c250b2e834f38cc1ad625eb33003bea

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f3bdbefc0b6f7350fa11ccb28adbf0a5557f5cadbe7f2e068a58345a427d23cc
MD5 fe7eb77dd5bf5187f0e4172ca870c53a
BLAKE2b-256 516ffe2a8c53bb56d72f24c53c8633b0a37f3ce50898bd6b1260572f07f860c2

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b8ae62854cfe5c37c4bda3cba0c18f643e5c1096ba47ff1f5f022093cb1baf45
MD5 1c6224422326664008cae191922309f0
BLAKE2b-256 ea26dcb9f5c1c5561c008db847f0d0630d325bd5efaf055b03dca00494606aed

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 2ed574af2ee58ada015d2a0281110ab3fe3afa8853801ba8a5ca23031eab4876
MD5 737bf99de429f6bf1581f249f68c6d91
BLAKE2b-256 b584e0af2d4167b682ec6266a688fd4ffa9c86fec5bc4e77b57d724e1cff86de

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7ce1a430cac21f5a73ef40a62af8b596a3600a88471dea78a4a3a7e2184b58ca
MD5 272cca7f81ae92470f06b4ad3f24ff9b
BLAKE2b-256 c7d8553dfeed194cff1256211ea386c09b7a690ec210d70b4f24d01162c02294

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 62671eb7622ad746086fb65d6a2f5e084fba61667dec5be6bb72773ee7544410
MD5 f961c661d8cd82ec4acb53bd6bae6136
BLAKE2b-256 03e743d2f2a58edbe3311c5a9b2791ab02666ad6108a2f11d5fb3cc984210d12

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 13cd917b4ef5d980b3e836954fd4f6002c692a112ff8a764f731eb8fac686fb9
MD5 a611597f69b95bf4b1e410d8e67cd674
BLAKE2b-256 0a42b10d553eaf962d1911dd309902dda8e311be2c14f9d143078b2f2f2029f0

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f28813ebb5da0bd21f1ea0f20ddcd5cdc34f75526455fa0b2af4e55fbc0228a
MD5 7c7fc02b08bdf46d33e6c6c55bfb0161
BLAKE2b-256 3ad1eeb40914dc48dc90e8186261589a3af9486e09258e175883091b2e97e16c

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 129c98e810dc33f9aa7793e117fe18b63e9ee2d75f930c3692823725abd0ce06
MD5 add0a34221d673c8421dd0f9a0e07404
BLAKE2b-256 bc98dfe6ed41082f0bb270279111075645c8faa5c5a4d712b4f250104c7e77d6

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1a10f43b98db73c2e7cdbb920f9daa8456d54a820d5e2c60bcbde1f1f3d034b4
MD5 cfdced2e8097b37d75973c7637dacf3a
BLAKE2b-256 c6f236f31b5e141b8f1e3f9c7e0dbd3c9d779be6cdbdf66ac1ed8e79f9ebbdf2

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ca19f7ff89fd0cce7eb718192acf937c58f0cb22f97d296a93b83c303cca722a
MD5 bff8729b9f8fe6f119ab3b2725a9ed10
BLAKE2b-256 d7671f41964e4b636ecf4350891b1df0268461fae85027147159b59d6248918b

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cf05a228751aabe4775f0aa72ba4acd75f0c148baf8849e397580504f9070b7c
MD5 9997f570166416f5c96c0d00b5a2dc40
BLAKE2b-256 49f6406f2a328259377cd18fc12292b8d1e3f6a23a5b227d4c0861860f484580

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9402af2e2380573406fc6b05f2f62fca92fb775a58177e68cfbb0843681d758e
MD5 5f37a21eae57c324a69cfa94f9b18158
BLAKE2b-256 5231e4f7608cf7aa937d6db59ae0f1a563cd0c9faa9d1d32bf676501159fe135

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 214eee8a52e43a26ddc2f81e1dd7901261efc0eec4e417fabc6baf83b470faef
MD5 a5ca984859830666f9b969d1f23e06ea
BLAKE2b-256 b1f29e6138d8297297a53d8054e2a17891748d8d80cea1be7f77552fdd9661e1

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4861a17c623392fca7b4200dd70e6ba3e89d0511431d355bc5afa73a37e1e2ab
MD5 6f83a482e8003b4cc4871d588980cba2
BLAKE2b-256 b60e72a55a1b1bfe89d58bf00e3e5926c0e04741f14fd724447b4138483ba02b

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.6.8-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.6.8-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 74794d9e691aa1d389e87429fdf9ed9cd9cfa62ebda2eda035a734d02f9a6c5f
MD5 f4964597dea7fd7f247b59f9554d49b6
BLAKE2b-256 400213ea6399f1373341d92b5a3a9a40b1e8328be58d25758c31aea25721e17c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page