blast2sam-pl
Quick Start
- Command:
blast2sam.pl [-s] [-d] input.blast > output.sam - Local executable:
/home/vimalinx/miniforge3/envs/bio/bin/blast2sam.pl - Full reference: See references/help.md
When To Use This Tool
- Convert legacy default-format
blastntext output into SAM records. - Bridge older BLAST workflows into
samtoolsor other SAM/BAM-aware tooling. - Emit aligned query sequence with
-swhen downstream tools need SAM field 10 populated. - Emit dummy quality scores with
-dwhen a downstream parser insists on SAM field 11.
Common Patterns
# 1) Convert legacy BLASTN text output into headerless SAM
blast2sam.pl \
alignments.blast > alignments.sam
# 2) Include aligned query sequence plus dummy qualities
blast2sam.pl \
-sd \
alignments.blast > alignments.with-seq.sam
# 3) Add a SAM header afterwards for downstream tools that require one
blast2sam.pl -sd alignments.blast > alignments.sam
samtools view -hT reference.fa alignments.sam > alignments.with-header.sam
Recommended Workflow
- Generate legacy
blastnoutput in the default pairwise text format, not tabular or XML output. - Convert it with
blast2sam.pl, adding-sif downstream tools need sequence and-dif they also need quality strings. - Add a SAM header separately if the next tool expects one.
- Inspect a few records before batch conversion, especially strand flag, position, CIGAR, and sequence fields.
Guardrails
- This parser is tailored to legacy plain-text
blastnoutput; it is not the right tool for BLAST tabular, XML, JSON, or generic BLAST+-outfmtoutputs. --helpworks via PerlGetopt::Std, but-helpis wrong here and is split into-h -e -l -p, which produces unknown-option errors.-sprints the aligned query sequence, not necessarily the original full read sequence from FASTQ input.-dfills SAM field 11 with dummyIcharacters (Phred 40 style); use that only when fake quality scores are acceptable.- Output is headerless and queries without alignments are omitted rather than emitted as unmapped SAM records.