1. Implement a function to compute the Hamming Distance between two DNA sequence
ID: 3902530 • Letter: 1
Question
1. Implement a function to compute the Hamming Distance between two DNA sequences. The function needs two DNA sequences as inputs. The output should be the Hamming distance between the two input DNA sequences (10 points). Some test cases are i, Output 2, when inputs are AAAAAA and ACAAAC ii. Output 1, when inputs are AAAAAA and ACAAAA ii. Output 6, when inputs are AAAAAA and TCGCTG 2. Implement a function to compute the TotalDistancev DNA) method in the context of median string finding problem. (30 points The function requires two inputs. v: a given k-mer. DNA a set of DNA sequences. You can use array to store the DNA sequences * The function should have two outputs . Best match (along with the position: use O-based meaning 0 indicates first position) of the given k-mer (v) in each DNA sequence in DNA The distance Test Case 1 For the 10 DNA sequences in file Sequences.fa given in BB, and v TAGATCCGAA, a sample output is. TAGATCTCAA 171 TGGATCCGAA 471 TAAATCCGAA 331 TAGGTCCAAA 21 2 TAGATTCGRA 1 TAGATCCOTA 70 1 TAGATCCAAA 161 TCGATCCGAA 65 1 Total distance 11 Test Case 2 For the 10 DNA sequences in file Sequences.fa given in BB, and v AAAAAA, a sample output is. Bestmatch Poa Hating Distane 30 2 34 2 25 2 17 1 26 2 AATCGA 54 2 19 3 10 1 Total distance 21 3. Implement the Brute Force Median String Search algorithm [No need to use a tree. Test the given algorithm for the cases of 4-mer, 5-mer and 6-mer with the given Sequences.fa file. [60 points Test Case 1: For sequences in Sequences.fa, the motif of length 4 is GATC Test Case 2:For sequences in Sequences fa, the motif of length 5 is CCGAA Test Case 3 For sequences in Sequences fa, the motif of length 6 is TCCGAAExplanation / Answer
#include <iostream>
using namespace std;
// taking two strings as input and returning integer
int hammingDist(string one, string two)
{
// declaring count to 0
int count = 0;
// looping through each letter
for(int i=0; i<one.length(); i++)
{
// when both ain't same, incrementing count by 1
if(one[i] != two[i])
count++;
}
// returning count
return count;
}
// sample runs
int main() {
cout << hammingDist("AAAAAA","ACAAAC") << endl;
cout << hammingDist("AAAAAA","ACAAAA") << endl;
cout << hammingDist("AAAAAA","TCGCTG") << endl;
}
/* SAMPLE OUTPUT
2
1
6
*/
// Note: One question at a time please -- Policy of Chegg
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.