Write a C program to determine the open reading frame ORF in

Write a C program to determine the open reading frame (ORF) in a DNA sequence. In DNA, there are regions of DNA that encode proteins that are first transcribed in the mRNA then translated into a protein. The region of DNA that tells us where to start and stop the translation is referred to as an open reading frame (ORF). An ORF begins when the sequence “atg” occurs and terminates when we encounter either “tga”, “tag”, or “taa”. Unfortunately, we do not know the length of the original DNA sequence or the ORF in advance, so we must use dynamic memory allocation to store the sequence and ORF with the exact the amount of memory required to save the sequences using with malloc or calloc. Print to the user the original sequence and its length, and the ORF and its length. Use the code.txt file for this exercise. Example,

Original: gcgagtgcccatttatgcccaagctgaatagcgtagaggggttttcatcatttgaggacgacgtataagcgagtgcccattt (len=82) ORF: atgcccaagctgaatagcgtagaggggttttcatcatttgaggacgacgtataa (len=54)

Solution

#include<stdio.h>
#include<stdlib.h>
#include <sys/stat.h>
int main()
{
FILE *fp;
int filesize = 0, c = 0;
fp = fopen(\"code.txt\", \"r\");
fseek(fp, 0, 2); /* file pointer at the end of file */
filesize = ftell(fp); /* take a position of file pointer un size variable */
fseek(fp,0,0);
char *ORF;
ORF = NULL;
//Dynamically allocates memory to ORF
ORF = (char *)malloc(sizeof(char) * filesize);
printf(\"\ Original: \");
//Reads the data from file
while(1)
{
if(fgets(ORF, filesize, fp) == NULL)
break;
else
{
printf(\"%s\", ORF);
}
}
printf(\"\ Length = %d\ \", filesize);
for(c = 0; c < filesize; c++)
{
if((*(ORF+c) == \'a\') && (*(ORF+(c+1)) == \'t\')&& (*(ORF+(c+2)) == \'g\'))
{
do
{
//DNA[c] = ORF[c];
printf(\"%c\",ORF[c]);
c++;
if((*(ORF+c) == \'t\') && (*(ORF+(c+1)) == \'g\')&& (*(ORF+(c+2)) == \'a\'))
break;
if((*(ORF+c) == \'t\') && (*(ORF+(c+1)) == \'a\')&& (*(ORF+(c+2)) == \'g\'))
break;
if((*(ORF+c) == \'t\') && (*(ORF+(c+1)) == \'a\')&& (*(ORF+(c+2)) == \'a\'))
break;

}while(1);
printf(\"%d\",c);
}
}
fclose(fp);
}

Output:

Original: gcgagtgcccatttatgcccaagctgaatagcgtagaggggttttcatcatttgaggacgacgtataagcgagtgcccattt
Length = 82

DNA
atgcccaagc

Write a C program to determine the open reading frame (ORF) in a DNA sequence. In DNA, there are regions of DNA that encode proteins that are first transcribed
Write a C program to determine the open reading frame (ORF) in a DNA sequence. In DNA, there are regions of DNA that encode proteins that are first transcribed

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site