Skillversitas

Quick Guide and Next Steps

This chapter is the fast reference for everything covered, plus a roadmap for where to go next: which module for which job, the most common one-liners, and the order to learn the remaining pieces.

Module Map

NeedModuleKey calls
Read/write sequencesBio.SeqIOparse, read, write, convert
Sequence operationsBio.Seqtranscribe, translate, reverse_complement
AnnotationsBio.SeqFeaturefeatures, location, qualifiers
Pairwise alignmentBio.AlignPairwiseAligner
Multiple alignmentBio.AlignIOread, write, columns
BLAST resultsBio.Blast.NCBIXMLparse hits/hsps
NCBI queriesBio.Entrezesearch, efetch, esummary
SQL sequence storeBio.BioSQLDBUtils.connect, add_sequence
MotifsBio.motifscreate, parse, score
ClusteringBio.Clusterdistance, cluster
StructuresBio.PDBPDBParser, Superimposer
TreesBio.Phyloread, draw
Population statsBio.PopGenallele frequencies, pi, Tajima's D

Common One-Liners

from Bio import SeqIO
from Bio.Seq import Seq

# count records and total length
recs = list(SeqIO.parse("data.fasta", "fasta"))
print(len(recs), sum(len(r) for r in recs))

# reverse complement
str(Seq("ATGC").reverse_complement())

# translate a CDS
str(Seq("ATGAAATAA").translate())

# extract CDS translations from GenBank
for f in SeqIO.read("gene.gb", "genbank").features:
    if f.type == "CDS":
        print(f.qualifiers.get("translation", [""])[0][:30])

A Learning Path

  1. Sequences and I/O (Seq, SeqIO, SeqFeature) - the foundation; do a dozen small parsing exercises.
  2. Alignment (PairwiseAligner, AlignIO) - compare real sequences, read scores and identity.
  3. Databases (Entrez) - automate esearch/efetch with caching; build a small downloader.
  4. One deep module - PDB, Phylo, or PopGen - depending on your field, with a real dataset.
  5. Integration - a CLI app that chains several modules (this chapter's seqstats as the template).

Pitfalls to Avoid

  • Forgetting the format argument to SeqIO - always pass it explicitly.
  • Confusing Bio (import name) with biopython (package name).
  • Reading qualifiers without defaults - GenBank qualifiers are lists; use .get(key, [])[0] safely.
  • Leaking memory with list(SeqIO.parse(huge_file)) when a generator would do.
  • Hitting NCBI without an API key or without caching - rate limits and politeness.

Summary

Use the module map to find the right tool (SeqIO for I/O, PairwiseAligner for alignment, Entrez for NCBI, PDB for structures), keep the one-liners as a cheatsheet, follow the staged learning path from sequences to a chained CLI app, and avoid the classic pitfalls - explicit formats, safe qualifier access, generators over lists, and polite Entrez usage.