Python Strings for Bioinformatics
Core Patterns
# Reverse complement — use maketrans, NOT chained replace()
complement_table = str.maketrans('ATGC', 'TACG')
rev_comp = dna.translate(complement_table)[::-1]
# Transcription
rna = dna.replace('T', 'U')
# Extract all codons
codons = [mrna[i:i+3] for i in range(0, len(mrna), 3)]
# GC content
gc = (seq.count('G') + seq.count('C')) / len(seq)
# Validate DNA
is_valid = all(c in 'ATGC' for c in seq.upper())
Motif Finding
[Description truncada. Veja o README completo no GitHub.]