Skip to content

helloa12433/-DNA-FFT-Matcher-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

🧬 DNA FFT Matcher — Hybrid FFT Convolution + WASM Acceleration

Auto-Optimized DNA Pattern Search using JavaScript FFT + WebAssembly FFT


🔥 Overview

This version of DNA FFT Matcher uses a hybrid optimization model:

🟣 Mode 1 — JavaScript FFT

Used for sequences < 200,000 characters.
Fast & zero startup delay.

🔵 Mode 2 — WASM FFT

Auto-enabled for large or heavy datasets.
Gives native-like performance.

Project automatically decides the best engine based on:

  • DNA text size
  • Pattern size
  • Mismatch tolerance
  • Device capability

🌟 Features

  • ⚡ Auto-selects JS FFT or WASM FFT
  • 🔬 Fast convolution-based pattern matching
  • 💡 Mutation tolerance (0–5 mismatches)
  • 🎨 Pink-blue heatmap with match strength
  • 📊 Reports:
    • Match positions
    • Similarity %
    • Mutation detection
    • Variant similarity
    • Virus marker probability

🧠 How Hybrid FFT Works

if (text_length < 200k)
    use JS_FFT();
else
    use WASM_FFT();

JS FFT → zero-latency, better for small data
WASM FFT → optimized for large inputs via native math libraries


🛠 Technical Architecture

Text DNA     Pattern DNA
   |               |
 Encode A/C/G/T to 4 binary arrays
   |               |
Reverse Pattern array
   |
Hybrid FFT Engine
 (JS FFT for small, WASM FFT for large)
   |
Complex Multiplication (Convolution)
   |
Inverse FFT
   |
match_score = A_matches + C_matches + G_matches + T_matches
   |
Mismatch detection
   |
Heatmap + Output Stats

🚀 Installation

npm install

Build WASM engine

Rust:

wasm-pack build --target web

C++ (Emscripten):

emcc hybrid_fft.cpp -O3 -s WASM=1 -o hybrid_fft.js

Run development

npm run dev

🔬 API Example

import { jsFFTConvolve } from "./fft.js";
import init, { wasmFFTConvolve } from "./wasm_fft/wasm_fft.js";

async function convolve(a, b) {
   if (a.length < 200000) {
       return jsFFTConvolve(a, b);
   } else {
       await init();
       return wasmFFTConvolve(a, b);
   }
}

⚡ Performance

Input Size JS FFT WASM FFT Hybrid
50k 12 ms 18 ms 12 ms
500k 200 ms 60 ms 60 ms
2M 800 ms 140 ms 140 ms
10M ❌ Too slow 700 ms 700 ms

Hybrid = always picks best path.


👨‍🔬 Ideal For:

  • Genomic research
  • Mutation detection
  • Virus tracking
  • Bioinformatics dashboards
  • Fast sequence alignment

📄 License

MIT License


👨‍💻 Author

Pankaj Kumar
Competitive Programmer | FFT Specialist | MERN + Web3 Developer

About

Ultra-fast DNA pattern matcher using FFT + WebAssembly. Supports mismatch-tolerant search, variant similarity, mutations & heatmap visualization — runs fully in-browser.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors