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 two-dimensional 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 (i.e., 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 mismatch(es). 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 [2,8] for n,[8,16] for l,[3,5] for m, and [0,2] 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 256 candidate motifs when m =4. This is because there are four possible alphabets in each of the four positions 44=256.
Thus, the number of candidate motifs is 4 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 10 would have 7 substrings of length 4.
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 position(s) with a substring.
For example, if h =1, 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 user_input; 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 gen_candidates; This function generates all possible candidate motifs of length m. It also displays them.
void gen_substrings; This function generates all substrings of length m from an input string. It also displays them.
int hamming_dist; This function returns a hamming distance between two strings of length m. For example, TATGC and TCTCC are two strings of length 5. They have a hamming distance of 2 because they are different in two positions.
void match_motifs_in_string; 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 find_motifs; 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 gen_candidates 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 4 possible alphabets (A, C, G, T), each of the m positions has 4 possible permutations. Therefore, the total number of candidates is 4m. 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.
In this project, you will write a C program that

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 Programming Questions!