C++ Code:
You will implement the following functions:
/** * Reads from standard input a list of Short Tandem Repeat (STRs) * and their known counts for several individuals * * @param nameSTRs the STRs (eg. AGAT, AATG, TATC) * @param nameIndividuals the names of individuals (eg. Alice, Bob, Charlie) * @param STRcounts the count of the longest consecutive occurrences of each STR in the DNA sequence for each individual * @pre nameSTRs, nameIndividuals, and nameSTRs are empty * @post nameSTRs, nameIndividuals and STRcounts are populated with data read from stdin **/ void readData(vector<string>& nameSTRs, vector<string>& nameIndividuals, vector<vector<int>>& STRcounts)
For example, consider the input:
3 AGAT AATG TATC Alice 5 2 8 Bob 3 7 4 Charlie 6 1 5
It shows, in the first line, the number of STRs followed by the names of those STRs, which will be populated into the vector nameSTRs. The remaining lines contain data for a number of individuals. Their names will be populated into the vector nameIndividuals and the longest consecutive counts of STRs will be stored in the 2D vector STRcounts (which is a vector of vector of ints). Elements in a 2D vector are vector themselves. Check this resource for learning more about 2D
Note, that an empty line at the end of the input denotes the end of data. In other words, the code should stop reading names and STR counts as soon as an empty line is encountered.
- /** * Prints a list of Short Tandem Repeat (STRs) and their * known counts for several individuals * * @param nameSTRs the STRs (eg. AGAT, AATG, TATC) * @param nameIndividuals the names of individuals (eg. Alice, Bob, Charlie) * @param STRcounts the STR counts * @pre nameSTRs, nameIndividuals, and STRcounts hold the data intended to be printed * @post the name of individuals and their STR counts in a column-major format are printed to stdout **/ void printData(vector<string>& nameSTRs, vector<string>& nameIndividuals, vector<vector<int>>& STRcounts)
This function will print out the information that has been previously read (using the function readData) in a format that aligns an individual's STR counts along a column. For example, the output for the above input will be:
name Alice Bob Charlie ---------------------------------------- AGAT 5 3 6 AATG 2 7 1 TATC 8 4 5
This output uses text manipulators to left-align each name and counts within 10 characters. The row of dashes is set to 40 characters.
- /** * Computes the longest consecutive occurrences of several STRs in a DNA sequence * * @param sequence a DNA sequence of an individual * @param nameSTRs the STRs (eg. AGAT, AATG, TATC) * @returns the count of the longest consecutive occurrences of each STR in nameSTRs **/ vector<int> getSTRcounts(string& sequence, vector<string>& nameSTRs)
For example, if the sequence is
AACCCTGCGCGCGCGCGATCTATCTATCTATCTATCCAGCATTAGCTAGCATCAAGATAGATAGATGAATTTCGAAATGAATGAATGAATGAATGAATGAATG
and the vector namesSTRs is {"AGAT", "AATG", "TATC"}, then the output is the vector {3, 7, 4}
- /** * Compares if two vectors of STR counts are identical or not * * @param countQuery STR counts that is being queried (such as that computed from an input DNA sequence) * @param countDB STR counts that are known for an individual (such as that stored in a
database ) * @returns a boolean indicating whether they are the same or not **/ bool compareSTRcounts(vector<int>& countQuery, vector<int>& countDB)
For example, if countQuery is the vector {3, 7, 4}, and countDB is the vector {3, 3, 4}, the function returns false.
Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 4 images
- C++ - Vowels and Consonants - Just do everything in main and make sure you comment each steparrow_forwardc++arrow_forwardC PROGRAM Create a c program that will convert number figures into words 1. You can use user-defined functions, string, array, and loops 2. Maximum input limit is 10000.00 Sample output (bold letters is for input) Enter amount in Peso: 143.50 You just entered P145.50 equivalent to One Hundred Forty Three and Fifty Centavos. Do you want to convert another amount? [Y|N]: Narrow_forward
- C Programming Write function checkHorizontal to count how many discs of the opposing player would be flipped, it should do the following a. Return type integer b. Parameter list i. int rowii. int col iii. char board[ROW][COL] iv. char playerCharc. If the square to the left or right is a space, stop checking d. If the square to the left or right is the same character as the player’s character, save that it was a flank, stop checking e. If the square to the left or right is not the same character as the player’s character, count the disc f. If the counted discs is greater than zero AND the player found their own character, return the counted discs, otherwise return ZERO Write function checkVertical to count how many discs of the opposing player would be flipped, it should do the following a. Return type integer b. Parameter list i. int rowii. int col iii. char board[ROW][COL] iv. char playerCharc. If the square above or below is a space, stop checking d. If the square above or below is…arrow_forward5. use c code to Write a stringSearch function that gets two strings one called needle and the other called haystack. It then searches in the Haystack for the needle. If it finds it, it returns the index of where the needle starts in the haystack. If the needle cannot be found, it should return -1 Prototype: int stringSearch(char needle[], char haystack) Example1: Haystack: “This is just an example” Needle: “just” Result: 8 Example2: Haystack: “This is just an example” Needle: “This” Result: 0 Example3: Haystack: “This is just an example” Needle: “this” Result: -1 Hint: all the answer need to include an output and use c code to answerarrow_forwardProblem taken from LeetCode // Problem Statement : // You are given a string. // Write a function that takes a string as input and reverse only the vowels of a string. // Example : // Sample Input - 1 : // "hello" // Sample Output - 1 : // "holle" // Sample Input - 2 : // "leetcode" // Sample Output - 2 : // "leotcede" class Solution {public: string reverseVowels(string s) { int i = 0 , j = s.size() - 1; while(i < j) { while(i < j && (s[i] != 'a' && s[i] != 'e' && s[i] != 'i' && s[i] != 'o' && s[i] != 'u' && s[i] != 'A' && s[i] != 'E' && s[i] != 'I' && s[i] != 'O' && s[i] != 'U' )) { i++;…arrow_forward
- in python create function that has a parameter of dict[str, str] key should be a name value should be a word when given a dict of names and word, function should return the word that is most common ******************************* no using key, value for loops no .get, .items, .defaultset no importing builtins no using .values, .keys, or .index must do it through dictionary cycling ************************** should return a stringarrow_forwardhelp me solve this in c++ please Write a program that asks the user to enter a list of numbers from 1 to 9 in random order, creates and displays the corresponding 3 by 3 square, and determines whether the resulting square is a Lo Shu Magic Square. Notes Create the square by filling the numbers entered from left to right, top to bottom. Input validation - Do not accept numbers outside the range. Do not accept repeats. Must use two-dimensional arrays in the implementation. Functional decomposition — Program should rely on functions that are consistent with the algorithm.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education