bb_blast_best_hit - ampinzonv/BB3 GitHub Wiki

Function: bb_blast_best_hit

Extract the best BLAST hit per (qseqid, sseqid) pair from a tabular BLAST output.


๐Ÿ” Description

This function parses a BLAST output file (in outfmt 6 with 14 columns) and retains only the best hit for each unique (query, subject) pair. The best hit is determined by the lowest e-value; if multiple hits share the same e-value, the one with the highest bitscore is selected.


๐Ÿ“ฅ Input

  • A BLAST result file in tabular format (outfmt 6) with 14 columns.
  • Use --input - for STDIN.

๐Ÿ“ค Output

  • One line per unique (qseqid, sseqid) pair, representing the best hit.

๐Ÿงช Examples

Filter best hits from a file:

bb_blast_best_hit --input blast_results.tsv

Using a pipeline:

cat blast_results.tsv | bb_blast_best_hit --input -

Save output:

bb_blast_best_hit --input blast_results.tsv --outfile best_hits.tsv

โš™๏ธ Usage

bb_blast_best_hit --input FILE [--outfile FILE] [--quiet] [--force]

๐Ÿงต Options

Option Description
--input FILE Input BLAST file (outfmt 6, 14 columns) or - for STDIN (required)
--outfile FILE Output file (optional, default: STDOUT)
--quiet Suppress log messages
--force Overwrite output file if it exists

๐Ÿ“Œ Notes

  • Input must include the following 14 columns:
    qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore qlen slen
  • If no valid hits are found or input is malformed, the function will return an error.