Hi, I'm new to C programming and am having trouble with a program I'm trying to write. The goal of this program is to take the following information (which I have stored in a file) and display the locus (which is AJ002502), length of sequence (all of the ACT&Gs), and then print out the sequence. I'm trying to modify one of my existing programs but am having trouble. Any help would be greatly appreciated.![]()
Thanks
(Below is my file)
>gi|2582735|emb|AJ002502.1| Human immunodeficiency virus type 1 protease gene (isolate B01 week 48)
CCTCAGATCACTCTTTGGCAACGACCCATCGTCACAATAAAGATAGGGGG GCAATTAAAGGAAGCTCTATTAGATACAGGAGCAGATGWTMCAGTWTTAG AAGAAATGAATTTSCCAGGAAGATGGAAACCAAAAATAATAGGGGGAATT GGAGGTTTTGTTAAAGTAAGACAGTATGATCAGATACCCATAGACATCTG TGGACATAAAGTTATAGGTACTGTATTARTAGGACCTACACCTGCCAACG TAATTGGAAGAAATCTACTGACTCAGATTGGTTGTACTTTAAATTTT
Code:#include <stdio.h> #include <string.h> #include <ctype.h> /*struct sequence {char locus[20]; char data[500]; int length;}; struct sequence newSequence(char *l) struct sequence newSequence(char *d) { struct sequence temp; strcpy(temp.locus, l); //String copy strcpy(temp.data, d); temp.length = strlen(d); //String length return temp; }*/ main(int argc, char **argv) { FILE *input = fopen(argv[1], "r"); if(!input) { printf("NO FILE"); exit(1); } char buffer[1000]; while(fgets(buffer, 1000, input)) { if(strstr(buffer, "LOCUS")) { // char *token = strtok(buffer, " \t"); // token = strtok(NULL, " \t"); // printf(">%s\n",token); char *mylocus = strtok(buffer, " \t"); mylocus = strtok(NULL, " \t"); printf(">%s\n",mylocus); //Want to store this until called on later in the structs! } else { if(strstr(buffer, "ORIGIN")) { char c = fgetc(input); //Is stored as int need to convert to string while(c!='/') { if(!isblank(c)) { if(!isdigit(c)) { putchar(c); } } c=fgetc(input); } /* char *mydata = c; struct sequence mySeq = newSequence(mydata); printf(mydata = %s\n,mySeq.data); */ printf("\n"); } } } // struct sequence mySeq = newSequence(mylocus, mydata); // printf("mylocus = %s \nmydata = %s\nlength=%d\n",mySeq.locus,mySeq.data,mySeq.length); fclose(input); return 0; }



LinkBack URL
About LinkBacks



