Practical 2: Genomics, systems biology and multi-omics
Learning objectives
Parse FASTA records; validate sequence symbols; calculate called-base GC content; construct a reverse complement.
Biological question and data
How do file structure and unknown bases affect a sequence summary?
FASTA inputs contain only A, C, G, T and N; these teaching records have no quality scores. N is unknown and is excluded from the GC denominator.
No biological download is required. Numerical inputs are hypothetical, not observed animal data. The runnable examples use base R. Count and abundance units are specified where used.
1. Parse explicit records
Use the local teaching parser, which rejects missing headers, duplicate IDs and invalid bases.
Wrapped sequence lines are joined within their records. Sequence length includes unknown bases.
2. Calculate called-base summaries
Count unknowns separately. An all-unknown sequence has no estimable called-base GC proportion.
Show R code
summary_one <-function(s) { x <-strsplit(s,"")[[1]]; called <- x%in%c("A","C","G","T")c(length=length(x),called=sum(called),unknown=sum(!called),GC=if(any(called))mean(x[called]%in%c("G","C")) elseNA_real_)}result <-t(vapply(sequences,summary_one,numeric(4)))result
These summaries answer different questions. Excluding unknown positions gives a called-base composition; it does not recover the composition of unobserved positions. Report the unknown fraction alongside it.
5. Preserve orientation and record context
Reverse complementation changes orientation, while reversing alone does not complement bases. A double reverse complement should recover a valid input sequence under the supported alphabet. Before comparing records, check whether each represents a complete sequence or a region, what the header identifies and whether ambiguous symbols are supported by the parser. Restricting to A/C/G/T/N is a teaching contract, not the complete vocabulary of all biological sequence files.
Interpretation challenge
Two sequences have identical called-base GC fractions but one has 40% unknown bases. Are their measurement qualities equivalent?
Suggested reasoning
No. The fraction describes only called positions. Unknown coverage, sequence length and the observation process must accompany the composition statistic.
Interpretation and limits
Called-base GC is a descriptive proportion, not sequencing quality or coding potential. Unknown bases and selected regions can make whole-record comparisons misleading. This parser is intentionally small, not a general FASTA library.
Exercises
Recalculate GC including N in the denominator; explain the change.
Add a duplicate header.
Why does complementing without reversing give a different object?
Suggested answers
It decreases to 6/10, treating unknowns as if they were called non-GC bases.
The parser rejects the ambiguous identifier.
A reverse complement changes strand orientation; complement alone preserves the original character order.