Question: In this project, you will write a C program that reinforces programming fundamentals, such as expressions, control flow, functions, pointers, dynamic memory allocations, and two
In this project, you will write a C program that reinforces programming fundamentals, such as expressions, control flow, functions, pointers, dynamic memory allocations, and twodimensional arrays. You will also use C library functions for working with strings.
Restrictions: You may not use any global variables.
Summary of Basic Motif Search: Given n input strings of length l ie there are l alphabets in each input string find all substrings of length m that are common in all n input strings with at most h mismatches The set of possible alphabets in the input strings consists of A C G and T
Basic Motif Search Steps:
Upon the start of the program, a greeting message Basic Motif Search Program is displayed. The user is then asked to enter the number of input strings n the length of input strings l the length of motifs m and the number of allowable mismatches h
The inputs may only contain numerical characters.
The entered value must contain at least one numerical character and must be in the range of for n for l for m and for h
If these conditions are not satisfied, then the user must be prompted again to enter a valid number until they do so Check each input as the user entered them one by one.
Next, ask the user to enter n strings of length l o The inputs must only contain A C G or T alphabets.
The number of alphabets in each string must be of length l
If these conditions are not satisfied, then the user must be prompted again to enter a valid input string until they do so
This step is completed once n valid input strings have been entered.
Next, the motif search begins with a creation of all candidate motifs with length m
For example, there are candidate motifs when m This is because there are four possible alphabets in each of the four positions
Thus, the number of candidate motifs is m substrings of length m
Display all candidate motifs
Next, for each input string, generate all its substrings of length m
For example, a string of length would have substrings of length
Display all substrings of each string.
Then, check all candidate motifs against all substrings of each input string.
A candidate motif is considered found in an input string if it is mismatched by at most h positions with a substring.
For example, if h a candidate motif ACAG is considered found in an input string that contains ATAG substring as one of its substrings because it is mismatched by only one position.
Display all candidate motifs found in each input string.
If a candidate motif is found in all input strings with at most h mismatched positions, it is accepted as a motif.
Display all motifs found.
Required functions in addition to main:
You may create any additional functions as needed. Choose the appropriate parameters for each of the following functions:
void userinput; This function prompts the user for the required inputs n l m h and n input strings of length l validates user inputs one by one as entered and notifies as well as prompts user for a new input when the input is invalid.
void gencandidates; This function generates all possible candidate motifs of length m It also displays them.
void gensubstrings; This function generates all substrings of length m from an input string. It also displays them.
int hammingdist; This function returns a hamming distance between two strings of length m For example, TATGC and TCTCC are two strings of length They have a hamming distance of because they are different in two positions.
void matchmotifsinstring; This function compares all candidate motifs to all substrings of an input string. The match happens when they are not different by more than h positions. It also displays them.
int findmotifs; This function returns the number of motifs found. It identifies the motifs that appears in all input strings. It also displays the motifs.
Hints for gencandidates Function:
This function generates all possible candidate motifs of length m Thus, you should assume that m value will be passed as a parameter to the function. Since there are possible alphabets A C G T each of the m positions has possible permutations. Therefore, the total number of candidates is m Your code will need to pass in an array of pointers, where each pointer will point to each candidate motif, which is an array of characters of length m You will need to dynamically allocate these arrays of characters. Then, you can fill these arrays of characters with candidate motifs as you go through all possible combinations.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
