{"id":25596839,"url":"https://github.com/nanoporetech/fast-ctc-decode","last_synced_at":"2025-04-05T03:06:09.520Z","repository":{"id":41331634,"uuid":"240148408","full_name":"nanoporetech/fast-ctc-decode","owner":"nanoporetech","description":"Blitzing Fast CTC Beam Search Decoder","archived":false,"fork":false,"pushed_at":"2024-05-13T13:48:57.000Z","size":314,"stargazers_count":182,"open_issues_count":6,"forks_count":26,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-03-29T02:03:33.714Z","etag":null,"topics":["beam-search","ctc-decode","viterbi"],"latest_commit_sha":null,"homepage":"https://nanoporetech.com/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nanoporetech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-13T01:02:33.000Z","updated_at":"2025-03-11T18:33:14.000Z","dependencies_parsed_at":"2024-05-13T10:38:10.536Z","dependency_job_id":"b6439a33-0cb4-4824-848b-af0218e6be1c","html_url":"https://github.com/nanoporetech/fast-ctc-decode","commit_stats":{"total_commits":135,"total_committers":7,"mean_commits":"19.285714285714285","dds":"0.31851851851851853","last_synced_commit":"31c69e2d5b22d897453392fac9a6afc07324526a"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoporetech%2Ffast-ctc-decode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoporetech%2Ffast-ctc-decode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoporetech%2Ffast-ctc-decode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoporetech%2Ffast-ctc-decode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nanoporetech","download_url":"https://codeload.github.com/nanoporetech/fast-ctc-decode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280263,"owners_count":20912967,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beam-search","ctc-decode","viterbi"],"created_at":"2025-02-21T12:34:41.506Z","updated_at":"2025-04-05T03:06:09.500Z","avatar_url":"https://github.com/nanoporetech.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fast-ctc-decode\n\n![test-fast-ctc-decode](https://github.com/nanoporetech/fast-ctc-decode/workflows/test-fast-ctc-decode/badge.svg) [![PyPI version](https://badge.fury.io/py/fast-ctc-decode.svg)](https://badge.fury.io/py/fast-ctc-decode)\n\nBlitzing fast CTC decoding library.\n\n```\n$ pip install fast-ctc-decode\n$ npm i @nanopore/fast-ctc-decode\n```\n\n## Usage\n\n### Python\n```python\n\u003e\u003e\u003e from fast_ctc_decode import beam_search, viterbi_search\n\u003e\u003e\u003e\n\u003e\u003e\u003e alphabet = \"NACGT\"\n\u003e\u003e\u003e posteriors = np.random.rand(100, len(alphabet)).astype(np.float32)\n\u003e\u003e\u003e\n\u003e\u003e\u003e seq, path = viterbi_search(posteriors, alphabet)\n\u003e\u003e\u003e seq\n'ACACTCGCAGCGCGATACGACTGATCGAGATATACTCAGTGTACACAGT'\n\u003e\u003e\u003e\n\u003e\u003e\u003e seq, path = beam_search(posteriors, alphabet, beam_size=5, beam_cut_threshold=0.1)\n\u003e\u003e\u003e seq\n'ACACTCGCAGCGCGATACGACTGATCGAGATATACTCAGTGTACACAGT'\n```\n\n### Node / Web\n```js\nimport init, { beam_search, viterbi_search } from 'fast-ctc';\n\nconst 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];\nconst alphabet = [\"N\",\"A\",\"G\"];\nconst beamSize = 5;\nconst beamCutThreshold = Number(0.0).toPrecision(2);\nconst collapseRepeats = true;\nconst shape = [10, 3];\nconst string = false;\nconst qBias = Number(0.0).toPrecision(2);\nconst qScale = Number(1.0).toPrecision(2);\n\n// On web, note the base path will be your public folder\ninit('fast_ctc_decode_wasm_bg.wasm');\n\nconst viterbisearch = await beam_search(floatArr, alphabet, string, qScale, qBias, collapseRepeats, shape);\n\nconst beamsearch = await beam_search(floatArr, alphabet, beamSize, beamCutThreshold, collapseRepeats, shape);\n\nconsole.log(viterbisearch); // GGAG\nconsole.log(beamsearch); // GAGAG\n```\n\n## Benchmark\n\n| Implementation       | Time (s) | URL |\n| -------------------- | -------- | --- |\n| Viterbi (Rust)       |   0.0003 | [nanoporetech/fast-ctc-decode](https://github.com/nanoporetech/fast-ctc-decode.git) |\n| Viterbi (Python)     |   0.0022 |     |\n| Beam Search (Rust)   |   0.0033 | [nanoporetech/fast-ctc-decode](https://github.com/nanoporetech/fast-ctc-decode.git) |\n| Beam Search (C++)    |   0.1034 | [parlance/ctcdecode](https://github.com/parlance/ctcdecode) |\n| Beam Search (Python) |   3.3337 | [githubharald/CTCDecoder](https://github.com/githubharald/CTCDecoder) |\n\n\n## Developer Quickstart\n\n### Python\n\n```\n$ git clone https://github.com/nanoporetech/fast-ctc-decode.git\n$ cd fast-ctc-decode\n$ pip install --user maturin\n$ make test\n```\n\n### JavaScript / Node\n\n```\nnpm i\nnpm test\n```\n\nNote: You'll need a recent [rust](https://www.rust-lang.org/tools/install) compiler on your path to build the project.\n\nBy default, a fast (and less accurate) version of exponentiation is used for the 2D search. This can\nbe disabled by passing `--cargo-extra-args=\"--no-default-features\"` to maturin, which provides more\naccurate calculations but makes the 2D search take about twice as long.\n\n## Credits\n\nThe original 1D beam search implementation was developed by [@usamec](https://github.com/usamec) for [deepnano-blitz](https://github.com/fmfi-compbio/deepnano-blitz).\n\nThe 2D beam search is based on [@jordisr](https://github.com/jordisr) and [@ihh](https://github.com/ihh) work in their [pair consensus decoding](https://doi.org/10.1101/2020.02.25.956771) paper.\n\n### Licence and Copyright\n(c) 2019 Oxford Nanopore Technologies Ltd.\n\nfast-ctc-decode is distributed under the terms of the MIT License.  If a copy of the License\nwas not distributed with this file, You can obtain one at https://github.com/nanoporetech/fast-ctc-decode/\n\n### Research Release\n\nResearch 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanoporetech%2Ffast-ctc-decode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnanoporetech%2Ffast-ctc-decode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanoporetech%2Ffast-ctc-decode/lists"}