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.4.12-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12 Windows x86-64

ont_pybasecall_client_lib-7.4.12-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.4.12-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.4.12-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.4.12-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.4.12-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11 Windows x86-64

ont_pybasecall_client_lib-7.4.12-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.4.12-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.4.12-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.4.12-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.4.12-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10 Windows x86-64

ont_pybasecall_client_lib-7.4.12-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.4.12-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.4.12-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.4.12-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.4.12-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9 Windows x86-64

ont_pybasecall_client_lib-7.4.12-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.4.12-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.4.12-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.4.12-cp38-cp38-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.8 Windows x86-64

ont_pybasecall_client_lib-7.4.12-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.4.12-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.4.12-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5ce56cf7173abbf87522cbe4256af8168b07b3414001a102b8c7b1f81e8b1a68
MD5 acf5fdc8f76a1868449cd4fdecb49e6e
BLAKE2b-256 d9f4d030aa57f815efb5effbd8b574be0452c83351eec7fb3b59f70465d0fe51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d02c34d9a36ee1b1e486cbd3a80a6c751d5f39e16f34d77bf1b653726528293d
MD5 1ae9550beb99ee2e8f0105f50f253241
BLAKE2b-256 59e1eeebecfc281c163cc90bbe254e82ce398f498ea80e1194ce5b0e164e34ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 77f2c0fc4dc0fe20e771800ebbeeed5abac1600d7376c8c74a5da6f6eed83a44
MD5 a84a2368a6a95c42a7710195ae563990
BLAKE2b-256 42c50b1215812175f91fa471cebc306b035f72fe2cbdee95e1bc113d1b8708c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9bb728d6c9915381d88269a8ab22b0012d58c69fa1d85a2637b832d350cc0828
MD5 2f868ec561e9eec829f1cba50bdb75f1
BLAKE2b-256 e283033ab8dd523c42cdabb222d7a18a813a6ababa325f00f9db53b7b1ee8a5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ada41de47c221d119291022deaf5cb0c5c16fbc695c8a90081abd558eaabd0f8
MD5 2b9ff40d62f332955ca8b4e41d58f954
BLAKE2b-256 955fe3658a3ec8df491f5b7cce49a633efa0f59975652b4086e90c23fdd96cfb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2d81763290316aab947712fa11430818be0e30cc7721ea5a0c134b2a393d6c5e
MD5 64d7ac96889b39a10735af540ec5868b
BLAKE2b-256 d3106d00ebd955323f16be66d58c38ef2491fa6f9e555772a4ccb7be3efec379

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6d7530e82599cdbb24482629cfecb9db347d7a863f01ec8c9b820563f512f0c5
MD5 fee515046d0db56c1b6217c3dac3f50f
BLAKE2b-256 ceb9a04f3d0a2766bea74d5c9d46b9b02582c56b576cbd813b989ba32d3e10eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fbb49694c12d20a645fb7113873dd2dc30b3b9f4395c4396b9277505eb1637ad
MD5 3750aa097a27be4bed1a8a78aee293e4
BLAKE2b-256 49636ff70ca848f463f645293b299d6f9d8bdb259ba426efebedacd6b87f519e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 462e139c27da0c4c7201e8d6725e11769f901a69a0448f219ad34797a5a38ff5
MD5 2f2a52fe37072ccd3ed6b6a2f991fbd4
BLAKE2b-256 469edaf8663acd7b94888acaec0d3c02955b7bc6c4a5a6180022341f590b86cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 f1f279d2e7db304934e5d6d4e943da47aec29ada891bdef73c348dc7feb057da
MD5 be1a6e928ff58fd70e37ab7f79bb851d
BLAKE2b-256 c9f494eceae5a0adbace22d4cb48055929f4cda61f441acfc61d1ae3e9ca6e74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 45bf44a578284323b2791e78c53a2fd050b4932958c93c17afc2820f1a1c6353
MD5 6f3d6ce2e69c26d7e354433fb45735c4
BLAKE2b-256 92e287db10635872423e66784f3a2356695a3057a634de1ec7f1efb448164ab1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d6e776e8bcba3387aa994020a9b2d2e2309e724c1e0154db7198242b9cf8c1f1
MD5 d47c570c1f8e9e777d8250281c97a3a2
BLAKE2b-256 5d4f457e0f2ad849f25f9fd3be3902d6ada99595c16ea900af4e6a5c17c2dbec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6cfa007c23d7132947a8836bcc79c962cb585fc4a4a22c50b9e81f7a157fa9fd
MD5 e408026977de55523a402336e19c7fcb
BLAKE2b-256 22860ae97d85e54d102e698970d69748197992a3010706df699f8c7996dae448

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab464209966026727dcb1c8a23cb98363cbe0dd7410b57d0bd1b91396e9c049e
MD5 220970efa8c3cafc3841751baa57b61a
BLAKE2b-256 b40a8d721ecff857db25688302ff70b91a23b4bbe72bdf405982f548d80f1376

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 675d63f66523ff57de977d8992b70b848bce565364ac82ecc691d9fbd0fe864a
MD5 ce88a480852bc73f046cca3885381520
BLAKE2b-256 f3d30c5754ee3d3b62beebe9b7cd71241589ae0e0150a62535e20f675bc121b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5950859c91a4adcc705974a6517bbe1b18c50cc1b84bdad587ea1e1ae23b03ea
MD5 c9db484ca5f5127892966b3a85ccc484
BLAKE2b-256 6200d7cbccd0870a1660f28a36a3aba1460fda0ee12e2d91edbcb812b3549c0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fc505a26793a1cec0253f469e5d0d92c1e5b6e431dfb5a9c22ec2ecae69eecc3
MD5 4652f2815186c6ba3ff4e4d73ac281c6
BLAKE2b-256 a15ccea92fe0674705dc1f9b51b6834d5a3bc5a319ae206269f2e6df0154ea64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 46e93993b27b456a2442e97a3d354e3b62a41b5261b14e6be72c9b0bda986f8e
MD5 9956910a0fd0495dc34837c0961e4f5c
BLAKE2b-256 47bd6e71c01848d9c022cdf7f9e1cc04ad7250edf069649a30f257b51cab6f1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d53ca84c84dcb63bb1dbd24cd2c285ea6216c98c47b38edc6bcecd9d5d625b43
MD5 f41a69e0829dd564a6e605d0a371219b
BLAKE2b-256 fb1d7444b8cde5737801a9f3a3884afabb98f7de21dc2846815d96622572840f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ef69c6c452e090827ded119c0113c83f605a4f64cb95936c6a842fa2ee86751e
MD5 d99bd5564f573055751af2c4b00ba1a3
BLAKE2b-256 e1477bb10b2d0532f74a2a4e988be197c96289aa7fee87c4827a2b7d4c968e2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5a96e79b13b1896b5d03365642c1f6e474123d26cc4f0279a34a07be8a060f12
MD5 beaaefa51c005edf733fc735b001ab79
BLAKE2b-256 3fa7539861964441fdf802d1b2db7991438a7fa1e3e483ea773125451498a41c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.4.12-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 4510cdcb86f2434879feb125e4e19d8e7506698e7ae7f69c67457473a72cff8e
MD5 4ebd353f82e23726cf55b6b1235e22c2
BLAKE2b-256 477d9b4c28edc214f45a4ec5c519f7d14eb3c6f072b4ebac1dbd19b4b3b0d5d8

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page