script in R to convert DNA to RNA sequence
1
0
Entering edit mode
4.1 years ago

Assume you have the following DNA sequence ACAGTCGACTAGCTTGCACGTAC,how to write an R function script called “DNA_to_RNA.R” to convert this sequence to an RNA sequence, assuming perfect transcription process without any loss in the DNA sequence bases. You have to loop over the whole sequence and check each character in the DNA sequence separately before converting to an RNA sequence.

sequencing • 3.6k views
ADD COMMENT
1
Entering edit mode

Just change T to U no ? Why would you do that ? Homework ?

ADD REPLY
0
Entering edit mode

yes but i think i need to do a loop

ADD REPLY
0
Entering edit mode

Please show some effort. What did you try?

ADD REPLY
0
Entering edit mode

i am trying with the "for loop" now

ADD REPLY
0
Entering edit mode
 x="ACAGTCGACTAGCTTGCACGTAC"
> for (variable in x) {
+     gsub("T", "U", x)
+ }

this does not work

ADD REPLY
0
Entering edit mode

That is not how for-loops work. Please spend some time on baic R. gsub already operates on the entire DNA string. The string, or x is a single element so you cannot loop through it.

ADD REPLY
2
Entering edit mode
4.1 years ago
ATpoint 82k
> DNA <- c("TGGATTTCCCCGATCGA")
> gsub("T", "U", DNA)
[1] "UGGAUUUCCCCGAUCGA"
ADD COMMENT

Login before adding your answer.

Traffic: 1583 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6