Skip to main content

pykraken2

pykraken2 provides a server/client implementation of kraken2.

Installation

pykraken2 is pre-alpha software, there are currently no packaged versions. Please use the Development instructions before for installation and use.

Development

The Git repository contains Python code implementing a server and client pair, it also contains a fork of kraken2 as a git submodule. To obtain the repository:

git clone --recursive https://github.com/epi2me-labs/pykraken2.git

For the purposes of development the Python components of pykraken2 can be installed using an in-place (editable) install:

make develop

This will make a virtual environment at ./venv and create and inplace (editable) install of the Python code, along with compiling kraken2 and copying the executables to the bin directory of the virtual environment.

Usage

Two command-line entry points are provided:

pykraken2 server

to run a kraken2 service to classify reads, and

pykraken2 client

to send read data to the service and receive results.

API

The server and client are straight-forward, we recommend the context managers are used:

# create a server
from pykraken2.server import Server
with Server(database, address, port, threads=8) as server:
    while True:
        pass

Although this code looks a little goofy, we intend to change the behaviour of the context manager. database is a database directory created by kraken2, address a location on which to listen for requests (e.g. 'localhost), port the network port on which to listen, and threads the number of threads to kraken2 to use. An optional argument k2_binary can be used to specify the location of a kraken2 binary to use.

A client can be constructed as:

# create a client
from pykraken2.client import Client
with Client(address, ports) as client:
    with open('output.txt', 'w') as fh:
        for chunk in client.process_fastq(args.fastq):
            fh.write(chunk)

Currently the process_fastq iterator returns chunks of the kraken2 output. The chunks are verbatim output: a chunk may contain multiple records, the last record may be incomplete in any non-final chunk.

Metadata

Release files for pykraken2 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pykraken2 0.0.1
File Size Uploaded
pykraken2-0.0.1.tar.gz 14.4 kB Details

Release files / pykraken2-0.0.1.tar.gz

Download URL pykraken2-0.0.1.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0b4a9a4ee8cf83888da6bf49161c062f437f64a9b40014594bcea036ddfbadc7
BLAKE2b-256 checksum
How to use checksums
81707a35b515b16547339f72670538ebb0206167edc8a70a9fb22eb285bcc431
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page