bb_get_fasta_header - ampinzonv/BB3 GitHub Wiki

Function: bb_get_fasta_header

Extract FASTA headers from a file or from standard input (STDIN).


๐Ÿ” Description

This function retrieves only the header lines (those starting with >) from a FASTA file. It can read from a file or from a pipeline (using - as input), making it ideal for use in command-line workflows.

๐Ÿ“ฅ Input

  • A FASTA file containing biological sequences.
  • Can also read from STDIN using --input -.

๐Ÿ“ค Output

  • A list of headers (each line starting with >).
  • Output is sent to STDOUT by default, or to a file using --outfile.

๐Ÿงช Examples

Extract headers from a file:

bb_get_fasta_header --input sequences.fasta

Extract headers from a stream:

cat sequences.fasta | bb_get_fasta_header --input -

Save headers to a file:

bb_get_fasta_header --input sequences.fasta --outfile headers.txt

โš™๏ธ Usage

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

๐Ÿงต Options

Option Description
--input FILE Input FASTA file, or - to read from STDIN (required)
--outfile FILE Path to output file (optional, default: STDOUT)
--quiet Suppress informational log messages
--force Overwrite output file if it exists

๐Ÿ“Œ Notes

  • If running on macOS, grep behaves the same as on Linux, so no special handling is required.
  • This function is useful when preparing lists of entries for filtering or extracting specific sequences.