Skip to main content

Python bindings for the GuppyClient library.

Project description

ont-pyguppy-client-lib

ont-pyguppy-client-lib provides python bindings for connecting to a Guppy basecall server. It allows you to interact with the server to do anything you could normally do using the guppy basecall client. This includes:

  • Basecalling

  • Barcoding / demultiplexing

  • Alignment

For example:

>>> from pyguppy_client_lib.pyclient import PyGuppyClient
>>> caller = PyGuppyClient(
    "127.0.0.1:5555",
    "dna_r9.4.1_450bps_fast",
    alignment_index_file="/path/to/index.mmi",
    bed_file="/path/to/targets.bed"
)
>>> caller.connect()

Getting started

ont-pyguppy-client-lib is available on PyPI and may be installed via pip:

pip install ont-pyguppy-client-lib

ont-pyguppy-client-lib requires an instance of the Guppy basecall server is running. Guppy may be obtained from the Oxford Nanopore Community

The version of ont-pyguppy-client-lib should exactly match the version of Guppy being used. You can find your Guppy version like this:

$ <location of guppy_basecall_server>/guppy_basecall_server --version

For example, this Guppy basecall server is version 4.2.2:

$ ./ont-guppy/bin/guppy_basecall_server --version
: Guppy Basecall Service Software, (C) Oxford Nanopore Technologies,  Limited. Version 4.2.2+effbaf8, client-server API version 3.2.0

Install a specific version of ont-pyguppy-client-lib like this:

pip install ont-pyguppy-client-lib==<version>

Dependencies

ont-pyguppy-client-lib requires numpy in order to run. In order to use included helper functions for reading data from fast5 files it is also necessary to manually install ont-fast5-api:

pip install ont-fast5-api

Documentation and help

Information on the methods available may be viewed through Python’s help command::

>>> from pyguppy_client_lib import pyclient
>>> help(pyclient)
>>> from pyguppy_client_lib import client_lib
>>> help(client_lib)

Interface / Examples

ont-pyguppy-client-lib comprises three Python modules:

  1. pyclient A user-friendly wrapper around guppy_client. This is what you should use to interact with a Guppy basecall server.

  2. guppy_client A compiled library which provides direct Python bindings to Guppy’s C++ API.

  3. helper_functions A set of functions for running a Guppy basecall server and loading reads from fast5 files.

Starting a basecall server

There must be a Guppy 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 pyguppy_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/guppy_server_logs",
               "--config", "dna_r9.4.1_450bps_fast.cfg",
               "--port", 5556]
# The second argument is the directory where the
# guppy_basecall_server executable is found. Update this as
# appropriate.
helper_functions.run_server(server_args, "/home/myuser/ont-guppy/bin")

See the Guppy protocol for more information on server arguments.

Create a client and connect to a server

from pyguppy_client_lib.pyclient import PyGuppyClient

client = PyGuppyClient(
    "127.0.0.1:5555",
    "dna_r9.4.1_450bps_fast"
)
client.connect()

Basecall all the reads in a folder

Note that the helper_functions module requires that ont-fast5-api is installed.:

from pyguppy_client_lib import helper_functions

# Using the client generated in the previous example
results = helper_functions.basecall_with_pyguppy(
    caller,
    <input_folder>
)

Glossary of Terms:

Guppy - 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.

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_pyguppy_client_lib-5.1.17-cp38-cp38-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

ont_pyguppy_client_lib-5.1.17-cp37-cp37m-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

ont_pyguppy_client_lib-5.1.17-cp36-cp36m-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

ont_pyguppy_client_lib-5.1.17-cp35-cp35m-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.5m Windows x86-64

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