How voutcn/megahit works
MEGAHIT is a command-line NGS assembler whose principal workflow takes sequencing reads and produces assembled contigs. The sampled entry point dispatches commands, and the assembly driver references graph-cleaning algorithms and contig output; README usage documents read inputs and final.contigs.fa. Separate commands support local assembly, iterative edge extraction, and library building. The graph preserves those capabilities and the core sequence, graph, and data-structure layers. Some pipeline links rely on README-level behavior or are unverified because their implementations were not excerpted.
Main entry points: main.cpp Command dispatcher · main_assemble.cpp Assembly command · local_assemble.cpp Local assembly · contig_graph.cpp Local contig graph
Components 23
Command entry
- Command dispatcher
src/main.cpp - Assembly command
src/main_assemble.cpp
Read processing
- Sequence readers
src/sequence/io/fastx_reader.h - Sequence libraries
src/sequence/io/sequence_lib.h - Read sorting
src/sorting/base_engine.cpp - SDBG construction
src/sorting/seq_to_sdbg.cpp
Graph assembly
- Succinct de Bruijn graph
src/sdbg/sdbg.h - Unitig graph
src/assembly/unitig_graph.cpp - Graph cleaning
src/assembly/all_algo.h - Contig output
src/assembly/contig_output.h
Additional workflows
- Local assembly
src/localasm/local_assemble.cpp - Contig hash mapper
src/localasm/hash_mapper.cpp - Local contig graph
src/idba/contig_graph.cpp - Iterative extraction
src/main_iterate.cpp - Library building
src/main_buildlib.cpp
Core data structures
- Packed sequences
src/sequence/sequence_package.h - Contig reader
src/sequence/io/contig/contig_reader.h - Hash graph
src/idba/hash_graph.h - K-mer representation
src/idba/kmer.h - Bit-vector primitives
src/kmlib/kmbitvector.h - Parallel hash map
src/parallel_hashmap/phmap.h - Hash functions
src/xxhash/xxhash.h
Other components
- Assembler user
Connections 26
- Assembler user → Command dispatcher: runs
- Command dispatcher → Assembly command: dispatches
src/main.cpp - Command dispatcher → Local assembly: dispatches
src/main.cpp - Command dispatcher → Iterative extraction: dispatches
src/main.cpp - Command dispatcher → Library building: dispatches
src/main.cpp - Assembler user → Sequence readers: supplies reads
- Sequence readers → Sequence libraries: loads libraries
- Sequence libraries → Packed sequences: packs sequences
- Sequence readers → Read sorting: provides reads
- Read sorting → SDBG construction: sorts for graph
- SDBG construction → Succinct de Bruijn graph: constructs graph
- Assembly command → Succinct de Bruijn graph: assembles from
- Assembly command → Graph cleaning: runs algorithms
src/assembly/all_algo.h - Assembly command → Contig output: writes contigs
src/main_assemble.cpp - Contig output → Assembler user: produces contigs
- Local assembly → Contig hash mapper: builds mapper
src/localasm/local_assemble.cpp - Local assembly → Local contig graph: assembles graph
src/localasm/local_assemble.cpp - Local assembly → Sequence libraries: reads libraries
src/localasm/local_assemble.cpp - Contig hash mapper → Contig reader: loads contigs
src/localasm/hash_mapper.cpp - Local contig graph → Hash graph: uses graph
- Unitig graph → Succinct de Bruijn graph: uses graph data
- Unitig graph → Bit-vector primitives: uses bit vectors
src/assembly/unitig_graph.cpp - Local contig graph → K-mer representation: uses k-mers
- Local contig graph → Parallel hash map: uses map
- Contig hash mapper → Parallel hash map: uses map
- Parallel hash map → Hash functions: hashes keys