omics.co.in logo omics.co.in

5: Heuristic Sequence Searching: BLAST & FASTA Algorithms

Tested Stacks: GATK 4.6.1 Samtools 1.21 Nextflow 24.10 Seurat v5.1 Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
📚 Chapter 5 of 13 0% Course Completed

Chapter 5: Heuristic Sequence Searching: BLAST & FASTA Algorithms

Searching a query sequence against the NCBI GenBank database containing hundreds of millions of sequences using the exact Smith-Waterman algorithm would require hours or days per query. Published in 1990 by Altschul, Gish, Miller, Myers, and Lipman, the Basic Local Alignment Search Tool (BLAST) introduced heuristic approximations that accelerate database searches by three orders of magnitude while preserving statistical rigor.

The Karlin-Altschul E-Value Equation

The Expect value (E-value) represents the number of distinct alignments with a score equal to or greater than \(S\) that are expected to occur in a database search purely by chance:

E = K × m × n × e-λS

Where \(m\) is query length, \(n\) is total database size (effective search space), and \(K\) and \(\lambda\) are Karlin-Altschul statistical parameters. An E-value of \(10^{-10}\) indicates an astronomically low probability of random occurrence, confirming genuine biological homology.

1. The Three Heuristic Phases of BLAST

  • Phase 1: Seeding (Word Generation): For protein queries, BLAST generates all overlapping words of length \(W\) (default \(W=3\)). It compiles a list of all "neighborhood words" that score ≥ threshold \(T\) when compared against the query word using BLOSUM62.
  • Phase 2: Database Scanning: BLAST scans the database to rapidly locate exact occurrences of words in the neighborhood list using a deterministic finite automaton or hash lookup.
  • Phase 3: Extension: When a seed match occurs, BLAST initiates ungapped two-hit extension in both directions, calculating High-Scoring Segment Pairs (HSPs) until the running alignment score drops by a cutoff \(X\) below the maximum achieved. Only qualifying HSPs proceed to gapped alignment.

2. Production BLAST+ Command-Line Execution

# 1. Build a local BLAST database from a multifasta file
makeblastdb \
    -in uniprot_sprot.fasta \
    -dbtype prot \
    -title "SwissProt_DB" \
    -out /databases/swissprot

# 2. Run blastp with tabular custom output (outfmt 6)
blastp \
    -query query_protein.fasta \
    -db /databases/swissprot \
    -evalue 1e-5 \
    -num_threads 8 \
    -outfmt "6 qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore stitle" \
    -out blast_results.tsv
⚠️

Common Pitfalls & Troubleshooting Checklist

  • Java Heap Exhaustion (GATK / Picard): If processes terminate with java.lang.OutOfMemoryError, set your environment variable explicitly: export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp".
  • Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with samtools index -@ 4 sample.bam.
  • Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority: conda config --set channel_priority strict.
  • Chromosome Naming Contamination: Always verify whether reference FASTA headers use chr1 or 1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.
📝 Propose Edit on GitHub ↗