Sequences, alignments, and representations
Parse biological sequences, create transparent features, and use alignment as a baseline for learned similarity.
A biological sequence is ordered and evolutionary history makes observations dependent. Before using embeddings, build interpretable representations: length, GC content, amino-acid composition, and k-mer counts. Use Biopython to parse a small public FASTA file and verify that alphabet, identifiers, and lengths match expectations. Compare two sequences with local or global alignment and explain what substitutions and gaps mean under the chosen scoring scheme. Then train a simple logistic regression on k-mer frequencies for a small, clearly labeled sequence task. Split by homologous group or source organism where possible; a random row split can place near-duplicate relatives on both sides and inflate performance. BLAST provides a strong retrieval baseline based on sequence similarity, so compare learned predictions with nearest matches rather than treating the classifier as inherently more modern or informative. Inspect disagreements manually. Learned representations may capture useful regularities, but they do not erase phylogeny, annotation error, or sampling bias. The biological split is often a more consequential modeling choice than the classifier.
Try it yourself
- Parse a small FASTA file with Biopython and compute composition plus k-mer features.
- Align selected pairs and inspect BLAST results or a small local BLAST database.
- Compare a grouped split with a random split for a simple classifier.
You’re ready to move on when…
- Parser preserves identifiers and sequence lengths.
- Evaluation groups related sequences to limit homology leakage.
- Report compares classifier errors with an alignment or BLAST baseline.