Package: lightmotif
🎼🧬lightmotifA lightweightplatform-acceleratedlibrary forbiological motifscanning usingposition weight matrices.🗺️ OverviewMotifscanning withposition weight matrices(also known as position-specific scoring matrices) is a robust method for
identifying motifs of fixed length inside abiological sequence. They can be
used to identifytranscription factorbinding sites in DNA,
orproteasecleavagesite inpolypeptides.
Position weight matrices are often viewed assequence logos:Thelightmotiflibrary provides a Python module to run very efficient
searches for a motif encoded in a position weight matrix. The position
scanning combines several techniques to allow high-throughput processing
of sequences:Compile-time definition of alphabets and matrix dimensions.Sequence symbol encoding for fast table look-ups, as implemented in
HMMER[1]or MEME[2]Striped sequence matrices to process several positions in parallel,
inspired by Michael Farrar[3].Vectorized matrix row look-up usingpermuteinstructions ofAVX2.This is the Python version, there is aRust crateavailable as well.🔧 Installinglightmotifcan be installed directly fromPyPI,
which hosts some pre-built wheels for most mainstream platforms, as well as the
code required to compile from source with Rust:$pipinstalllightmotifIn the event you have to compile the package from source, all the required
Rust libraries are vendored in the source distribution, and a Rust compiler
will be setup automatically if there is none on the host machine.💡 ExampleThe motif interface should be mostly compatible with theBio.motifsmodule fromBiopython. The notable difference is that
thecalculatemethod of PSSM objects expects astripedsequence instead.importlightmotif# Create a count matrix from an iterable of sequencesmotif=lightmotif.create(["GTTGACCTTATCAAC","GTTGATCCAGTCAAC"])# Create a PSSM with 0.1 pseudocounts and uniform background frequenciespwm=motif.counts.normalize(0.1)pssm=pwm.log_odds()# Encode the target sequence into a striped matrixseq="ATGTCCCAACAACGATACCCCGAGCCCATCGCCGTCATCGGCTCGGCATGCAGATTCCCAGGCG"striped=lightmotif.stripe(seq)# Compute scores using the fastest backend implementation for the host machinescores=pssm.calculate(sseq)⏱️ BenchmarksBenchmarks use theMX000001motif fromPRODORIC[4], and thecomplete genomeof anEscherichia coli K12strain.Benchmarks were run on ai7-10710U CPUrunning @1.10GHz, compiled with--target-cpu=native.lightmotif (avx2):      5,479,884 ns/iter    (+/- 3,370,523) = 807.8 MiB/sBio.motifs:           334,359,765 ns/iter   (+/- 11,045,456) =  13.2 MiB/sMOODS.scan:           182,710,624 ns/iter    (+/- 9,459,257) =  24.2 MiB/spymemesuite.fimo:     239,694,118 ns/iter    (+/- 7,444,620) =  18.5 MiB/s💭 Feedback⚠️ Issue TrackerFound a bug ? Have an enhancement request ? Head over to theGitHub issue
trackerif you need to report
or ask something. If you are filing in on a bug, please include as much
information as you can about the issue, and try to recreate the same bug
in a simple, easily reproducible situation.📋 ChangelogThis project adheres toSemantic Versioningand provides achangelogin theKeep a Changelogformat.⚖️ LicenseThis library is provided under the open-sourceMIT license.This project was developed byMartin Larraldeduring his PhD project at theEuropean Molecular Biology Laboratoryin theZeller team.📚 References[1]Eddy, Sean R. ‘Accelerated Profile HMM Searches’. PLOS Computational Biology 7, no. 10 (20 October 2011): e1002195.doi:10.1371/journal.pcbi.1002195.[2]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.[3]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.[4]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.