Question
Using the two following methods; findFrequency and hasMutation; how do I write a method that counts the number of mutated DNA sequences that occur within
Using the two following methods; findFrequency and hasMutation; how do I write a method that counts the number of mutated DNA sequences that occur within an array. This must be done by building on the technique for findFrequency and adding calls to hasMutation.
Parameters:
seqArray - An array of DNA sequences, as described in the CSC110 Assignment 5 instructions.
Returns:
The number of mutated DNA sequences found within the array.
Note that DNA sequences contain two to four of the following characters: {A,C,G,T} in any order. A mutated sequence contains adjacent repeated characters , so ACCG, TTCCA, and AACC are all mutated sequences.
public static int findFrequency(String target, String[] strings) {
int maxFrequency = 0;
for ( String DNACode : strings ) {
if ( DNACode.equals(target) ) {
maxFrequency = maxFrequency + 1;
}
}
return maxFrequency;
}
public static boolean hasMutation(String DNACode) {
for ( int i = 0 ; i < DNACode.length() ; i++ ) {
for ( int j = i + 1 ; j < DNACode.length() ; j++ ) {
if ( DNACode.charAt(i) == DNACode.charAt(j) ) {
return true;
}
}
}
return false;
}
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