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_r10.4.1_e8.2_400bps_5khz_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 pod5 files it is also necessary to manually install pod5:

pip install 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 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)
#  * A port to run on
server_args = ["--log_path", "/home/myuser/basecall_server_logs",
               "--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_r10.4.1_e8.2_400bps_5khz_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 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_r10.4.1_e8.2_400bps_5khz_modbases_5hmc_5mc_cg_hac')
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.

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

If you're not sure about the file name format, learn more about wheel file names.

ont_pybasecall_client_lib-7.13.6-cp313-cp313-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.13Windows x86-64

ont_pybasecall_client_lib-7.13.6-cp313-cp313-manylinux_2_28_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

ont_pybasecall_client_lib-7.13.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

ont_pybasecall_client_lib-7.13.6-cp313-cp313-macosx_14_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

ont_pybasecall_client_lib-7.13.6-cp312-cp312-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.12Windows x86-64

ont_pybasecall_client_lib-7.13.6-cp312-cp312-manylinux_2_28_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

ont_pybasecall_client_lib-7.13.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

ont_pybasecall_client_lib-7.13.6-cp312-cp312-macosx_14_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

ont_pybasecall_client_lib-7.13.6-cp311-cp311-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.11Windows x86-64

ont_pybasecall_client_lib-7.13.6-cp311-cp311-manylinux_2_28_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

ont_pybasecall_client_lib-7.13.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

ont_pybasecall_client_lib-7.13.6-cp311-cp311-macosx_14_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

ont_pybasecall_client_lib-7.13.6-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10Windows x86-64

ont_pybasecall_client_lib-7.13.6-cp310-cp310-manylinux_2_28_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

ont_pybasecall_client_lib-7.13.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

ont_pybasecall_client_lib-7.13.6-cp310-cp310-macosx_14_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

ont_pybasecall_client_lib-7.13.6-cp39-cp39-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.9Windows x86-64

ont_pybasecall_client_lib-7.13.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

ont_pybasecall_client_lib-7.13.6-cp39-cp39-macosx_14_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c862bdaf917e2f7eff96363dc705634dd509d6da702ca76091895083e8950c96
MD5 9ba04f4c6eb831f10cf767c727638621
BLAKE2b-256 047ba64e27d5b2c182ba1e789840742dbcc045128a93f2615adbb991fd5e95ea

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f171446519a8d79a6689ded424e95aaea69321d4e1a3d518caacace0760a071d
MD5 becf3daebf995f75608a9d7105253e34
BLAKE2b-256 ed78a78d7a578ac7c4a166f9631636d3ac3ceafa0a6df622df8a5b93fdbb843b

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4032a8c8540873ba8219627e4328c7231c091a41a83b64fdb39cf9818e2f414e
MD5 1d7e6a490f34b806c25e6b564e932a80
BLAKE2b-256 34a841dd4a5f86a33013a7eab140676fb50b65bf217033082a3719af1fb74a71

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a923c97383661905fca75bcb5b7dc7833b99629940a026db38b9bd28014fc09f
MD5 e3ff0018d12c7d75d6766d0703227a1e
BLAKE2b-256 7dfa3e35e87d23346fc7876876141ad35f503bb64a8ff93051d81de5f738dbac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4d99e74d9542095705b53dd944f3150484584370362282abf872923a4b94247b
MD5 6dad87e0128ac608f4f35942406a120c
BLAKE2b-256 4462f6074eec3498878a5928a8a286a2015961f741e43049cd8383b2df3f23c2

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 796d1071bfb74663a01ca2386751563f1cf5b3c9e62065ce32865097c38c840d
MD5 cb3f44fc28be9418fb89df9c921bc068
BLAKE2b-256 85b27a756e27be1a4637794b65e8a4cc5bb67a31c5706c71c854fd711d8cdb6a

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5230d117731f91d7530863af64f140f666a38f32e1726dd7fa1a77f0ce9547dc
MD5 c02a64ef53e6576b976455394b8186ca
BLAKE2b-256 17f5471e48b7826c6168669a977b2dd6ff3f09b70a995fcb8a009fe1c7282f13

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 935cdd82ce22293137607b1a92c4046fdcb301c5f84b02e00dfdc59649c7d270
MD5 dfe9ce6b8be39a41d63043ccc8374499
BLAKE2b-256 a5e70eb67634401deefa252fbb4d398705f667e81f9e8af39b0a43d1024f4031

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4984d27b6a8062851844c12eb136579642d5e5241ac48c5bba972bd8bf183353
MD5 b4e7629b7418c2f346ed1c7f89ec520b
BLAKE2b-256 622907857529ee6034391cc7767052634a72b6ae7db2b9578a0aa7b6cd3da487

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 379480d197afa6ae7ae11bc6da914538df9d229bc3e599902282ecf9a81443ad
MD5 5c311af009348345760f1fd2b2bf8b2e
BLAKE2b-256 5d7f3b17a5bca63441bd566ba9b488d509ab8e3648783ca380c6da9128644793

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 05de8be02def39e85729c1a459f99da72247da78094e2c2365741548e07d17f7
MD5 c69e049cebdbdf078fed60ab38e6146e
BLAKE2b-256 54e57f855a2d2b7774885e5627ff69c506a610be3d6b599459ad77af6aca3570

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 0b057d721a8a2b99ffb60b78f41ebbadd889f3813a89e7cbc9a08890844ad21e
MD5 f8f46cc247cdc428732139d550453f87
BLAKE2b-256 78ed5fefe1634edd472673ec806ed32bfab9346daba7693e1e734f1d51dc62f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e7dddecfb7c3a1a343b4808e7b6eb91d7f1458ad9094b8ff555d4d6c370e9f4c
MD5 161e6127781099929b20772b0f2abebf
BLAKE2b-256 62483e7afaf5a4f056998685c32949126cf38e384f392b3495281c7cb4f03108

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6f3d46c66bbfed603adcc153589f09b3386508e1b123d0c425bdc92bc650bf9b
MD5 86ea4c86bb5791577e41d3c6a6c4ed02
BLAKE2b-256 8754f32db1803d7627c90ba273b49700910d6446dd2f95716b23f4e6674ab140

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d1dda524196ff8462cece6d3242d31da6c57138efa817618aa0a15c5843f79b3
MD5 238d52871be854cd58e142b26527c9c9
BLAKE2b-256 ef4d9fa709b26925463f6f965b40468e4edbd8cb4836bed750383c0a501fa4c5

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 72aeb9dc326fe12a1b56c061f89e25b78cba8ce987ca2f1f36223700cf177fb7
MD5 f6bd6e8933c4d83f5a5dae0c7d00c462
BLAKE2b-256 91f176c7fbd735c7afd500b51f8bd0c666a6a3148a3fea979f00f6a65d16a636

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 9f436e19b4790b613f52e6328316f8494b6dd846082903b5135e67f055890d45
MD5 c1fcfd2952542b9bea98a69a443fa9ed
BLAKE2b-256 f91ada5fc44850ec086f4455df74f51087a039b7bf82b68610ebe71c8671f1bc

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5ffe26ed73472b62babe1b6959873730691f5ff4fc580fa4c906b78d33b391c2
MD5 fb026fb8a53410e073fa5503e992c1ee
BLAKE2b-256 e7a767ed67ee91cb63258a8dd369e40a54cda6d3b45c35e7c64caa567b260973

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.13.6-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.13.6-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 383b290d77585b00cd643729bcc8bb595debc82655778722e713a6d268f4c120
MD5 266b2a316510293ff0928316f7b55758
BLAKE2b-256 fa8b9b145be48c7ab929fd7aa654096ce04fa6e722224c8e0c0aaa3c1d7942da

See more details on using hashes here.

Supported by

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