Thanks for the advice. My next problem is with the title of my files. I managed to get it to put the unique id as the title. What I need is a file extension to go on the end. To illustrate, I need the filename to go from AJ002507 to AJ002507.gb.
Heres my code; any help would be great.
Code:
main( int argc, char **argv )
{
FILE *input ;
FILE *output ;
char data[1000000] ;
char *firstWord, *GenBankID ;
char headerLine[1000] ;
if( ! ( input = fopen( argv[1], "r" ) ) )
{
printf( "COULD NOT OPEN FILE %s - Exit!\n", argv[1]) ;
exit(1) ;
}
output = fopen( "id", "w") ;
while( (fgets(data, 1000000, input)))
{
if(strstr( data, "LOCUS"))
{
// Labeling file with unique ID
strcpy( headerLine, data ) ;
firstWord = strtok( headerLine, " \t" ) ;
GenBankID = strtok( NULL, " \t" ) ;
output = fopen ( GenBankID , "w" ) ;
fputs(data, output ) ;
}
else if(strstr( data, "//"))
{
fputs(data, output) ;
fclose (output ) ;
}
else
{
fputs(data, output) ;
}
}
fclose (input) ;
return(0) ;
}