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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!