{"id":16916907,"url":"https://github.com/althonos/lightmotif","last_synced_at":"2025-10-04T08:29:24.971Z","repository":{"id":159465679,"uuid":"634653092","full_name":"althonos/lightmotif","owner":"althonos","description":"A lightweight platform-accelerated library for biological motif scanning using position weight matrices.","archived":false,"fork":false,"pushed_at":"2025-03-07T12:57:32.000Z","size":2502,"stargazers_count":43,"open_issues_count":2,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T14:09:25.067Z","etag":null,"topics":["bioinformatics","genomics","pssm","rust-library","sequence-analysis","sequence-motif","simd"],"latest_commit_sha":null,"homepage":"","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/althonos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"COPYING","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":"2023-04-30T20:17:01.000Z","updated_at":"2025-03-07T12:57:36.000Z","dependencies_parsed_at":"2023-12-12T01:40:02.529Z","dependency_job_id":"f24a36b9-76fa-4c6b-93d8-d913e5fcd528","html_url":"https://github.com/althonos/lightmotif","commit_stats":{"total_commits":336,"total_committers":3,"mean_commits":112.0,"dds":"0.011904761904761862","last_synced_commit":"f4b262b7e1a50c22ef3eb394034b04ba3ac8f9e5"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/althonos%2Flightmotif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/althonos%2Flightmotif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/althonos%2Flightmotif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/althonos%2Flightmotif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/althonos","download_url":"https://codeload.github.com/althonos/lightmotif/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353745,"owners_count":20925329,"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":["bioinformatics","genomics","pssm","rust-library","sequence-analysis","sequence-motif","simd"],"created_at":"2024-10-13T19:31:18.797Z","updated_at":"2025-10-04T08:29:24.850Z","avatar_url":"https://github.com/althonos.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎼🧬 `lightmotif` [![Star me](https://img.shields.io/github/stars/althonos/lightmotif.svg?style=social\u0026label=Star\u0026maxAge=3600)](https://github.com/althonos/lightmotif/stargazers)\n\n*A lightweight [platform-accelerated](https://en.wikipedia.org/wiki/Single_instruction,_multiple_data) library for [biological motif](https://en.wikipedia.org/wiki/Sequence_motif) scanning using [position weight matrices](https://en.wikipedia.org/wiki/Position_weight_matrix)*.\n\n[![Actions](https://img.shields.io/github/actions/workflow/status/althonos/lightmotif/rust.yml?branch=main\u0026logo=github\u0026style=flat-square\u0026maxAge=300)](https://github.com/althonos/lightmotif/actions)\n[![Coverage](https://img.shields.io/codecov/c/gh/althonos/lightmotif?logo=codecov\u0026style=flat-square\u0026maxAge=3600)](https://codecov.io/gh/althonos/lightmotif/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square\u0026maxAge=2678400)](https://choosealicense.com/licenses/mit/)\n[![Crate](https://img.shields.io/crates/v/lightmotif.svg?maxAge=600\u0026style=flat-square)](https://crates.io/crates/lightmotif)\n[![Docs](https://img.shields.io/docsrs/lightmotif?maxAge=600\u0026style=flat-square)](https://docs.rs/lightmotif)\n[![Source](https://img.shields.io/badge/source-GitHub-303030.svg?maxAge=2678400\u0026style=flat-square)](https://github.com/althonos/lightmotif/)\n[![Mirror](https://img.shields.io/badge/mirror-EMBL-009f4d?style=flat-square\u0026maxAge=2678400)](https://git.embl.de/larralde/lightmotif/)\n[![GitHub issues](https://img.shields.io/github/issues/althonos/lightmotif.svg?style=flat-square\u0026maxAge=600)](https://github.com/althonos/lightmotif/issues)\n[![Changelog](https://img.shields.io/badge/keep%20a-changelog-8A0707.svg?maxAge=2678400\u0026style=flat-square)](https://github.com/althonos/lightmotif/blob/master/CHANGELOG.md)\n\n## 🗺️ Overview\n\n[Motif](https://en.wikipedia.org/wiki/Sequence_motif) scanning with\n[position weight matrices](https://en.wikipedia.org/wiki/Position_weight_matrix)\n(also known as position-specific scoring matrices) is a robust method for\nidentifying motifs of fixed length inside a\n[biological sequence](https://en.wikipedia.org/wiki/Sequence_(biology)). They can be\nused to identify [transcription factor](https://en.wikipedia.org/wiki/Transcription_factor)\n[binding sites in DNA](https://en.wikipedia.org/wiki/DNA_binding_site),\nor [protease](https://en.wikipedia.org/wiki/Protease) [cleavage](https://en.wikipedia.org/wiki/Proteolysis) site in [polypeptides](https://en.wikipedia.org/wiki/Proteolysis).\nPosition weight matrices are often viewed as [sequence logos](https://en.wikipedia.org/wiki/Sequence_logo):\n\n[![MX000274.svg](https://raw.githubusercontent.com/althonos/lightmotif/main/docs/_static/prodoric_logo_mx000274.svg)](https://www.prodoric.de/matrix/MX000274.html)\n\nThe `lightmotif` library provides a Rust crate to run very efficient\nsearches for a motif encoded in a position weight matrix. The position\nscanning combines several techniques to allow high-throughput processing\nof sequences:\n\n- Compile-time definition of alphabets and matrix dimensions.\n- Sequence symbol encoding for fast table look-ups, as implemented in\n  HMMER[\\[1\\]](#ref1) or MEME[\\[2\\]](#ref2)\n- Striped sequence matrices to process several positions in parallel,\n  inspired by Michael Farrar[\\[3\\]](#ref3).\n- Vectorized matrix row look-up using `permute` instructions of [AVX2](https://fr.wikipedia.org/wiki/Advanced_Vector_Extensions).\n- High-throughput Gibbs sampler[\\[4\\]](#ref4) implementation in *oops*\n  and *zoops* modes, featuring deterministic results using randomness from \n  the [`rand`](https://crates.io/rand) crate.\n\nOther crates from the ecosystem provide additional features if needed:\n\n- [`lightmotif-io`](https://crates.io/crates/lightmotif-io) is a crate with parser implementations for various count matrix, frequency matrix and position-specific scoring matrix formats such as [TRANSFAC](https://en.wikipedia.org/wiki/TRANSFAC) or [JASPAR](https://jaspar.elixir.no/docs/).\n- [`lightmotif-tfmpvalue`](https://crates.io/crates/lightmotif-tfmpvalue) is an exact reimplementation of the TFM-PVALUE[\\[5\\]](#ref5) algorithm for converting between a score and a *p*-value for a given scoring matrix.\n\n*This is the Rust version, there is a [Python package](https://pypi.org/project/lightmotif) available as well.*\n\n## 💡 Example\n\n```rust\nuse lightmotif::*;\nuse lightmotif::abc::Nucleotide;\n\n// Create a count matrix from an iterable of motif sequences\nlet counts = CountMatrix::\u003cDna\u003e::from_sequences(\n    [\"GTTGACCTTATCAAC\", \"GTTGATCCAGTCAAC\"]\n        .into_iter()\n        .map(|s| EncodedSequence::encode(s).unwrap()),\n)\n.unwrap();\n\n// Create a PSSM with 0.1 pseudocounts and uniform background frequencies.\nlet pssm = counts.to_freq(0.1).to_scoring(None);\n\n// Use the pipeline to encode the target sequence into a striped matrix\nlet seq = \"ATGTCCCAACAACGATACCCCGAGCCCATCGCCGTCATCGGCTCGGCATGCAGATTCCCAGGCG\";\nlet encoded = EncodedSequence::encode(seq).unwrap();\nlet mut striped = encoded.to_striped();\n\n// Organize layout of striped matrix to allow scoring with PSSM.\nstriped.configure(\u0026pssm);\n\n// Compute scores for every position of the matrix.\nlet scores = pssm.score(\u0026striped);\n\n// Scores can be extracted into a Vec\u003cf32\u003e, or indexed directly.\nlet v = scores.unstripe();\nassert_eq!(scores[0], -23.07094);\nassert_eq!(v[0], -23.07094);\n\n// Find the highest scoring position.\nlet best = scores.argmax().unwrap();\nassert_eq!(best, 18);\n\n// Find the positions above an absolute score threshold.\nlet indices = scores.threshold(10.0);\nassert_eq!(indices, []);\n```\nThis example uses a dynamic dispatch pipeline, which selects the best available\nbackend (AVX2, SSE2, NEON, or a generic implementation) depending on the local \nplatform.\n\n## ⏱️ Benchmarks\n\nBoth benchmarks use the [MX000001](https://www.prodoric.de/matrix/MX000001.html)\nmotif from [PRODORIC](https://www.prodoric.de/)[\\[5\\]](#ref5), and the\n[complete genome](https://www.ncbi.nlm.nih.gov/nuccore/U00096) of an\n*Escherichia coli K12* strain.\n*Benchmarks were run on a [i7-10710U CPU](https://ark.intel.com/content/www/us/en/ark/products/196448/intel-core-i7-10710u-processor-12m-cache-up-to-4-70-ghz.html) running @1.10GHz, compiled with `--target-cpu=native`*.\n\n- Score every position of the genome with the motif weight matrix:\n  ```console\n  test bench_avx2    ... bench:   4,510,794 ns/iter (+/-     9,570) = 1029 MB/s\n  test bench_sse2    ... bench:  26,773,537 ns/iter (+/-    57,891) =  173 MB/s\n  test bench_generic ... bench: 317,731,004 ns/iter (+/- 2,567,370) =   14 MB/s\n  ```\n\n- Find the highest-scoring position for a motif in a 10kb sequence\n  (compared to the PSSM algorithm implemented in\n  [`bio::pattern_matching::pssm`](https://docs.rs/bio/1.1.0/bio/pattern_matching/pssm/index.html)):\n  ```console\n  test bench_avx2    ... bench:      12,797 ns/iter (+/-   380) = 781 MB/s\n  test bench_sse2    ... bench:      62,597 ns/iter (+/-    43) = 159 MB/s\n  test bench_generic ... bench:     671,900 ns/iter (+/- 1,150) =  14 MB/s\n  test bench_bio     ... bench:   1,193,911 ns/iter (+/- 2,519) =   8 MB/s\n  ```\n\n\n## 💭 Feedback\n\n### ⚠️ Issue Tracker\n\nFound a bug ? Have an enhancement request ? Head over to the [GitHub issue\ntracker](https://github.com/althonos/lightmotif/issues) if you need to report\nor ask something. If you are filing in on a bug, please include as much\ninformation as you can about the issue, and try to recreate the same bug\nin a simple, easily reproducible situation.\n\n\u003c!-- ### 🏗️ Contributing\n\nContributions are more than welcome! See [`CONTRIBUTING.md`](https://github.com/althonos/lightmotif/blob/master/CONTRIBUTING.md) for more details. --\u003e\n\n## 📋 Changelog\n\nThis project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)\nand provides a [changelog](https://github.com/althonos/lightmotif/blob/master/CHANGELOG.md)\nin the [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) format.\n\n## ⚖️ License\n\nThis library is provided under the open-source\n[MIT license](https://choosealicense.com/licenses/mit/).\n\n*This project was developed by [Martin Larralde](https://github.com/althonos/)\nduring his PhD project at the [European Molecular Biology Laboratory](https://www.embl.de/)\nin the [Zeller team](https://github.com/zellerlab).*\n\n## 📚 References\n\n- \u003ca id=\"ref1\"\u003e\\[1\\]\u003c/a\u003e Eddy, Sean R. ‘Accelerated Profile HMM Searches’. PLOS Computational Biology 7, no. 10 (20 October 2011): e1002195. [doi:10.1371/journal.pcbi.1002195](https://doi.org/10.1371/journal.pcbi.1002195).\n- \u003ca id=\"ref2\"\u003e\\[2\\]\u003c/a\u003e Grant, Charles E., Timothy L. Bailey, and William Stafford Noble. ‘FIMO: Scanning for Occurrences of a given Motif’. Bioinformatics 27, no. 7 (1 April 2011): 1017–18. [doi:10.1093/bioinformatics/btr064](https://doi.org/10.1093/bioinformatics/btr064).\n- \u003ca id=\"ref3\"\u003e\\[3\\]\u003c/a\u003e Farrar, Michael. ‘Striped Smith–Waterman Speeds Database Searches Six Times over Other SIMD Implementations’. Bioinformatics 23, no. 2 (15 January 2007): 156–61. [doi:10.1093/bioinformatics/btl582](https://doi.org/10.1093/bioinformatics/btl582).\n- \u003ca id=\"ref4\"\u003e\\[4\\]\u003c/a\u003e Lawrence, Charles E., Stephen F. Altschul, Mark S. Boguski, Jun S. Liu, Andrew F. Neuwald, and John C. Wootton. ’Detecting subtle sequence signals: a Gibbs sampling strategy for multiple alignment’. Science. 1993 Oct 8;262(5131):208-14. [doi:10.1126/science.8211139](https://doi.org/10.1126/science.8211139).\n- \u003ca id=\"ref5\"\u003e\\[5\\]\u003c/a\u003e Touzet, Hélène, and Jean-Stéphane Varré. ‘Efficient and Accurate P-Value Computation for Position Weight Matrices’. Algorithms for Molecular Biology 2, no. 1 (2007): 1–12. [doi:10.1186/1748-7188-2-15](https://doi.org/10.1186/1748-7188-2-15).\n- \u003ca id=\"ref5\"\u003e\\[6\\]\u003c/a\u003e Dudek, Christian-Alexander, and Dieter Jahn. ‘PRODORIC: State-of-the-Art Database of Prokaryotic Gene Regulation’. Nucleic Acids Research 50, no. D1 (7 January 2022): D295–302. [doi:10.1093/nar/gkab1110](https://doi.org/10.1093/nar/gkab1110).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falthonos%2Flightmotif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falthonos%2Flightmotif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falthonos%2Flightmotif/lists"}