How do I find mutation in DNA using java function An organis
How do I find mutation in DNA using java function?
An organism\'s DNA is responsible for how it looks, how it behaves as well as its physiology. Figuring out how genes mutate can help us understand alien evolution as well as treat earthly diseases better. It\'s the year 2056 & you\'ve obtained a motherload of sequenced genetic material from a research laboratory on Mars. Interesting relationships can be found by studying how genetic sequences are related to one another through mutations. Your task is to write a method - findMutationDistance that takes in this genetic data bank as a large collection of sequences (bank) and the 2 sequences (start & end) whose mutation distance needs to be calculated. This method should return the shortest mutation distance between the two sequences - start and end. If, for whatever reason such a mutation is not possible, the method should return -1.
Constraints:
Martian biological material contains genetic sequences that are all 8 characters in length. The only allowed characters in the sequence are the 4 nucleotide bases of a DNA strand - Adenine, Cytosine, Guanine & Thymine, represented by the letters \'A\', \'C\', \'T\' & \'G\'. For eg, \'AATTGGCC\' represents a possible genetic sequence in the data bank.
For a sequence to be a part of the mutation distance, it must contain all but 1 of the nucleotide bases as its preceding sequence in the same order AND be present in the bank of valid sequences. For eg. \'AATTGGCC\' -> \'AATTGGCA\' can be considered a valid mutation if \'AATTGGCA\' is present in the bank. Another example of a valid mutation can be \'AATTGGCC\' -> \'TATTGGCC\' -> \'TTTTGGCC\' -> \'TTTTGGCA\' if \'TATTGGCC\', \'TTTTGGCC\' & \'TTTTGGCA\' are present in the bank of valid genetic sequences. In this example, the mutation distance is 3, as it took 3 mutations to go from \'AATTGGCC\' to \'TTTTGGCA\'.
You can assume that the bank will contain unique sequences, and the start sequence may or may not be a part of the bank.
The function is
static int findMutationDistance(String start, String end, String[] bank) {
}
Solution
import edu.duke.*; import java.io.*; public class FindMultiGenes { public String findGenes(String dnaOri) { String gene = new String(); String dna = dnaOri.toLowerCase(); int start = -1; while(true){ start = dna.indexOf(\"atg\", start); if (start == -1) { break; } int stop = findStopCodon(dna, start); if(stop > start){ String currGene = dnaOri.substring(start, stop+3); System.out.println(\"From: \" + start + \" to \" + stop + \"Gene: \" +currGene);} } return gene; } private int findStopCodon(String dna, int start){ for(int i = start + 3; i