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()

It is also possible to start the PyBasecallClient using a dorado model set, e.g:

from pybasecall_client_lib.pyclient import PyBasecallClient

client = PyBasecallClient(
    "127.0.0.1:5555",
    "dna_r10.4.1_e8.2_400bps_hac@v4.3.0|dna_r10.4.1_e8.2_400bps_hac@v4.3.0_5mC_5hmC@v1|",
)
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.9.8-cp313-cp313-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.13Windows x86-64

ont_pybasecall_client_lib-7.9.8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

ont_pybasecall_client_lib-7.9.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

ont_pybasecall_client_lib-7.9.8-cp313-cp313-macosx_13_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.13macOS 13.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

ont_pybasecall_client_lib-7.9.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ont_pybasecall_client_lib-7.9.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

ont_pybasecall_client_lib-7.9.8-cp312-cp312-macosx_13_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 13.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

ont_pybasecall_client_lib-7.9.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

ont_pybasecall_client_lib-7.9.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

ont_pybasecall_client_lib-7.9.8-cp311-cp311-macosx_13_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.11macOS 13.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

ont_pybasecall_client_lib-7.9.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

ont_pybasecall_client_lib-7.9.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

ont_pybasecall_client_lib-7.9.8-cp310-cp310-macosx_13_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.10macOS 13.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

ont_pybasecall_client_lib-7.9.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

ont_pybasecall_client_lib-7.9.8-cp39-cp39-macosx_13_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.9macOS 13.0+ ARM64

File details

