Thanks for getting back to me. Here is the code that's causing the error:
Code:
#include <stdio.h>
#include <conio.h>
#include "molecule.h"
#include "smiles.h"
#include "smierr.h"
main( int argc, char *argv[] )
{
char buf[200];
char s[MAX_SMI];
char sf[MAX_SMI];
int Error, ErCode;
int N_Frag, Found;
MOLECULE m;
RINGS r;
long id;
FILE *ff, *fs, *fo;
if ( argc != 4 ) {
printf( "USAGE: fragment <smiles-file> <fragment-file> <output-file>\n" );
exit( 1 );
}
if ( (fs = fopen( argv[1], "r" )) == NULL ) {
printf( "Unable to open SMILES file %s\n", argv[1] );
exit( 1 );
}
if ( (ff = fopen( argv[2], "r" )) == NULL ) {
printf( "Unable to open FRAGMENT file %s\n", argv[2] );
exit( 1 );
}
if ( (fo = fopen( argv[3], "w" )) == NULL ) {
printf( "Unable to open OUTPUT file %s\n", argv[3] );
exit( 1 );
}
printf( " Processed: " );
fgets( buf, 200, fs ); /* Retrieve line from smiles file */
sscanf( buf, "%ld %s", &id, s);
while ( !feof( fs ) ) {
if ( (Error = InSmi( s, &m, &ErCode, 0 )) != 0 ) {
printf( "SMILES ERROR for %ld", id );
getch();
} else if ( (Error = ChkVal( &m )) != 0 ) {
printf("VALENCE ERROR for %ld", id );
getch();
} else {
FindRings(&m,&r);
Found = 0;
fscanf( ff, "%s", sf );
while ( (!feof( ff )) && !Found ) {
N_Frag = EV_Num( sf, &m, &r );
if ( N_Frag > 0 ) {
fprintf( fo, "%10ld|%s\n", id, s );
Found = 1;
} else if ( N_Frag < 0 ) {
printf( "FRAGMENT ERROR\n" );
exit( 1 );
}
fscanf( ff, "%s", sf );
}
rewind( ff );
}
printf( "Processing %7ld\n", id );
fgets( buf, 200, fs ); /* Retrieve line from smiles file */
sscanf( buf, "%ld %s", &id, s);
}
fclose( fs );
fclose( ff );
fclose( fo );
exit( 0 );
}