Solved: DNA Subsequence A DNA sequence is a sequence of some combination of the characters A (adenine), C (cytosine), G (guanine), and T (thym

DNA Subsequence A DNA sequence is a sequence of some combination of the characters A (adenine), C (cytosine), G (guanine), and T (thymine) which correspond to the four nucleobases that make up DNA. Given a long DNA sequence, it is often necessary to compute the number of instances of a certain subsequence. For this exercise, you will develop a program that processes a DNA sequence from a file and, given a subsequences, searches the DNA sequence and counts the number of times s appears. As an example, consider the following sequence: GGAAGTAGCAGGCCGCATGCTTGGAGGTAAAGTTCATGGTTCCCTGGCCC If we were to search for the subsequence GTA, it appears twice You will write a program (place your source in a file named dnaSearch.c) that takes, as command line inputs, an input file name and a valid DNA (sub)sequence. That is, it should be callable from the command line as follows: /dnaSearch dna01.txt GTA GTA appears 2 times

>>>> dna01.txt <<<

Don't use plagiarized sources. Get Your Custom Essay on
Solved: DNA Subsequence A DNA sequence is a sequence of some combination of the characters A (adenine), C (cytosine), G (guanine), and T (thym
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

ACAAGATGCCATTGTCCCCCGGCCTCCTGCTGCTGCTGCTCTCCGGGGCCACGGCCACCGCTGCCCTGCC
CCTGGAGGGTGGCCCCACCGGCCGAGACAGCGAGCATATGCAGGAAGCGGCAGGAATAAGGAAAAGCAGC
CTCCTGACTTTCCTCGCTTGGTGGTTTGAGTGGACCTCCCAGGCCAGTGCCGGGCCCCTCATAGGAGAGG
AAGCTCGGGAGGTGGCCAGGCGGCAGGAAGGCGCACCCCCCCAGCAATCCGCGCGCCGGGACAGAATGCC
CTGCAGGAACTTCTTCTGGAAGACCTTCTCCTCCTGCAAATAAAACCTCACCCATGAATGCTCACGCAAG
TTTAATTACAGACCTGAA

DNA Subsequence A DNA sequence is a sequence of some combination of the characters A (adenine), C (cytosine), G (guanine), and T (thymine) which correspond to the four nucleobases that make up DNA. Given a long DNA sequence, it is often necessary to compute the number of instances of a certain subsequence. For this exercise, you will develop a program that processes a DNA sequence from a file and, given a subsequences, searches the DNA sequence and counts the number of times s appears. As an example, consider the following sequence: GGAAGTAGCAGGCCGCATGCTTGGAGGTAAAGTTCATGGTTCCCTGGCCC If we were to search for the subsequence GTA, it appears twice You will write a program (place your source in a file named dnaSearch.c) that takes, as command line inputs, an input file name and a valid DNA (sub)sequence. That is, it should be callable from the command line as follows: /dnaSearch dna01.txt GTA GTA appears 2 times

Expert Answer

 

Hi Let me know if you need more information:-

==============================================

dnaSearch.c

———————————-

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char **argv) {
int offset;
int counter = 0;
char* filename = argv[1];
char* search = argv[2];
int i = strlen(search);
search[i] = ‘’;
FILE * file = fopen(argv[1], “r”);
//printf(“After read..”);
if (file == NULL) {
printf(“END read..”);
exit(1);
}
char line[i];
while (fgets(line, i + 1, file) != NULL) {
//printf(“%s:%sn”, line, search);
int len = strlen(line);
//printf(“length:—> :%d:%d:n”, len, i);
//sleep(1);
//printf(“%s:%sn”, line, search);
if ((len < i) || line == “” || line == “n”) {
//printf(“Skipped:—> %s:%sn”, line, search);
} else if (strcmp(line, search) == 0) {
counter++;
} else {
fseek(file, -(i – 1), SEEK_CUR);
}
}
printf(“%s appears %d times”, search, counter);
fclose(file);
}

===============================

INPUT:-

GGAAGTAGCAGGCCGCATGCTTGGAGGTAAAGTTCATGGTTCCCTGGCCC

OUTPUT:-

GTA appears 2 times

=================================================

#include <iostream>
#include <stdio.h>
#include <string>
#include <fstream>
using namespace std;
int main(int argc, char **argv) {
ifstream fileInput;
int offset;
string search(argv[2]);
string line;
//cout << argv[1] << “:” << search << endl;
int counter = 0;

fileInput.open(argv[1]);
if (fileInput.is_open()) {
while (!fileInput.eof()) {
getline(fileInput, line);
int offset = 0;
while(offset <line.size()){
if ((offset = line.find(search, offset)) != string::npos) {
//cout<<“offset”<<offset<<endl;
offset = offset + search.size();
counter++;
}else{
offset= line.size();
}
}
}
fileInput.close();
}
cout << search << ” appears ” << counter << ” times ” << endl;
}

============================================================

INPUT:-

==============================================================

INPUT: GGAAGTAGCAGGCCGCATGCTTGGAGGTAAAGTTCATGGTTCCCTGGCCC

OUTPUT:-

GTA appears 2 times

====================================

INPUT 2: GGAAGTAGCAGGCCGCATGCTTGGAGGTAAAGTTCATGGTTCCCTGTAGCCC

OUTPUT:-

GTA appears 3 times

=======================

INPUT 3: ACAAGATGCCATTGTCCCCCGGCCTCCTGCTGCTGCTGCTCTGTACCGGGGCCACGGCCACCGCTGCCCTGCC
CCTGGAGGGTGGCCCCACCGGCCGAGACAGCGAGCATATGCAGGAAGCGGCAGGAATAAGGAAAAGCAGC
CTCCTGACTTTCCTCGCTTGGTGGTTTGAGTGGACCTCCCAGGCCAGTGCCGGGCCCCTCATAGGAGAGG
AAGCTCGGGAGGTGGCCAGGCGGCAGGAAGGCGCACCCCCCCAGCAATCCGCGCGCCGGGACAGAATGCC
CTGCAGGAACTTCTTCTGGAAGACCTTCTCCTCCTGCAAATAAAACCTCACCCATGAATGCTCACGCAAG
TTTAATTACAGACCTGAA

OUTPUT:-

GTA appears 14 times

==============================

Solved: DNA Subsequence A DNA sequence is a sequence of some combination of the characters A (adenine), C (cytosine), G (guanine), and T (thym 1

——————————————————————————

Still stressed from student homework?
Get quality assistance from academic writers!