I have a situation where I have to map a 3 letter code of Amino Acid to its 1 letter code. Like ALA=>A. So if I have 'ALA' in my array, it should match and print 'A'. The following is a snippet of the code I had written..its giving a segmentation fault...kindly help
***This is the full code**
Code:
char* dictionary_func(char*);
manin()
{
FILE *fp;
char amino[4];
char line[80];
char chain='0';
char chain1='1';
char code[1];
int i,j,k,count=0;
int chain_count=0;
fp=fopen("test.pdb","r");
if(fp!=NULL)
{
while(fgets(line,80,fp )!=NULL)
{
if((line[0]=='A')&&(line[1]=='T')&&(line[2]=='O')&&(line[3]=='M'))
{
count++;
chain=line[21];
if(chain1!=chain)
{
if(chain==' ')
printf(">Sequence:\n");
else{
chain_count++;
printf("\n>Chain %c \n",chain);;
}
}
chain1=chain;
for(i=17,j=0;i<=19,j<3;i++,j++)
{
amino[j]=line[i];
}
//printf("%s",amino);
printf("%s",dictionary_func(amino)); //This is the part giving the segmentation fault
if(count%70==0)
printf("\n");
}
}
fclose(fp);
}
}
char* dictionary_func(char*s)
{
if(strcmp(s,"ALA")==0)
{
return ("A");
}
}