Question

In: Computer Science

In C++ Write a function called findMatchedGenome that takes three genomes and a sequence and prints...

In C++

Write a function called findMatchedGenome that takes three genomes and a sequence and prints the list of matched genomes

  • The function must be named findMatchedGenome
  • The function will take in 4 string input parameters in the order
    • Genome 1, a string
    • Genome 2, a string
    • Genome 3, a string
    • sequence (sub-sequence of the genomes), a string
  • The function should not return anything.
  • Unexpected values might be passed into a function and your function should be able to handle it without crashing the program:
    • If one or more genomes or sequence is an empty string, then it prints “Genomes or sequence is empty.” Function will exit.
    • If the length of the three genomes is different, it prints “Lengths of genomes are different.” Function will exit.

Checking these cases must be performed in the order specified above. First check for empty genomes and sequence followed by a check for different lengths.

Helper functions (the functions used in your findMatchedGenome) should be written in the answer box as well.

For example:

Test Result
//For empty sequence
findMatchedGenome("TTC","GCC","TCT","");
Genomes or sequence is empty.

Solutions

Expert Solution

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

void findMatchedGenome(string genome1,string genome2,string genome3,string seq);
int main(void) {
   //Declaring variables
findMatchedGenome("TTC","GCC","TCT","");  
   return 0;
}
void findMatchedGenome(string genome1,string genome2,string genome3,string seq)
{
   if(genome1.compare("")==0 || genome2.compare("")==0||genome3.compare("")==0|| seq.compare("")==0)
   {
       cout<<"Genomes or sequence is empty."<<endl;
   }
   else if(genome1.length()!=genome2.length() ||
   genome2.length()!=genome3.length() ||
           genome3.length()!=genome1.length())
           {
               cout<<"Lengths of genomes are different."<<endl;
           }
           else
           {
               if(genome1.compare(seq)==0)
               {
                   cout<<"Genome1 is matched to sequence."<<endl;
               }
               else if(genome2.compare(seq)==0)
               {
                   cout<<"Genome2 is matched to sequence."<<endl;
               }
               else if(genome3.compare(seq)==0)
               {
                   cout<<"Genome3 is matched to sequence."<<endl;
               }
               else
               {
                   cout<<"No Genome is matched to sequence."<<endl;
               }
              
           }
}

___________________________

Output:

____________________________Thank You


Related Solutions

In C++ Write a function called findBestSimScore that takes a genome and a sequence and returns...
In C++ Write a function called findBestSimScore that takes a genome and a sequence and returns the highest similarity score found in the genome as a double. Note: the term genome refers to the string that represents the complete set of genes in an organism, and sequence to refer to some substring or sub-sequence in the genome. Your function MUST be named findBestSimScore Your function should take two parameters in this order: a string parameter for the genome (complete set...
Write a recursive function in python called make_palindrome that takes a sequence as a parameter and...
Write a recursive function in python called make_palindrome that takes a sequence as a parameter and returns a new sequence that is twice the length of the parameter sequence but that contains the contents of the original in palindrome form. For example, if the sequence "super" is passed into the function, the function will return "superrepus".
Programming in C (not C++) Write the function definition for a function called CompareNum that takes...
Programming in C (not C++) Write the function definition for a function called CompareNum that takes one doyble argument called "num". The function will declare, ask, and get another double from the user. Compare the double entered by the user to "num" and return a 0 if they are the same, a -1 num is less than the double entered by the user and 1 if it is greater.
C++ Write a function called linearSearch that takes an array as a parameter and search for...
C++ Write a function called linearSearch that takes an array as a parameter and search for a specific value inside this parameter. The function returns the frequency of a specific value in the array. In the main function: 1. Define an array called salaries of length 5. 2. Initialize the array by asking the user to input the values of its elements. 3. Define a variable called key and ask the user to enter a value for this variable. 4....
Write a C function called weighted_digit_sum that takes a single integer as input, and returns a...
Write a C function called weighted_digit_sum that takes a single integer as input, and returns a weighted sum of that numbers digits. The last digit of the number (the ones digit) has a weight of 1, so should be added to the sum "as is". The second from last digit (the tens digit) has a weight of 2, and so should be multiplied by 2 then added to the sum. The third from last digit should be multiplied by 1...
Write a function in c++, called afterAll that takes two parameters, a vector of string and...
Write a function in c++, called afterAll that takes two parameters, a vector of string and a string. The function returns true if the 2nd parameter comes after all of the strings in the vector, order-wise, false if not. As an example, "zoo" comes after "yuzu".
Programming in C language (not C++) Write a function definition called PhoneType that takes one character...
Programming in C language (not C++) Write a function definition called PhoneType that takes one character argument/ parameter called "phone" and returns a double. When the variable argument phone contains the caracter a or A, print the word Apple and return 1099.99. When phone contains the caracter s or S print the word Samsung and return 999.99. When phone contains anything else, return 0.0.
In C: Write a function definition called PhoneType that takes one character argument/parameter called phone and...
In C: Write a function definition called PhoneType that takes one character argument/parameter called phone and returns a double. When the variable argument phone contains the character a or A print the word Apple and return 1099.99 When phone contains anything else return a 0.0
C programming Write a function called string in() that takes two string pointers as arguments. If...
C programming Write a function called string in() that takes two string pointers as arguments. If the second string is contained in the first string, have the function return the address at which the contained string begins. For instance, string in(“hats”, “at”) would return the address of the a in hats. Otherwise, have the function return the null pointer. Test the function in a complete program that uses a loop to provide input values for feeding to the function.
(C++ only please) Write a function called maximum that takes an array of double values as...
(C++ only please) Write a function called maximum that takes an array of double values as a parameter and returns the largest value in the array. The length of the array will also be passed as a parameter. (Note that the contents of the array should NOT be modified.) Write a function called printReverse that takes an array of characters and the length of the array as parameters. It should print the elements of the array in reverse order. The...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT