Skip to content

Latest commit

Β 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Design and Analysis of Algorithms (DAA): DNA Pattern Matching using Naive and Knuth-Morris-Pratt (KMP)

C++ Algorithms HTML License

A Design and Analysis of Algorithms (DAA) project implementing Naive Pattern Matching and Knuth-Morris-Pratt (KMP) algorithms for efficient DNA sequence analysis. The project includes a C++ console application, an interactive web-based visualization dashboard, and execution time benchmarking for algorithm comparison.


🎯 Project Overview

This project demonstrates efficient string pattern matching techniques used in DNA sequence analysis. It compares the performance of the Naive Pattern Matching algorithm with the Knuth-Morris-Pratt (KMP) algorithm.

The project consists of:

  • C++ console application
  • Interactive web dashboard
  • DNA sequence validation
  • Random DNA sequence generation
  • Pattern occurrence detection
  • Performance benchmarking
  • Execution time comparison

This project was developed as part of the Design and Analysis of Algorithms (DAA) course.


πŸš€ Features

  • βœ… DNA sequence validation (A, C, G, T only)
  • βœ… Naive Pattern Matching
  • βœ… Knuth-Morris-Pratt (KMP) Algorithm
  • βœ… Find all pattern occurrences
  • βœ… Random DNA sequence generation
  • βœ… Performance benchmarking
  • βœ… Execution time comparison
  • βœ… Interactive console menu
  • βœ… Interactive Web Dashboard
  • βœ… Algorithm visualization
  • βœ… Performance comparison graph
  • βœ… Modular C++ implementation

πŸš€ Highlights

  • Implements both Naive and KMP algorithms.
  • Compares execution time of both algorithms.
  • Demonstrates practical Design and Analysis of Algorithms concepts.
  • Interactive visualization using HTML, CSS and JavaScript.
  • Suitable for DAA laboratory and interview preparation.

πŸ“‚ Project Structure

DNA-Pattern-Matching/
β”‚
β”œβ”€β”€ CPP/
β”‚   └── main.cpp
β”‚
β”œβ”€β”€ web/
β”‚   └── index_modern_dna_strict.html
β”‚
β”œβ”€β”€ screenshots/
β”‚   β”œβ”€β”€ menu.png
β”‚   β”œβ”€β”€ pattern-matching.png
β”‚   β”œβ”€β”€ benchmark.png
β”‚   └── web-dashboard.png
β”‚
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE
└── .gitignore

🧬 Algorithms Implemented

1. Naive Pattern Matching

The Naive algorithm compares the pattern with every possible position in the DNA sequence.

Time Complexity

Case Complexity
Best O(n)
Average O(n Γ— m)
Worst O(n Γ— m)

2. Knuth-Morris-Pratt (KMP)

KMP preprocesses the pattern using the Longest Prefix Suffix (LPS) array to avoid unnecessary comparisons.

Time Complexity

Phase Complexity
LPS Construction O(m)
Pattern Search O(n)
Overall O(n + m)

πŸ“ˆ Algorithm Comparison

Algorithm Best Case Average Case Worst Case
Naive O(n) O(n Γ— m) O(n Γ— m)
KMP O(n + m) O(n + m) O(n + m)

βš™οΈ Technologies Used

  • C++
  • HTML5
  • CSS3
  • JavaScript
  • Standard Template Library (STL)
  • Chrono Library
  • MT19937 Random Number Generator

πŸ–₯️ Console Menu

============================================
   DNA SEQUENCE PATTERN MATCHING PROJECT
============================================

1. Match a pattern in a DNA sequence

2. Run performance benchmark (Naive vs KMP)

3. Exit

πŸ“– Example

Input

DNA Text

ACGTACGTACGTACGT

Pattern

CGTA

Output

Matches Found : 3

Starting Indices :

1
5
9

πŸ“Š Benchmark Example

Text Length : 100000

Pattern Length : 20

Naive Algorithm

Matches : 2

Time : 3.18 ms

-------------------------

KMP Algorithm

Matches : 2

Time : 0.74 ms

πŸ“š Learning Outcomes

This project helped in understanding:

  • Design and Analysis of Algorithms
  • String Matching Algorithms
  • Naive Pattern Matching
  • Knuth-Morris-Pratt (KMP)
  • Longest Prefix Suffix (LPS)
  • Time Complexity Analysis
  • DNA Sequence Processing
  • Performance Benchmarking
  • Modern C++ Programming

πŸ’‘ Future Improvements

  • Boyer-Moore Algorithm
  • Rabin-Karp Algorithm
  • LPS Array Visualization
  • Character Comparison Counter
  • FASTA File Support
  • CSV Report Export
  • Performance Charts
  • Qt Desktop GUI
  • DNA Mutation Detection

πŸ–₯️ How to Run

Compile

g++ CPP/main.cpp -o dna

Run (Linux/macOS)

./dna

Run (Windows)

g++ CPP/main.cpp -o dna.exe
dna.exe

πŸ“Έ Screenshots

Console Menu


Pattern Matching Result


Performance Benchmark


Interactive Web Dashboard


🎯 Applications

  • Bioinformatics
  • DNA Sequence Analysis
  • Genome Research
  • Pattern Matching
  • String Searching
  • Algorithm Analysis
  • Computational Biology
  • Computer Science Education

πŸ” Keywords

  • Design and Analysis of Algorithms
  • DAA
  • DNA Pattern Matching
  • String Matching
  • Naive Algorithm
  • Knuth-Morris-Pratt
  • KMP
  • LPS
  • Bioinformatics
  • C++
  • HTML
  • JavaScript
  • Algorithm Visualization
  • Performance Benchmarking

πŸ‘¨β€πŸ’» Author

Ziyaurrahman

B.Tech in Artificial Intelligence & Data Science

Arya College of Engineering & IT, Jaipur

GitHub: https://github.com/ziyaur-12


⭐ Support

If you found this project helpful, consider giving it a ⭐ on GitHub.

About

Design and Analysis of Algorithms (DAA) project implementing Naive and Knuth-Morris-Pratt (KMP) algorithms for DNA sequence pattern matching with C++ implementation, interactive web visualization, and performance benchmarking.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages