| Crates.io | bamslice |
| lib.rs | bamslice |
| version | 0.1.7 |
| created_at | 2025-10-29 19:27:28.313837+00 |
| updated_at | 2026-01-15 03:48:46.068167+00 |
| description | Extract byte ranges from BAM files and convert to interleaved FASTQ format for parallel processing |
| homepage | |
| repository | https://github.com/nebiolabs/bamslice |
| max_upload_size | |
| id | 1907232 |
| size | 111,014 |
Extract specific byte ranges from BAM/CRAM files and convert to interleaved FASTQ format. Designed for parallel processing across compute nodes without requiring pre-indexing.
samtools fastqcargo build --release
Binary: target/release/bamslice
bamslice \
--input input.bam \
--start-offset 0 \
--end-offset 10000000 \
--output output.fastq
--input, -i: Input BAM--start-offset, -s: Starting byte offset (will find next BGZF block at or after this offset)--end-offset, -e: Ending byte offset (will stop when reaching a block at or after this offset)--output, -o: Output FASTQ file (default: stdout)Extract first half of file:
FILE_SIZE=$(stat -f%z input.bam) # macOS
# FILE_SIZE=$(stat -c%s input.bam) # Linux
HALF=$((FILE_SIZE / 2))
bamslice -i input.bam -s 0 -e $HALF -o first_half.fastq
Extract second half (no overlap!):
bamslice -i input.bam -s $HALF -e $FILE_SIZE -o second_half.fastq
Output to stdout:
bamslice -i input.bam -s 0 -e 1000000 | head -n 4
The tool uses byte ranges, making it trivial to parallelize without coordination
See example.nf for a pipeline that pipes bamslice output through fastp for QC/filtering.
nextflow run example.nf --bam input.bam --chunk_size 104857600
0x1f 0x8b 0x08)end_offsetRun the test suite to verify correctness:
cargo test
lint the codebase:
make lint
Run a coverage analysis:
make coverage && open target/coverage/html/index.html
Profile the application with samply (requires cargo install samply):
make perf
Run the performance benchmark:
make bench && open target/criterion/report/index.html
Release a new version:
echo "update Cargo.toml with new version"
git commit -m 'update package version to vX.Y.Z'
git tag -m 'tag for release' vX.Y.Z
git push --follow-tags
cargo publish
AGPLv3 - See LICENSE file for details