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.11.2-cp313-cp313-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.13Windows x86-64

ont_pybasecall_client_lib-7.11.2-cp313-cp313-manylinux_2_28_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

ont_pybasecall_client_lib-7.11.2-cp313-cp313-manylinux_2_28_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

ont_pybasecall_client_lib-7.11.2-cp313-cp313-macosx_13_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 13.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

ont_pybasecall_client_lib-7.11.2-cp312-cp312-manylinux_2_28_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

ont_pybasecall_client_lib-7.11.2-cp312-cp312-manylinux_2_28_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

ont_pybasecall_client_lib-7.11.2-cp312-cp312-macosx_13_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 13.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

ont_pybasecall_client_lib-7.11.2-cp311-cp311-manylinux_2_28_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

ont_pybasecall_client_lib-7.11.2-cp311-cp311-manylinux_2_28_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

ont_pybasecall_client_lib-7.11.2-cp311-cp311-macosx_13_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 13.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

ont_pybasecall_client_lib-7.11.2-cp310-cp310-manylinux_2_28_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

ont_pybasecall_client_lib-7.11.2-cp310-cp310-manylinux_2_28_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

ont_pybasecall_client_lib-7.11.2-cp310-cp310-macosx_13_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 13.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

ont_pybasecall_client_lib-7.11.2-cp39-cp39-manylinux_2_28_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

ont_pybasecall_client_lib-7.11.2-cp39-cp39-macosx_13_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.9macOS 13.0+ ARM64

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 97b31e4984efba46a2506cb9218bf83ee088c8b5f6c1464b3f0297ca433c05f3
MD5 073c7524fe6c7a81841b9e63ee03b1f2
BLAKE2b-256 d3e9b333e0ca52aba894d8a3da8c536ac21f4b2d78e643f312273f2971c50919

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.11.2-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 524179810aa8dc9c5ad826d501a68147c9d6bd0bb3a30585d2781002e4a2198b
MD5 837b92fd9b7d01cee2ad2375b4fa46e9
BLAKE2b-256 f9a92303533f47dded05cbd1bb9443e47c3ff488eb4419d4b7c3f72d83224cfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 78d049aca36c3319d482049d4b5798c7b92dc02bb78c1944321d8d8c9cdebe25
MD5 4f2c1ab623086fd3069051130836818b
BLAKE2b-256 83d8fe99c8a07a0ca3241c7f7dbfe6d166f7511981eb475cb6b975013c90c2f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp313-cp313-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 97a988a4eeac76eee2e1837a0a637c3baeac90b8bd3c989e7e5a150a224ca7d2
MD5 5a761db1ff81b552a2dc6780ea5aaddc
BLAKE2b-256 ea81e9e6e38f2049c6fc7705b270297f7673310a03d9f766262d0129ca317f31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6d47be369166a1c38f00537c65b929d7638efb06285e779350c8d2d47f4cb494
MD5 abffb28d77697063e1e597b6c0fe1318
BLAKE2b-256 3232dbdb31e41658b9854339ebb80222f94770defa190c8234c874000cc5deb9

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.11.2-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3fcc7b287df922467b76c5f2976c144c7c3b77a042f0806df1641763c7debbd7
MD5 5e5c697a2e1f34acb65e0e14de5f62f8
BLAKE2b-256 7d08e1bde8a17bdb9a795781d80ccd164618ef08deffb09b61184769e9e80eab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5c5cc51c706eed97330df2c65758ed16443016628f6bd87ef966713712f79d6b
MD5 1e8d3a11ee7e9aa7523e07a8666d64b4
BLAKE2b-256 2d8d70a71e159d423c33244d43f69c2b8dff772d44e0aa83984a6028ad0fea4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp312-cp312-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 4a13cde400e78ee17ae03545a1044c6742657516553953c494a87674486ea352
MD5 e3868c6df03ede1d01cd898c9cabd574
BLAKE2b-256 37ce42bb02b2da72640a5c3cd13d45274fd7b7dce0bd5abcc040ec5b57d30529

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0a0f68071f8e34558b91dd020ecffd587527dc36d5fb4a394e3cd1fe70124395
MD5 d7b298100dec25e2b0bf1118cc54bf37
BLAKE2b-256 52839efa8ad89ed5de54908a574f295f524da81ed0d78a820a36e712b9926a39

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.11.2-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80bac953dcba98d7059147bba7e6729a4d60c5fa2d657bf876945bc593a66833
MD5 f60910402ed0be87cdebb647d3920f7f
BLAKE2b-256 f6cc82d73fc3c7cf814b38d42f91bfa929c772681a50bc4f23807e23d6007855

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ffc84bec4c36b511fe3f6c727814645f0ea032a257a104e29e3fcdb126b50128
MD5 918fa847877ea4a38b4ad0feed2fdbdf
BLAKE2b-256 a0e8ee48d36e4cf344ea666fec9a8c139ba5dfa00c3656e37ff6aa5469747109

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp311-cp311-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 0b158aafd35e81be39811478f63c1535cdf330f0ce332688ebc0957b9571bf12
MD5 692f321764f4bb55553e4d45be5ce32a
BLAKE2b-256 4711022b925850df90780e33f07d9a74be95e0791c2a58295f7b7ae0e9090543

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7e69d3d601e1eb2a09cddf5f3014e9b7cae050b2746e95c1f86e3900605cd0a9
MD5 5ca6fc58febb742491a157b1ae0faff2
BLAKE2b-256 e0f53a859ad6f777b5496a9ec53066cff20a2f14ff405e87370f8af1ffc1d5fd

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.11.2-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2b570ab0414b04a8e36636ab2649ef30ca4d46259fc740aaf165f3797d2e2bb0
MD5 f8b8d879eb89469561179003518d23cf
BLAKE2b-256 2ec448c417383682ca6e1428d08ca131a1e13571190d200fbe3ea4f260765cc9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 dcbbfc7260a3a3b29751494d617d7155966df849797b228597727101400eb936
MD5 b195ddf1a1cde9aca30fcd29a4f28690
BLAKE2b-256 238d00a3acf7bf5238c7dc44425124ee84d89a72d977156b9647d3f6f1c2e88e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp310-cp310-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 4f9047c5e041ef6865627426696314b743fb00765269c87123d088650334ab65
MD5 46a84c8db522fb4f3b201eac14f0e6dc
BLAKE2b-256 36e096b10a14a85d7072e2dc1b09a2311389ba47b271a41773756dedc4146497

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f2a162de0a391a05409b649cb41605cdbb0283a1316d62c1731b6b2257f04c46
MD5 c2866cdefc7ff1f6b3b89cec5b424f1f
BLAKE2b-256 fe9246cc1be5668248d6ac32c8164d72c8b7f801a7fe2d54591b09f6c80d9e64

See more details on using hashes here.

File details

Details for the file ont_pybasecall_client_lib-7.11.2-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 432e83cac4972937f293edf1680950983c886e55980b7ec4205f8183cf82e2d3
MD5 08889201c725ca8663c3973f953d9463
BLAKE2b-256 3973895a3f295f679dda42bc5e466eb5f35f5ddb662ff2efba4cb71b7c0bbfc2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ont_pybasecall_client_lib-7.11.2-cp39-cp39-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 6b8f54835f1c40c1eac74f648aa8120a4854515009d7f113e5223c9c12b8c9cb
MD5 71963657dfe1948a14c09eacad998529
BLAKE2b-256 ddb98cdbd04b0e061e21797517ae730384f6c7d5b09bb0ebd3f531745d9e6f19

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