How fnadalin/gapfiller works
Project Type and Purpose
• This is a single‐binary, command-line C++ application (“GapFiller”) for de-novo local assembly to fill sequence gaps between paired reads.
• It is not a multi-tier web app or microservices system. Rather, it is a modular, self-contained bioinformatics tool that reads input files, processes them in memory, and writes output files.
High-Level Components
A. CLI & Options Manager
B. I/O Layer
C. Data Structures & Storage
D. Assembly Engine (Core Algorithm)
E. Error Handling
F. Output Generation
G. Third-Party Libraries (Boost, zlib, samtools code)
Relationships and Data Flow
1. CLI & Options Manager
• Parses command-line args (seed files, query files, parameters).
• Populates an Options singleton (src/options/*).
2. I/O Layer
• Auto-detects file types (fasta/fastq/SAM/BAM, gz/bz2) via Auto_Unzip/Auto_Zip modules (src/io).
• Streams raw reads into memory structures.
• Feeds seeds into the Assembly Engine and optional query reads.
3. Data Structures & Storage
• In-memory representations: Reads, Contig, Layout_list/vector, Hash tables (src/data_structures/*).
• Builds fingerprint hash index (k-mers) for fast overlap lookups.
4. Assembly Engine
• Uses modules/Assembly*.cpp classes: seed-and-extend algorithm.
• Performs overlap detection via hash index, consensus extension, stop-criteria checks (insert size exceeded, repeats, no more reads, etc.).
• Optionally records layout (src/modules/Assembly_store_layout).
5. Error Handling
• Centralized exception classes (src/errors/*) catch I/O, format, data errors, and propagate to CLI for reporting or abort.
6. Output Generation
• Writes contigs.fasta, contigs_trash.fasta, contigs.stats, and optional .layout files.
• Uses Binary/Fastq/Sam writers in the I/O layer, plus compression modules.
7. Third-Party Libraries
• Boost: for configurations, possibly threading or data structures.
• zlib: gzip compression support.
• Samtools code (src/samtools/*): in-process C library for BAM/SAM parsing and indexing.
• From CLI → Options Manager → Assembly Engine and I/O Layer
• From I/O Layer → Data Structures → Assembly Engine
• From Assembly Engine ↔ Data Structures (read/write)
• Assembly Engine → Output Generation → Files on disk
• Errors at any stage → Error Handling → CLI (exit/report)
Architectural Patterns and Design Principles
• Modular layering: clear separation between CLI parsing, I/O, core algorithm, data structures, and error handling.
• Singleton pattern for options.
• Strategy pattern for different input/output formats (via polymorphic Auto_Unzip/Auto_Zip, Binary, Fastq, Sam classes).
• In-memory hash indexing for fast lookup (parameterized by k and block length).
Detailed Elements
• Component labels: “Options::Singleton”, “Auto_Unzip”, “Hash”, “Assembly::extend()”, etc.
• “Read seeds & queries” → Hash build → “Find overlaps” → “Extend contig” → “Write contig”
• Modules for both FASTA/FASTQ and SAM/BAM reading.
• Compression subprocess (Auto_Zip) before writing .gz outputs.