dna_sequence <- "ATGGCCATTGTAATGGGCCGCTGAAAGGGTGCCCGATAG"
transcribe_dna_to_rna <- function(dna) {
dna <- toupper(dna)
rna <- chartr("T", "U", dna)
return(rna)
}
rna_sequence <- transcribe_dna_to_rna(dna_sequence)
cat("RNA Sequence: ", rna_sequence, "\n")
## RNA Sequence: AUGGCCAUUGUAAUGGGCCGCUGAAAGGGUGCCCGAUAG
codon_table <- c(
UUU = "F", UCU = "S", UAU = "Y", UGU = "C",
UUC = "F", UCC = "S", UAC = "Y", UGC = "C",
UUA = "L", UCA = "S", UAA = "Stop", UGA = "Stop",
UUG = "L", UCG = "S", UAG = "Stop", UGG = "W",
CUU = "L", CCU = "P", CAU = "H", CGU = "R",
CUC = "L", CCC = "P", CAC = "H", CGC = "R",
CUA = "L", CCA = "P", CAA = "Q", CGA = "R",
CUG = "L", CCG = "P", CAG = "Q", CGG = "R",
AUU = "I", ACU = "T", AAU = "N", AGU = "S",
AUC = "I", ACC = "T", AAC = "N", AGC = "S",
AUA = "I", ACA = "T", AAA = "K", AGA = "R",
AUG = "M", ACG = "T", AAG = "K", AGG = "R",
GUU = "V", GCU = "A", GAU = "D", GGU = "G",
GUC = "V", GCC = "A", GAC = "D", GGC = "G",
GUA = "V", GCA = "A", GAA = "E", GGA = "G",
GUG = "V", GCG = "A", GAG = "E", GGG = "G"
)
translate_rna_to_protein <- function(rna) {
rna <- toupper(rna)
codons <- unlist(strsplit(rna, "(?<=.{3})", perl=TRUE))
protein <- sapply(codons, function(codon) codon_table[codon])
protein <- protein[protein != "Stop"]
return(paste(protein, collapse=""))
}
protein_sequence <- translate_rna_to_protein(rna_sequence)
cat("Protein Sequence: ", protein_sequence, "\n")
## Protein Sequence: MAIVMGRKGAR
mutate_dna <- function(dna, position, new_base) {
substr(dna, position, position) <- new_base
return(dna)
}
mutated_dna <- mutate_dna(dna_sequence, 10, "A")
mutated_rna <- transcribe_dna_to_rna(mutated_dna)
mutated_protein <- translate_rna_to_protein(mutated_rna)
cat("Mutated DNA Sequence: ", mutated_dna, "\n")
## Mutated DNA Sequence: ATGGCCATTATAATGGGCCGCTGAAAGGGTGCCCGATAG
cat("Mutated RNA Sequence: ", mutated_rna, "\n")
## Mutated RNA Sequence: AUGGCCAUUAUAAUGGGCCGCUGAAAGGGUGCCCGAUAG
cat("Mutated Protein Sequence: ", mutated_protein, "\n")
## Mutated Protein Sequence: MAIIMGRKGAR
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.3
library(gridExtra)
## Warning: package 'gridExtra' was built under R version 4.3.3
dna_df <- data.frame(Position = 1:nchar(dna_sequence), Base = strsplit(dna_sequence, NULL)[[1]])
rna_df <- data.frame(Position = 1:nchar(rna_sequence), Base = strsplit(rna_sequence, NULL)[[1]])
protein_df <- data.frame(Position = seq(1, nchar(protein_sequence) * 3, by = 3), AminoAcid = strsplit(protein_sequence, NULL)[[1]])
dna_plot <- ggplot(dna_df, aes(x = Position, y = 1, label = Base, color = Base)) +
geom_text(size = 6) +
scale_color_manual(values = c("A" = "red", "T" = "orange", "G" = "blue", "C" = "purple")) +
theme_minimal() +
labs(title = "DNA Sequence") +
theme(axis.text.y = element_blank(), axis.ticks.y = element_blank(), axis.title.y = element_blank())
rna_plot <- ggplot(rna_df, aes(x = Position, y = 1, label = Base, color = Base)) +
geom_text(size = 6) +
scale_color_manual(values = c("A" = "red", "U" = "turquoise", "G" = "blue", "C" = "purple")) +
theme_minimal() +
labs(title = "RNA Sequence") +
theme(axis.text.y = element_blank(), axis.ticks.y = element_blank(), axis.title.y = element_blank())
protein_plot <- ggplot(protein_df, aes(x = Position, y = 1, label = AminoAcid, color = AminoAcid)) +
geom_text(size = 6) +
scale_color_manual(values = rainbow(nchar(protein_sequence))) +
theme_minimal() +
labs(title = "Protein Sequence") +
theme(axis.text.y = element_blank(), axis.ticks.y = element_blank(), axis.title.y = element_blank())
combined_plot <- grid.arrange(dna_plot, rna_plot, protein_plot, ncol = 1)
# Grafiklerin kaydedilmesi
ggsave("dna_rna_protein_plots.png", combined_plot, width = 10, height = 15, units = "in", dpi = 300)