How to load in a fasta file without using fastaread using th

How to load in a fasta file without using fastaread using this function.

function fdna2rna(infile, outfile)

% For test run, use:
% fdna2rna(\'test.fasta\', \'test.mrna\')
  
% open FASTA file
fin = fopen(infile, \'r\');
fout = fopen(outfile, \'w+\');

Solution

In C language
void fdna2rna(char s1[], char s2[])
{
FILE *fin;
int c;
char* name ;
char* seq ;
int i =0 ;
fin = fopen(s1,\"r\");
c = fgetc(fp); /* ignoring > */
FILE *fout;
fout = fopen(s2,\"w+\");
while(c!=10) /* Ascii for new line = 10 getting the name using this while loop . */
{
c = fgetc(fp);
if(c==10)
continue;
name[i] = c;
/* putc(c,fout); can be used to write to fout characterwise*/
i++;
}
name[i]=\'\\0\'; /* end string */
printf(\"%s\",name);
i =0 ;
while(1) /* Getting the seq using this while loop . */
{
c = fgetc(fp);
if(c==10) /* Ascii for new line */
continue;
seq[i] = c;
i++;
if( feof(fp) )
{
break ;
}
/* putc(c,fout); can be used to write to fout characterwise*/
}
fclose(fin);
fclose(fout);
}

How to load in a fasta file without using fastaread using this function. function fdna2rna(infile, outfile) % For test run, use: % fdna2rna(\'test.fasta\', \'te

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site