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.2.tar.gz (7.7 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.2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pattern_searching-0.1.2.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pattern_searching-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6ff69e38dd51e27688c5b23202967b387be5a452ac9535a22540271d826c5989
MD5 329b0396ed25bf4bbe8d9aa2188bc8f7
BLAKE2b-256 0d8ded2f69dc6816f93862451a0217fe6f2322b257b21dd41622caa67c742cf1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pattern_searching-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b3ee37984673e6004099e2fc66666df7272456bdcebff27e06f33835f09c39d7
MD5 e37d3546f1643ec07303071c96cfe3da
BLAKE2b-256 3b3b31734b1d28913b237ba60fe18ac43eb3683d42c2c4eefa7fb27f2df1261c

See more details on using hashes here.

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