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:
- Pattern Searching on GeeksforGeeks
- KMP, Rabin-Karp, Boyer-Moore, Aho-Corasick tutorials
- Wu-Manber and Commentz-Walter references
⚖️ 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
546739d6ae47c81c2b15f0eee96b8b4b98355d407a5d43020936da99bc9214ee
|
|
| MD5 |
6d0e7dfb07b5437bc29da8dab1deff0e
|
|
| BLAKE2b-256 |
8ed3637b0565ebbb5a6387396039176564bd381de5617d9fb5bb74faf662a881
|
Provenance
The following attestation bundles were made for pattern_searching-0.1.3.tar.gz:
Publisher:
python-publish.yml on HADIL19/Pattern-Searching
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pattern_searching-0.1.3.tar.gz -
Subject digest:
546739d6ae47c81c2b15f0eee96b8b4b98355d407a5d43020936da99bc9214ee - Sigstore transparency entry: 1191939813
- Sigstore integration time:
-
Permalink:
HADIL19/Pattern-Searching@734f9b7ec0d3ae1d8664e653158ab9586074c114 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/HADIL19
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@734f9b7ec0d3ae1d8664e653158ab9586074c114 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pattern_searching-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pattern_searching-0.1.3-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
183c4171efc3beb76415ad058c4d73a419c4bd40a642682dc8bbb37939844727
|
|
| MD5 |
50a732da57019cd4d3c25486674ba52a
|
|
| BLAKE2b-256 |
b4f60f3a0ee4743b23a1cfea35ec73923aaca8756a5172138c9db84e3687db23
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pattern_searching-0.1.3-py3-none-any.whl -
Subject digest:
183c4171efc3beb76415ad058c4d73a419c4bd40a642682dc8bbb37939844727 - Sigstore transparency entry: 1191939820
- Sigstore integration time:
-
Permalink:
HADIL19/Pattern-Searching@734f9b7ec0d3ae1d8664e653158ab9586074c114 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/HADIL19
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@734f9b7ec0d3ae1d8664e653158ab9586074c114 -
Trigger Event:
release
-
Statement type: