Skip to main content

Single-pattern and multiple-pattern string searching algorithms in Python

Project description

Pattern Searching Algorithms

This package provides single-pattern and multiple-pattern string searching algorithms in Python.
It is useful for students, programmers, and bioinformatics enthusiasts to learn, practice, and experiment with text and DNA/protein sequence analysis.


🎯 Relevance to Bioinformatics

Pattern searching is crucial for:

  • Finding motifs in DNA sequences (e.g., promoters, binding sites)
  • Identifying repeated sequences or mutations in genomes
  • Searching multiple motifs efficiently in large genomic datasets

These algorithms are foundational for sequence analysis, text processing, and bioinformatics data mining.


🧩 Single-Pattern Algorithms (Recherche d’un seul motif)

Algorithm Description
Naive Simple brute-force search for a single pattern.
Morris-Pratt Optimized for repeated patterns using prefix preprocessing.
Boyer-Moore Skips unmatched characters using bad character heuristic.
Rabin-Karp Uses hashing for pattern search.

Example:

from algorithms.single_pattern.naive import naive_search

text = "ABABDABACDABABCABAB"
pattern = "ABABCABAB"
naive_search(text, pattern)

🧩 Multiple-Pattern Algorithms (Recherche de plusieurs motifs)

Algorithm Description
Rabin-Karp (Multiple) Hash-based search for multiple patterns at once.
Aho-Corasick Builds a finite automaton for all patterns; very efficient.
Wu-Manber Optimized multiple-pattern search using block shifts.
Commentz-Walter Combines Boyer-Moore logic with multiple-pattern optimization.

Example:

from algorithms.multiple_pattern.aho_corasick import AhoCorasick

text = "ACGTACGTGACG"
patterns = ["ACG", "GAC"]
ac = AhoCorasick(patterns)
ac.search(text)

🚀 Usage

Clone the repository:

git clone https://github.com/HADIL19/Pattern-Searching.git
cd Pattern-Searching

Install the package locally:

pip install -e .

Run any algorithm:

python algorithms/single_pattern/naive.py
python algorithms/multiple_pattern/aho_corasick.py

📚 Resources

Check resources/pattern_searching_links.md for tutorials and detailed explanations:


⚖️ License

This project is licensed under the MIT License.
See the LICENSE file for full details.

You are free to **use, copy, modify, merge, publish, distribute, subl

Project details


Download files

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

Source Distribution

pattern_searching-0.1.3.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pattern_searching-0.1.3-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file pattern_searching-0.1.3.tar.gz.

File metadata

  • Download URL: pattern_searching-0.1.3.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pattern_searching-0.1.3.tar.gz
Algorithm Hash digest
SHA256 546739d6ae47c81c2b15f0eee96b8b4b98355d407a5d43020936da99bc9214ee
MD5 6d0e7dfb07b5437bc29da8dab1deff0e
BLAKE2b-256 8ed3637b0565ebbb5a6387396039176564bd381de5617d9fb5bb74faf662a881

See more details on using hashes here.

Provenance

The following attestation bundles were made for pattern_searching-0.1.3.tar.gz:

Publisher: python-publish.yml on HADIL19/Pattern-Searching

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pattern_searching-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pattern_searching-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 183c4171efc3beb76415ad058c4d73a419c4bd40a642682dc8bbb37939844727
MD5 50a732da57019cd4d3c25486674ba52a
BLAKE2b-256 b4f60f3a0ee4743b23a1cfea35ec73923aaca8756a5172138c9db84e3687db23

See more details on using hashes here.

Provenance

The following attestation bundles were made for pattern_searching-0.1.3-py3-none-any.whl:

Publisher: python-publish.yml on HADIL19/Pattern-Searching

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page