Skip to main content

nearmiss

nearmiss is a fast inexact text matching tool for finding repeats of an area around a specific anchor string throughout text, optionally finding matches with substitutions.

It is primarily intended for finding near-match sections of DNA in the vicinity of specific anchor sequences. The current substitution alphabet is limited to ACGT.

The speed of nearmiss comes from a C extension that uses the SA-IS suffix array library from Yuta Mori and pointer magic instead. The search time for anchors is O(|anchor| log |text|). The search time for repeats is O(a(sw)^d log t), where

  • a is the number of anchors found
  • s is the size of the substitution alphabet
  • w is the size of the matching window
  • d is the maximum desired number of substitutions to allow in the window
  • and t is the size of the search text

Use

>>> from nearmiss import Searcher
>>> seq = "TACTANGGnnnTAAAAGnGG"
>>> searcher = Searcher(seq)
>>> searcher.find_anchors("GG")
[6, 18]
>>> searcher.find_anchors("nGG")
[17]
>>> searcher.find_repeat_counts("GG", (-4, -2), max_distance=1)
{18: [1, 0], 6: [1, 0]}
>>> searcher.find_repeat_counts("GG", (-4, -2), max_distance=2)
{18: [1, 0, 1], 6: [1, 0, 1]}

For more detailed information, see the source documentation with pydoc nearmiss.Searcher or help(nearmiss.Searcher).

To limit the number of threads used outside the source, set the environment variable OMP_NUM_THREADS to the number of desired threads.

Installing

Non-python dependencies

nearmiss uses OpenMP to drastically speed up mismatch searching on many anchors. To install that on Debian/Ubuntu systems, run sudo apt-get install libomp5.

with pip

pip install nearmiss

from source

pip install . in the source directory

Metadata

Release files for nearmiss 0.1.4

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

Source distribution (sdist)

Source distribution for nearmiss 0.1.4
File Size Uploaded Provenance Actions
nearmiss-0.1.4.tar.gz 25.1 kB Without provenance Details for nearmiss-0.1.4.tar.gz

Release files / nearmiss-0.1.4.tar.gz

Download URL nearmiss-0.1.4.tar.gz
Size 25.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e46c603861be4d808cae437d9464fa0799a3f2a0eddc8f4562d778d06cf3ab2a
BLAKE2b-256 checksum
How to use checksums
2a542d692f3249f402b485769b18e93b026e3de50ac5d523afa22fd29788c3fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Security for nearmiss 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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