Details for the file ont_pybasecall_client_lib-7.9.8-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 86d80a0fe94fa170fd69723c3c632fdc6abb52b8ac8a2b24c80a35768f4229a4
MD5 30049ca0bc1178534ad55250d69dea25
BLAKE2b-256 66c9b4a92b6501892883ee062b0dc5b48832a9a1762e32af9aa63593d2cac459

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.9.8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6096195be98bff22e6cec709a057e8acb0777b2721e2f1bb0bbaf1996953bd4e
MD5 e6ee09c4684ce7a875d8cc115423a61e
BLAKE2b-256 a8cad5a1789d877586d00c3b20ced983259e18f78eeb2292b1be3bebd289706f

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.9.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 02d23cb4c64256c880cc0b3fd626d4e1f6bd23fb6fa2b66766a2422734a1abe5
MD5 3c7f084d74b9f025e5610213aa4db30f
BLAKE2b-256 773c179dce9df0f9ebfa55ad93a4ba2aa65d635e2d1069d39bac953320118bf4

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.9.8-cp313-cp313-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp313-cp313-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 00bd33cf83027c7fc030729ff950d35b933c2e00c0fcfbae051eb403df0ac438
MD5 c6b72858dd778f0b71af7bb7646e103a
BLAKE2b-256 901946ae922d125a84e37178569df9c1fa54fec2050236f5609974d64e034c58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7ac241dfe2abe1676fba23560cba27d4aafc250ac34a91770d21a6d51b6c183e
MD5 2a3be493078df3f8877fc675ab9d300e
BLAKE2b-256 829ea43194b79281e7c3aee4f852dd0f498c4c57b8d000afba6abf06b3c5ab7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c5ca190384a58f92b41648f41b045d005fc33ee8dfbe880ef621191a7132025b
MD5 954f5a5bec84980368df07d5f7eaf7f2
BLAKE2b-256 5cb5b5500e95f28a6331e727a353f218396343dcc664284e0cec5ebabe6c8fd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a215f4c035dfd676efc05469cce7fad6e684784aceaeb41af17d04b95add3c3f
MD5 ec6213b591f72d98f6e4cee1f1c35a2d
BLAKE2b-256 655dbf83e25acc048d3dd5cd457413d7d98233d286d9d208afbd8080b410b73a

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.9.8-cp312-cp312-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp312-cp312-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 23c0983316942fddf83013b8362edc9753ede1dd26960b63862a86cfdfa0a9c6
MD5 a41ea094476b0d67b7966d1318b7c48a
BLAKE2b-256 df1ef8e20995b37f865001d3506a26930ae21a27939ce537ff411c4e16b47084

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a219bd2660f9890cde95bd32e7d10e7bfceeb3bb6b7faf3e45c78a93840c3ab1
MD5 656bcee772bb461d5d3abdcafbac5889
BLAKE2b-256 0b8e3fd5b6018cb4ad262e818d8b4c542e28ddb6358566c028efd6fcbaa684c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 455681814e97750526fc75f4b33731a7614a72e52260536c7075a238652b429e
MD5 4067b846b9d6bf24c6c4ed643a597b6d
BLAKE2b-256 986cd0527b5f3de70c57a1572c4d64b00c74ff9db0b81a20a44107960c136721

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4d91d44854221f2b4ce52b1bc548aa1224514e035e637551d2fb4ed6c339d24b
MD5 4cf2a85e96611341794c921168b6b693
BLAKE2b-256 082b5a048339a198b1ee9a6cbe947edc874d7d38e6a10c5a2c18d79804a13ea4

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.9.8-cp311-cp311-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp311-cp311-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 7bb0bfe1449785422880fbfa04a50abf8ab0d6b110cde9f659a372a3eef34d58
MD5 125cb73bcb5d57d754ef9be598e7e0cf
BLAKE2b-256 bea44e8d385f8f06635d6b37c585a5df7701a585936916bb13816bef7d79cac5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 597fc852eb7c64c9462206d266d5e73f957520bb8d0f9acd224a9c9968c2af05
MD5 76de4df6b13dcde92c8eec3a0b472010
BLAKE2b-256 c8e23932c324d3984db53c98fdc2af63b82ea4755885cdaaf60dc034f485dfe8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b834cf395f2739db43d329f3e6e2249e2fbe334c7fdc5af8e7ed0ab6ec6edd69
MD5 cd7d8d7a977099e9a5f9817d221dfbcc
BLAKE2b-256 881d02aba9c6e701719118ad774d7435edc44cfde6de7d1a6b6d08a05f686a18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4dc04d8c8c6e4c50ed4bb3d609755029540c056986c9781a9e8393b25681e8ed
MD5 5431feedc5dc13137cc69567e01e2bbc
BLAKE2b-256 335e051d4ce01ca84fc155fdf90efdd8a89e19601e81d2d47fcdb759bbb0949e

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.9.8-cp310-cp310-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp310-cp310-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 b37d578e0d66a721781e12af9796e2f5c2600ca864f2ed63397839af2c430bc2
MD5 0cba6715501dcae7699be0fe22a9c8f8
BLAKE2b-256 ca12a5d5137fc69ae80b2de2cba9d69dec81d6475d5e14439393845eaf62ad61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6717d41bb52d4aa1b8a3af59f67141c19ed3557d3f1cca1faf4fb726888af392
MD5 56b7ec62a2b3df3729c67ab56b399955
BLAKE2b-256 2da93b8fd5420c5f781bcfe3fa08cfcf67d2a81078ec8aa6db49f827f9cdb238

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b083a36f55d379fd3ffaf3596feea3dd3ae23f8821bf9d46d1476dac13afdbb8
MD5 766f27e5ad2b601800c4b4e214570da7
BLAKE2b-256 a03c36ab912f282589d2f53cf489eb84a55d1e99cd388188bc974407b9d7f933

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.9.8-cp39-cp39-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.9.8-cp39-cp39-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 e692a1f2f29a6ac2ca4d8c8cc3ab723949e150d7c16aecf71addfbd8bba63d7f
MD5 d8046a73755d991b07a04dedb5e1feaf
BLAKE2b-256 f2063427cd9078b58af396401ef3be21bb29c75d36ec3698b9227b2b209947e0

See more details on using hashes here.

Supported by

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