That’s a great idea! Creating a simple DNA sequencer is an excellent beginner project for a bioinformatics portfolio. You’ll get to show off both bio and coding skills, and it’s a neat way to demonstrate your understanding of DNA sequence analysis.
🚀 Project: Basic DNA Sequencer in Python
🎯 Project Goal
Build a program that takes DNA sequences (e.g., from a FASTA file or user input) and performs basic bioinformatics tasks:
- Validate the DNA sequence
- Compute nucleotide frequencies (A, T, G, C)
- Transcribe DNA to RNA
- Translate DNA to a protein
- Find reverse complements
- Search for motifs (e.g. restriction sites or custom subsequences)
- Generate summary statistics
🧪 Technologies Needed
- Python (beginner-friendly, widely used in bioinformatics)
- Optional: Biopython (for extended functionality)
🧬 Step-by-Step Code
Below is a simple version of a sequencer without external libraries.
Step 1: Get the DNA sequence
def get_dna_sequence():
seq = input("Enter a DNA sequence: ").upper()
return seq.replace(" ", "").replace("\n", "")
Step 2: Validate DNA sequence
def validate_dna(seq):
valid_nucleotides = set("ATGC")
return all(base in valid_nucleotides for base in seq)
Step 3: Count nucleotides
def count_nucleotides(seq):
return {
"A": seq.count("A"),
"T": seq.count("T"),
"G": seq.count("G"),
"C": seq.count("C")
}
Step 4: Transcribe to RNA
def transcribe_dna_to_rna(seq):
return seq.replace("T", "U")
Step 5: Reverse complement
def reverse_complement(seq):
complement = {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G'}
return ''.join(complement[base] for base in reversed(seq))
Step 6: Translate DNA to protein (using codons)
You’ll use a codon table:
codon_table = {
'ATA':'I', 'ATC':'I', 'ATT':'I', 'ATG':'M',
'ACA':'T', 'ACC':'T', 'ACG':'T', 'ACT':'T',
'AAC':'N', 'AAT':'N', 'AAA':'K', 'AAG':'K',
'AGC':'S', 'AGT':'S', 'AGA':'R', 'AGG':'R',
'CTA':'L', 'CTC':'L', 'CTG':'L', 'CTT':'L',
'CCA':'P', 'CCC':'P', 'CCG':'P', 'CCT':'P',
'CAC':'H', 'CAT':'H', 'CAA':'Q', 'CAG':'Q',
'CGA':'R', 'CGC':'R', 'CGG':'R', 'CGT':'R',
'GTA':'V', 'GTC':'V', 'GTG':'V', 'GTT':'V',
'GCA':'A', 'GCC':'A', 'GCG':'A', 'GCT':'A',
'GAC':'D', 'GAT':'D', 'GAA':'E', 'GAG':'E',
'GGA':'G', 'GGC':'G', 'GGG':'G', 'GGT':'G',
'TCA':'S', 'TCC':'S', 'TCG':'S', 'TCT':'S',
'TTC':'F', 'TTT':'F', 'TTA':'L', 'TTG':'L',
'TAC':'Y', 'TAT':'Y', 'TAA':'_', 'TAG':'_', # _ is stop
'TGC':'C', 'TGT':'C', 'TGA':'_', 'TGG':'W',
}
And translation function:
def translate_dna(seq):
protein = ''
for i in range(0, len(seq)-2, 3):
codon = seq[i:i+3]
if codon in codon_table:
protein += codon_table[codon]
else:
protein += 'X' # Unknown/invalid codon
return protein
Step 7: Motif Search
def find_motif(seq, motif):
positions = []
for i in range(len(seq) - len(motif) + 1):
if seq[i:i+len(motif)] == motif:
positions.append(i)
return positions
🧰 Putting It All Together
def main():
seq = get_dna_sequence()
if not validate_dna(seq):
print("Invalid DNA sequence. Only A, T, G, and C are allowed.")
return
print("Nucleotide Counts:", count_nucleotides(seq))
print("Transcribed RNA:", transcribe_dna_to_rna(seq))
print("Reverse Complement:", reverse_complement(seq))
print("Protein Sequence:", translate_dna(seq))
motif = input("Enter motif to search (e.g., ATG): ").upper()
positions = find_motif(seq, motif)
print(f"Motif '{motif}' found at positions: {positions}")
if __name__ == "__main__":
main()
🧪 Sample Output
Enter a DNA sequence: ATGTTTGGCAAA
Nucleotide Counts: {'A': 3, 'T': 4, 'G': 3, 'C': 1}
Transcribed RNA: AUGUUUGGCAAA
Reverse Complement: TTTGCCAAACAT
Protein Sequence: MFGK
Enter motif to search (e.g., ATG): TT
Motif 'TT' found at positions: [2, 3]
🎓 Portfolio Ideas
Add extras to impress:
- Accept input from a FASTA file
- Output in CSV or JSON
- Use Biopython to handle I/O and translation
- Create a web GUI (e.g., with Streamlit)
- Add plotting with matplotlib/seaborn for nucleotide frequencies
📁 Suggested File Structure
dna_sequencer/
│
├── main.py
├── codon_table.py
├── utils.py
├── sample.fasta
├── README.md
└── requirements.txt
📌 Tips for Your Portfolio
- Add comments and sample outputs.
- Showcase your problem-solving approach.
- Include unit tests if possible—it demonstrates best practices!
Would you like this project template as a GitHub repo starter or a GUI version (e.g., with Streamlit)?