 /* File gnalc1_prot.c */

#if !defined(COMPILE_ENVIRONMENT)
#include <gp/stdcenvf.h> /* std compile environment for functions */
#endif

 /**********************************************************************/
 /*                                                                    */
 /* Gets the next alignment <*palc1> (in character string form) from   */
 /* file <*cfp>.  Returns *p_at_end == T iff file is at end-of-file    */
 /* Assumes that strings read in are already aligned.                  */
 /*                                                                    */
 /**********************************************************************/

 void get_next_alignment_chr_prot(FILE *cfp, ALIGNMENT_CHR_PROT *palc1,
   boolean *p_at_end)
{
/* local data: */
  char *proc = "get_next_alignment_chr_prot";
  boolean include_boundaries = T;
  PROTECTED_CHR_STR *rec, *ret;
  SUBSTRING ss1x, *ss1 = &ss1x;
/* code: */
 db_enter_msg(proc,0); /* debug only */
/* initialize */
  init_al_chr_prot(palc1);
  rec = create_prot_chr_str(4001);
/* go */
  if (!*p_at_end)
    {while ((ret=fgets_prot(rec,cfp)) != NULL)
       {del_eol(rec->str);
if (db_level > 3) printf("%s fgets_prot returns rec->str=[%s]\n",pdb,rec->str);
        if (strncmpi(rec->str,"ID: ",4) == 0) /* look for i.d. line */
 	  {*ss1 = sstok_lr_s(ret->str,'(',')',!include_boundaries);
           if (substr_length(ss1) > 0) ss_to_ps(palc1->id,ss1);
           else
             {fprintf(stderr,"*WARNING: alignment i.d. record contains no i.d. in parens.\n");
              fprintf(stderr,"rec=[%s]\n",rec->str);
              strcpy_prot_s(palc1->id,"*NOT SUPPLIED*");
             }
           continue;
	  }
        if (strncmpi(rec->str,"REF: ",5) == 0) /* look for a REF line */
	  {strcpy_prot_s(palc1->sa,del_eol(strcutl(rec->str,5)));
if (db_level > 3) printf("%s new palc1->sa->str=[%s]\n",pdb,palc1->sa->str);
          }
       	if (strncmpi(rec->str,"HYP: ",5) == 0) /* look for a HYP line */
	  {strcpy_prot_s(palc1->sb,del_eol(strcutl(rec->str,5)));
if (db_level > 3) printf("%s new palc1->sb->str=[%s]\n",pdb,palc1->sb->str);
           break; /* if found, get out */
       }  }
    if (ret == NULL) *p_at_end = T;
    }
  destroy_prot_chr_str(rec);
 db_leave_msg(proc,0); /* debug only */
  } /* end of function "get_next_alignment_chr_prot" */
