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:
pyclient A user-friendly wrapper around client_lib. This is what you should use to interact with a Dorado basecall server.
client_lib A compiled library which provides direct Python bindings to Dorado’s C++ BasecallClient API.
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_and_trace_enabled option must be set to True; analogously, for the state_data one, post_out must be turned on. NOTE: You shouldn’t turn on post_out if you don’t need the states, because it generates a LOT of extra output data so it can really hurt performance. Likewise with move_and_trace_enabled, although that’s much less expensive.
options = {'priority': BasecallClient.high_priority, 'client_name': "test_client", 'move_and_trace_enabled': True, 'post_out':True } client = BasecallClient(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'] state_data = read['datasets']['state_data'] 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}, state_data size is {state_data.shape}, " f"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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for ont_pybasecall_client_lib-7.3.10-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27539390b81a66c41b15a52a1b273857a8da4255cbc1b3dd419187898a9ec77e |
|
MD5 | 76d22422dc0d28a3bb8525a7a1bae105 |
|
BLAKE2b-256 | 568f793c5a054540f7988ee0476a38ddd6f4c1d26081decd3f1fd04b35cfa708 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e917f89cdb8d1a7fba277ebdd503168c29c4f942ff963bedcdcbd0df2e60f5dd |
|
MD5 | 011eac0a9570780249f72593f0a331a7 |
|
BLAKE2b-256 | bbf910ebe432c172ee1d2c02bf6e59f4a006bf74759105fb6559f10d3a66f871 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b668511591c1788e9b4cb246511cd60dacd6516f63e68ac1c7a0e891a6acba53 |
|
MD5 | e16a364d28f29bef56fd69c9522897f2 |
|
BLAKE2b-256 | 3f17cff6deab4c0b9062a88e7c0b245b54d622d73b709d161eff0f0cec186555 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp311-cp311-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43d214c22ccf87420e464d58040c24fe120cd13219226db0d18a586715b34a33 |
|
MD5 | d59b0c433237b9e76cb241326c35e738 |
|
BLAKE2b-256 | 3a0f6caee4c023cbc19d5ed45f852c284f5b7ccb5e4c290a319d980bf4ca8d7b |
Hashes for ont_pybasecall_client_lib-7.3.10-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09e8c8d5dd77d64b515a8e38adf5a8603baf3dc61d91c5b244ead90e9a7b8608 |
|
MD5 | f703970913143dcf955cd7aa938330b9 |
|
BLAKE2b-256 | 263247322f48534a06774d36651b7ca16969d9c10765dd205f08c24d27472034 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25a5d4e1e61d7fd8da89c7b1b4243b45e5b8ce6ab88925c7a4a1fdf82789b31d |
|
MD5 | b6ec40ffbcef0d4de05648b1caafc3e8 |
|
BLAKE2b-256 | 75130903e6aa6a42cf65a146847e430a2596a50dc00003cdf793934ee60378a0 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71844c1af24aa0035a9d454bcf9b09827c7bc9c6b0f87cebb3384f3b1fb444b8 |
|
MD5 | be2349c1c16a1f866de723e51b22f607 |
|
BLAKE2b-256 | 89d8d82886f1a256dbe33fb5195840cdeeef74f304edb732ac7bd9a94491442a |
Hashes for ont_pybasecall_client_lib-7.3.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67d75426f152d555485b32d6bf0ab6ed28e32d64749a5a5d068468c531d73cff |
|
MD5 | f5c092fdba1add9125563c16e1407ca2 |
|
BLAKE2b-256 | e687ac78267fa135822a46be9ad7882575423c05f5aeabe822e7e676c9536344 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp310-cp310-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1a43f1db624f51c962fe1089a71a7fdff747bed927b71e3182888710aad20db |
|
MD5 | 553387b88289232be5246fcbafd192c2 |
|
BLAKE2b-256 | c344f6a22370606312b766f369854e94a908c9947eae3ca653c35a769fcb28c7 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8172bd70dfe9d21ddc2aba988159362140bad91d63e00dc533b71dbdd21bc4f7 |
|
MD5 | 6f32ace2481fa043eae3102c493aab38 |
|
BLAKE2b-256 | 8c9c00610bccae59c77017999e97df86f40095cdc17c292426bc6b5ec36e074e |
Hashes for ont_pybasecall_client_lib-7.3.10-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78deaf3b36d4f4bf33165cb668f35486055640028ee9b959a5ad3d8aa076ebac |
|
MD5 | 05d325956e2abdb07482d795d1ae74b9 |
|
BLAKE2b-256 | a513da59037af22fa0adeeaacd6eb21f5017800560a53e87e677f6f3b8ba09f9 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97d12026204205abe5fbfcffb60543dd20f63ab01740e90ac57df8ac12f4164c |
|
MD5 | 156ad174f8d3849e6107d6224ef454e7 |
|
BLAKE2b-256 | a2b2058e93c072eb7f21577b5c5cfcd734b79426ddc30034aae3766913df56df |
Hashes for ont_pybasecall_client_lib-7.3.10-cp39-cp39-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ee8bf843f326cdda8cc17e8549df0ee2eccffe5c7fa9c55528f1ab84dccba6b |
|
MD5 | 6eec4a548b28f89c63a77a4615447f41 |
|
BLAKE2b-256 | c30fe9defdefda2894242c166cac279d3d75e45bafae3f2f667d2a2470df624c |
Hashes for ont_pybasecall_client_lib-7.3.10-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 424e5875f8cec3b1bec954505f808d9071f3caf0cc2938e9f23a3806ef67f233 |
|
MD5 | 4d11c707a9dd7d5dc4b6faa1fc08a1d3 |
|
BLAKE2b-256 | d801796cd439478f94b12e31a24bb07305168f76541266d90528292e51f63189 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9767ef1b149ae5766317b6d3e671d3d89b37a5bd2b6d72210ccabf822609667 |
|
MD5 | 6ad321e4cf3f2777dff0565022b68057 |
|
BLAKE2b-256 | ec3d0fda6526dc5d2b3b69b0e585c36fd025e02dffd58b0a4da5c60f16eb85b1 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f07254e2a0691b8fffbcf414669d4413ad557cc016885f8fdb41e0d07ca7d98 |
|
MD5 | d8d73c47bbc2506d5cf754fbe23d29d2 |
|
BLAKE2b-256 | 8e09337207b0366da7b8d0eb5176f3e6c6d6304bae5f24ae256e8ee18f0f3691 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 029156cda4028e20ddc64633710ad9aea16f6a0de6df116c2a9d4fd72b985e3f |
|
MD5 | 9334373f1a7e8f15bba4469ce730fd73 |
|
BLAKE2b-256 | 0d8021e0c186377c976210f38c174628b0e45a44d22bd59067f2f10f0c3e0e81 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff029649d69eac43b94c90aef78ff5da650da040deefc3d46de30cb392691895 |
|
MD5 | 0e47dea3d7b4fb9f7110525c3317e219 |
|
BLAKE2b-256 | 34cdf97a5cc8493ee823a5d2166a5bef4776055388fc22a65b0fc3694f494090 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2aae1ef8ae383852335d68a840103ac985c65f0c4fafb65df9963b5f34798575 |
|
MD5 | 1a228ae0394107bc0152f5d346ffd0c3 |
|
BLAKE2b-256 | a28b326611d3f0cd6dc06d3adb26cb51f1da57c6de4167e37e78a7f24f5184c2 |
Hashes for ont_pybasecall_client_lib-7.3.10-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97e9facb045278c565bb099fd6405ade3e748bc15630de774e1b09ba0b2a2c7b |
|
MD5 | 026dd88e0be10f82e2d4097907708a61 |
|
BLAKE2b-256 | ef28a26327cd4579dd8ce105be9fb5a0a6d23d8749721a33f882c141612d5776 |