Skip to main content

nearmiss

NEARby MISmatch Search

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

from source

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.

Once installed, run pip install . in the source directory.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nearmiss-0.1.0.tar.gz (11.9 kB view details)

Uploaded Source

File details

Details for the file nearmiss-0.1.0.tar.gz.

File metadata

  • Download URL: nearmiss-0.1.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.5.3

File hashes

Hashes for nearmiss-0.1.0.tar.gz
Algorithm Hash digest
SHA256 455b16c1fd8b95b652a0ac4b4955ad7d17abc1abe3f221e1be8ab6e9ddb11551
MD5 66e335c05e1010bbf7b8d10b8f7c5f1c
BLAKE2b-256 a9eca162117d5fb2887863a826af2bc0c394a74e21d582b3a915f2f4c9399f57

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

This release

0.1.0 This release

1 file

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