Please Complete the following C Code with Comments explaining your solution and post a screenshot of it working.
Summary: This project explores pattern matching techniques to find a pattern in a DNA sequence containing letters in the DNA alphabet {A, C, G, T}. For example, suppose we have a DNA sequence as follows:
ATGACGATCTACGTATGGCAGCCACGCTTTTGATGTTAAGTCACACAGCCAAGTCA ACAAGGGCGACTTCATGATCTTTCCGCTCCGTTGGTGTAGGCCCGTGTTCAAATTC AATGGCTGATTGGAATTACCTTTGAAATACTCCAACCGACCGCCACGGCCAGGGT CCCGCTCGCTCTCTGTGGCCCTCCCACAAAACTCCGGTGAAAGTTGATTTGGACAC GGACCCAAAGCAGCGTAGATTATTCGAGCGTATTCGGTAGTCATTGAGGCCCCAA
The pattern “AATGG” can be found at the beginning of the third line. Note that overlapping matches are counted individually. For example, if the sequence is ‘AAAAAA’ and the pattern is ‘AAA’, there are 4 occurrences of the pattern. Part 1: A shell program DNA-shell.c is provided that randomly initializes a text string (10240 characters) with the DNA alphabet. A pattern of 3 to 7 characters is also randomly generated using the DNA alphabet. You must insert code into the shell to implement the function 'match' which takes four input parameters, the pointer to the text string, the length of the text string, a pointer to the pattern, and the length of the pattern. The 'match' function must return the array of indices of occurrences of the pattern in the text string. For example, if the sequence is ‘AACAAC’ and the pattern is ‘AAC’, the return value is ‘03’ where ‘0’ indicates the index of the first occurrence of ‘AAC’ and ‘3’ indicates the index of the second occurrence. The shell program includes a print statement for reporting the frequency of occurrences computed by 'match', so it can be properly graded. Its output format should not be modified. You should design, implement, and test your own code. Otherwise you won’t learn the things you need to know for later parts of the projects. Any submitted project containing code not fully created and debugged by the student constitutes academic misconduct. You should use gcc under Ubuntu to develop your program (type man gcc for compiler usage). Normally, you should compile and run your program using the Linux command line: > gcc DNA-shell.c –g –Wall –o DNAsearch > ./DNAsearch In order for your solution to be properly received and graded, there are a few requirements.
1. The file must be named p1-1.c.
2. You name and the date should be included in the header comment.
3. The starting shell program should not be modified except for the replacement of the comment /* your program goes here */ and the addition of declared local variables. It is especially important not to remove or modify the print statement since that will be used in the automatic grading process. 4. Your solution must be properly uploaded to the canvas before the scheduled due date. The canvas p1-1 assignment has details on late penalties and policies.
******************************************************************************************************************************************************************************************
/* Current date <your name goes here>
This is the only file that should be modified for the C
implementation
of Project 1.
This program initializes a DNA sequence of 10,240 random
characters and
a pattern of 3 to 7 random characters, all characters are from the
DNA
alphabet {A, T, G, C}.
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SEQLEN 10240
#define MAXPATLEN 10
#define NUMCHAR 4
char Alphabet[] = "ACTG";
int main(int argc, char *argv[]) {
char Seq[SEQLEN], Pat[MAXPATLEN];
int I, *MatchLocs, PatLen;
void Print_Seq(char *Seq, int SeqLen);
void Print_Pat(char *Pat, int PatLen);
int *Match(char *Pat, int PatLen, char *Seq, int SeqLen);
srand((unsigned int) time(NULL)); // seed random number
generator
PatLen = (rand() % MAXPATLEN) + 1; // compute pattern
length
for (I = 0; I < SEQLEN; I++)
Seq[I] = Alphabet[rand() % NUMCHAR]; // create sequence
for (I = 0; I < PatLen; I++)
Pat[I] = Alphabet[rand() % NUMCHAR]; // create pattern
Print_Pat(Pat, PatLen); // print pattern
Print_Seq(Seq, SEQLEN); // print sequence
MatchLocs = Match(Pat, PatLen, Seq, SEQLEN); // match pattern in
sequence
printf("Pattern detected at the following locations:\n");
while (*MatchLocs != -1) printf("Base pair %d in the sequence\n",
*MatchLocs++);
return 0;
}
/* Print Sequence
This routine prints the sequence. */
void Print_Seq(char *Seq, int SeqLen) {
int I;
printf("The sequence is ...\n");
for (I = 0; I < SeqLen; I++) {
putchar(Seq[I]);
if (I % 80 == 79)
printf("\n");
}
}
/* Print Pattern
This routine prints the match pattern. */
void Print_Pat(char *Pat, int PatLen) {
int I;
printf("The pattern is ... \"");
for (I = 0; I < PatLen; I++)
putchar(Pat[I]);
printf("\"\n");
}
/* Match
This routine find indices of occurrances of a variable length
DNA
patttern in a DNA sequence. A null terminated array of indices of
occurences is returned */
int *Match(char *Pat, int PatLen, char *Seq, int SeqLen) {
// insert your code here
return 0; // modify to return the array of indices
}

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SEQLEN 10240
#define MAXPATLEN 10
#define NUMCHAR 4
char Alphabet[] = "ACTG";
int main(int argc, char *argv[]) {
char Seq[SEQLEN], Pat[MAXPATLEN];
int I, *MatchLocs, PatLen;
void Print_Seq(char *Seq, int SeqLen);
void Print_Pat(char *Pat, int PatLen);
int *Match(char *Pat, int PatLen, char *Seq, int SeqLen);
srand((unsigned int) time(NULL)); // seed random number generator
PatLen = (rand() % MAXPATLEN) + 1; // compute pattern length
for (I = 0; I < SEQLEN; I++)
Seq[I] = Alphabet[rand() % NUMCHAR]; // create sequence
for (I = 0; I < PatLen; I++)
Pat[I] = Alphabet[rand() % NUMCHAR]; // create pattern
Print_Pat(Pat, PatLen); // print pattern
Print_Seq(Seq, SEQLEN); // print sequence
MatchLocs = Match(Pat, PatLen, Seq, SEQLEN); // match pattern in sequence
printf("Pattern detected at the following locations:\n");
while (*MatchLocs != -1) printf("Base pair %d in the sequence\n", *MatchLocs++);
return 0;
}
/* Print Sequence
This routine prints the sequence. */
void Print_Seq(char *Seq, int SeqLen) {
int I;
printf("The sequence is ...\n");
for (I = 0; I < SeqLen; I++) {
putchar(Seq[I]);
if (I % 80 == 79)
printf("\n");
}
}
/* Print Pattern
This routine prints the match pattern. */
void Print_Pat(char *Pat, int PatLen) {
int I;
printf("The pattern is ... \"");
for (I = 0; I < PatLen; I++)
putchar(Pat[I]);
printf("\"\n");
}
/* Match
This routine find indices of occurrances of a variable length DNA
patttern in a DNA sequence. A null terminated array of indices of occurences is returned */
int *Match(char *Pat, int PatLen, char *Seq, int SeqLen) {
int *result = malloc(sizeof(int) * SeqLen);
// insert your code here
int i=0, j=0;
int count = 0;
for(i=0; i<(SeqLen - PatLen + 1); i++) {
int matched = 1;
for(j=0; j<PatLen; j++) {
if(Pat[j] != Seq[i+j]) {
matched = 0;
}
}
if(matched) {
result[count++] = i;
}
}
result[count++] = -1;
return result; // modify to return the array of indices
}
please upvote. Thanks!
Please Complete the following C Code with Comments explaining your solution and post a screenshot of...
(Packing Characters into an Integer) The left-shift operator can be used to pack four character values into a four-byte unsigned int variable. Write a program that inputs four characters from the keyboard and passes them to function packCharacters. To pack four characters into an unsigned int variable, assign the first character to the unsigned intvariable, shift the unsigned int variable left by 8 bit positions and combine the unsigned variable with the second character using the bitwise inclusive OR operator....
This code should be Runnable on MARS (MIPS Assembler and Runtime Simulator) IDE Convert the following c code into mips #include <stdio.h> #include <string.h> char cipherText[200] = "anything"; int countNumberOfCharInCipher(char*); int countNumberOfCharInCipher(char* cText) { return strlen(cText); } int countSpaces(int numberOfChar, char input[]) { int spaceCounter =0; for(int i=0; i < numberOfChar; i++) { if(input[i] == 32) spaceCounter++; } return spaceCounter; } void decrypt(int numberOfChar, int key, char * cipherText, char * plainText) { int j = 0; int i =0;...
Question: Please Provide Comments on each Line of code explaining what the C Function is doing throughout the code. // Function used for substitution encryption void SubEncrypt(char *message, char *encryptKey) { int iteration = 0; printf("Enter Aphabet Encryption Key: \n"); scanf("%s", encryptKey); for (iteration = 0; iteration < strlen(message); iteration++) { char letter = message[iteration]; if (letter >= 'A' && letter <= 'Z') { letter = encryptKey[letter - 'A']; } message[iteration] = letter; } printf("CipherText message: %s\n", message); } //_________________________________________________________________________________________________________________________________________________...
using c language String Challenge Have the function StringChallenge(str) read str which will contain two strings separated by a space. The first string will consist of the following sets of characters: +, *, $, and {N} which is optional. The plus (+) character represents a single alphabetic character, the ($) character represents a number between 1-9, and the asterisk (*) represents a sequence of the same character of length 3 unless it is followed by {N} which represents how many...
#include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here. */ int GetNumOfNonWSCharacters(const char usrStr[]) { int length; int i; int count = 0; char c; length=strlen(usrStr); for (i = 0; i < length; i++) { c=usrStr[i]; if ( c!=' ' ) { count++; } } return count; } int GetNumOfWords(const char usrStr[]) { int counted = 0; // result // state: const char* it = usrStr; int inword = 0; do switch(*it)...
C Language! Please, comment what each line of code does in the code below and answer this question: (sentence is fine) 1. Aside from pressing ctrl-(d/z) at the beginning of a line causing the getnchar() function to return NULL, is there any way to enter less than 9 characters? Code: void exer1(void) { char input[LEN]; char *check; getchar(); // Clearing character buffer. printf("Please enter 9 characters: "); // Prompting the user to enter // a specific input. ...
C Programming
Take screenshot of compiled output once complete. (which
should look similar to the sample one provided). Will rate
positively.
Problem:
(1) Add PopTailSLL()
as a new member function to the SLL abstract data type. “Unlink”
the logically-last node (tail) from the list *sll, call the
DestructElement function to destruct the object pointed-to by the
node’s element data member, free() the node, and decrement
size. A SLL_UNDERFLOW exception occurs when size = 0.
void PopTailSLL(SLL *sll);
Hint PopTailSLL() is...
Write a complete C program that inputs a paragraph of text and prints out each unique letter found in the text along with the number of times it occurred. A sample run of the program is given below. You should input your text from a data file specified on the command line. Your output should be formatted and presented exactly like the sample run (i.e. alphabetized with the exact spacings and output labels). The name of your data file along...
need this in c programming and you can edit the code below. also
give me screenshot of the output
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define LINE_SIZE 1024
void my_error(char *s)
{
fprintf(stderr, "Error: %s\n", s);
perror("errno");
exit(-1);
}
// This funciton prints lines (in a file) that contain string
s.
// assume all lines has at most (LINE_SIZE - 2) ASCII
characters.
//
// Functions that may be called in this function:
// fopen(), fclose(), fgets(), fputs(),...