Question: In java only public class Part1 { public String findSimpleGene (String dna) { String Gene =; //Null string int startdna = dna.indexOf(ATG); //start codon if
In java only
public class Part1 {
public String findSimpleGene (String dna) {
String Gene =""; //Null string
int startdna = dna.indexOf("ATG"); //start codon
if (startdna ==-1){
//if no ATG
return "";
}
int stopdna = dna.indexOf("TAA", startdna + 3);
//stop codon - start at index and take next 3 characters
if (stopdna ==-1){
//if no TAA
return "";
}
Gene = dna.substring(startdna, stopdna+3);
//collect characters between startdna & stop at stopdna
//index and take next 3 characters
int g = Gene.length();
//Find length of Gene with int g
if (g % 3 == 0){
//find if g is divisible by 3
return Gene ;
}
if (g % 3 != 0){
//find if g is divisible by 3
return "" ;
}
return Gene;
}
public void testSimpleGene(){
String dna="AACGTCATGGAATCAATCTAA";
System.out.println("DNA strand is " + dna);
String gene= findSimpleGene(dna);
System.out.println("Gene is " + gene);
dna="AACATGTGCGTA";
System.out.println("DNA strand is " + dna);
gene= findSimpleGene(dna);
System.out.println("Gene is " + gene);
} }

Then
Modify the findSimpleGene method to work with DNA strings that are either all uppercase letters such as ATGGGTTAAGTC or all lowercase letters such as gatgctataat. Calling findSimpleGene with ATGGGTTAAGTC should return the answer with uppercase letters, the gene ATGGGTTAA, and calling findSimpleGene with gatgctataat should return the answer with lowercase letters, the gene atgctataa. HINT: there are two string methods toUpperCase() and toLowerCase(). If dna is the string ATGTAA then dna.toLowerCase() results in the string atgtaa.
3. The method findSimpleGene has one parameter for the DNA string named dna. Modify findSimpleGene to add two additional arameters, one named startCodon for the start codon and one named stopCodon for the stop codon. What additional changes do you need to make for the program to compile? After making all changes, run your program to check that you get the same output as before
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
