Skip to main content

No project description provided

Project description

fast-ctc-decode

test-fast-ctc-decode PyPI version

Blitzing fast CTC decoding library.

$ pip install fast-ctc-decode
$ npm i @nanopore/fast-ctc-decode

Usage

Python

>>> from fast_ctc_decode import beam_search, viterbi_search
>>>
>>> alphabet = "NACGT"
>>> posteriors = np.random.rand(100, len(alphabet)).astype(np.float32)
>>>
>>> seq, path = viterbi_search(posteriors, alphabet)
>>> seq
'ACACTCGCAGCGCGATACGACTGATCGAGATATACTCAGTGTACACAGT'
>>>
>>> seq, path = beam_search(posteriors, alphabet, beam_size=5, beam_cut_threshold=0.1)
>>> seq
'ACACTCGCAGCGCGATACGACTGATCGAGATATACTCAGTGTACACAGT'

Node / Web

import init, { beam_search, viterbi_search } from 'fast-ctc';

const floatArr = [0.0, 0.4, 0.6, 0.0, 0.3, 0.7, 0.3, 0.3, 0.4, 0.4, 0.3, 0.3, 0.4, 0.3, 0.3, 0.3, 0.3, 0.4, 0.1, 0.4, 0.5, 0.1, 0.5, 0.4, 0.8, 0.1, 0.1, 0.1, 0.1, 0.8];
const alphabet = ["N","A","G"];
const beamSize = 5;
const beamCutThreshold = Number(0.0).toPrecision(2);
const collapseRepeats = true;
const shape = [10, 3];
const string = false;
const qBias = Number(0.0).toPrecision(2);
const qScale = Number(1.0).toPrecision(2);

// On web, note the base path will be your public folder
init('fast_ctc_decode_wasm_bg.wasm');

const viterbisearch = await beam_search(floatArr, alphabet, string, qScale, qBias, collapseRepeats, shape);

const beamsearch = await beam_search(floatArr, alphabet, beamSize, beamCutThreshold, collapseRepeats, shape);

console.log(viterbisearch); // GGAG
console.log(beamsearch); // GAGAG

Benchmark

Implementation Time (s) URL
Viterbi (Rust) 0.0003 nanoporetech/fast-ctc-decode
Viterbi (Python) 0.0022
Beam Search (Rust) 0.0033 nanoporetech/fast-ctc-decode
Beam Search (C++) 0.1034 parlance/ctcdecode
Beam Search (Python) 3.3337 githubharald/CTCDecoder

Developer Quickstart

Python

$ git clone https://github.com/nanoporetech/fast-ctc-decode.git
$ cd fast-ctc-decode
$ pip install --user maturin
$ make test

JavaScript / Node

npm i
npm test

Note: You'll need a recent rust compiler on your path to build the project.

By default, a fast (and less accurate) version of exponentiation is used for the 2D search. This can be disabled by passing --cargo-extra-args="--no-default-features" to maturin, which provides more accurate calculations but makes the 2D search take about twice as long.

Credits

The original 1D beam search implementation was developed by @usamec for deepnano-blitz.

The 2D beam search is based on @jordisr and @ihh work in their pair consensus decoding paper.

Licence and Copyright

(c) 2019 Oxford Nanopore Technologies Ltd.

fast-ctc-decode is distributed under the terms of the MIT License. If a copy of the License was not distributed with this file, You can obtain one at https://github.com/nanoporetech/fast-ctc-decode/

Research Release

Research releases are provided as technology demonstrators to provide early access to features or stimulate Community development of tools. Support for this software will be minimal and is only provided directly by the developers. Feature requests, improvements, and discussions are welcome and can be implemented by forking and pull requests. However much as we would like to rectify every issue and piece of feedback users may have, the developers may have limited resource for support of this software. Research releases may be unstable and subject to rapid iteration by Oxford Nanopore Technologies.

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

fast_ctc_decode-0.3.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (622.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

fast_ctc_decode-0.3.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (595.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

fast_ctc_decode-0.3.5-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (443.4 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

fast_ctc_decode-0.3.5-cp311-cp311-macosx_10_7_x86_64.whl (237.1 kB view hashes)

Uploaded CPython 3.11 macOS 10.7+ x86-64

fast_ctc_decode-0.3.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (622.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

fast_ctc_decode-0.3.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (595.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

fast_ctc_decode-0.3.5-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (443.4 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

fast_ctc_decode-0.3.5-cp310-cp310-macosx_10_7_x86_64.whl (237.1 kB view hashes)

Uploaded CPython 3.10 macOS 10.7+ x86-64

fast_ctc_decode-0.3.5-cp39-none-win_amd64.whl (172.6 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

fast_ctc_decode-0.3.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (622.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

fast_ctc_decode-0.3.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (595.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

fast_ctc_decode-0.3.5-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (443.4 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

fast_ctc_decode-0.3.5-cp39-cp39-macosx_10_7_x86_64.whl (237.1 kB view hashes)

Uploaded CPython 3.9 macOS 10.7+ x86-64

fast_ctc_decode-0.3.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (622.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

fast_ctc_decode-0.3.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (595.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

fast_ctc_decode-0.3.5-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (443.4 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

fast_ctc_decode-0.3.5-cp38-cp38-macosx_10_7_x86_64.whl (237.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.7+ x86-64

fast_ctc_decode-0.3.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (622.2 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

fast_ctc_decode-0.3.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (595.7 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

fast_ctc_decode-0.3.5-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (443.4 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

fast_ctc_decode-0.3.5-cp37-cp37m-macosx_10_7_x86_64.whl (237.1 kB view hashes)

Uploaded CPython 3.7m macOS 10.7+ 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