Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Reading a DNA.txt file and trying to build a string from that, and then converting that string into RNA and then sending that into an
Reading a "DNA.txt" file and trying to build a string from that, and then converting that string into RNA and then sending that into an "RNA.txt" file
code at point of question submission:
public static void DNA2RNA(String DNAFile, String RNAFile) throws IOException{ //DNA to RNA, generates RNA.txt //initialization BufferedReader br = new BufferedReader(new FileReader("src/DNA.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("src/RNA.txt")); StringBuilder dnaBuilder = new StringBuilder(); String dnaRead;//string builder dna will be formed into a string here String RNA = "";//empty rna string to be filled after translation StringBuilder buildRNA = new StringBuilder(); while((dnaRead = br.readLine()) != null) {//buffer will copy dna txt to dna to dnaRead dnaBuilder.append(dnaRead); } ////////////////////////////////// //when program gets here, all txt from the file has been read and copied into the string //now translate dna to rna for (int i = 0; i < dnaRead.length(); i++){ if(dnaRead.charAt(i)== 'C') { bw.write(RNA + "G"); } if(dnaRead.charAt(i)== 'G'){ bw.write(RNA + "C"); } if(dnaRead.charAt(i) == 'A'){ bw.write(RNA + "U"); } if(dnaRead.charAt(i) == 'T'){ bw.write(RNA + "A"); } } bw.close();br.close(); ///////////////////////////////////////////////////////////////// //exception handler dont touch // try { // DNA2RNA(DNAFile, RNAFile); // }catch (IOException IOE){ // System.out.println("IO exception " + IOE); // } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started