hmmer-3.3/easel/miniapps/esl-alimerge.c
/* write_pfam_msa_top
 *                   
 * Highly specialized function for printing out the 'top' of a
 * Stockholm alignment file, i.e. the Stockholm header line, comments
 * and GF annotation to an msa file. This function is necessary when
 * printing the merged alignment file in small memory mode (when
 * --small enabled). <msa> is an alignment with no sequence
 * information (no aseq, ax, GS, or GR data).
 */


Highly specialized function for printing out the 'top' of a
Stockholm alignment file, i.e. the Stockholm header line, comments
and GF annotation to an msa file. This function is necessary when
printing the merged alignment file in small memory mode (when
small enabled).  is an alignment with no sequence
information (no aseq, ax, GS, or GR data).
Highly specialized function for printing out the ' top ' of a Stockholm alignment file i . e . the Stockholm header line comments and GF annotation to an msa file . This function is necessary when printing the merged alignment file in small memory mode ( when small enabled ) . is an alignment with no sequence information ( no aseq ax GS or GR data ) .
void
write_pfam_msa_top(FILE *fp, ESL_MSA *msa)
{
  int i, maxgf;
  fprintf(fp, "# STOCKHOLM 1.0\n");
  for (i = 0;  i < msa->ncomment; i++)
    fprintf(fp, "# %s\n", msa->comment[i]);
  if (msa->ncomment > 0) fprintf(fp, "\n");
  maxgf = maxwidth(msa->gf_tag, msa->ngf);
  if (maxgf < 2) maxgf = 2;
  if (msa->name != NULL) fprintf(fp, "#=GF %-*s %s\n", maxgf, "ID", msa->name);
  if (msa->acc  != NULL) fprintf(fp, "#=GF %-*s %s\n", maxgf, "AC", msa->acc);
  if (msa->desc != NULL) fprintf(fp, "#=GF %-*s %s\n", maxgf, "DE", msa->desc);
  if (msa->au   != NULL) fprintf(fp, "#=GF %-*s %s\n", maxgf, "AU", msa->au);
  if      (msa->cutset[eslMSA_GA1] && msa->cutset[eslMSA_GA2])
    fprintf(fp, "#=GF %-*s %.1f %.1f\n", 
	    maxgf, "GA", msa->cutoff[eslMSA_GA1], msa->cutoff[eslMSA_GA2]);
  else if (msa->cutset[eslMSA_GA1])
    fprintf(fp, "#=GF %-*s %.1f\n", 
	    maxgf, "GA", msa->cutoff[eslMSA_GA1]);
  if      (msa->cutset[eslMSA_NC1] && msa->cutset[eslMSA_NC2])
    fprintf(fp, "#=GF %-*s %.1f %.1f\n",
	    maxgf, "NC", msa->cutoff[eslMSA_NC1], msa->cutoff[eslMSA_NC2]);
  else if (msa->cutset[eslMSA_NC1])
    fprintf(fp, "#=GF %-*s %.1f\n",
	    maxgf, "NC", msa->cutoff[eslMSA_NC1]);
  if      (msa->cutset[eslMSA_TC1] && msa->cutset[eslMSA_TC2])
    fprintf(fp, "#=GF %-*s %.1f %.1f\n",
	    maxgf, "TC", msa->cutoff[eslMSA_TC1], msa->cutoff[eslMSA_TC2]);
  else if (msa->cutset[eslMSA_TC1])
    fprintf(fp, "#=GF %-*s %.1f\n", 
	    maxgf, "TC", msa->cutoff[eslMSA_TC1]);
  for (i = 0; i < msa->ngf; i++)
    fprintf(fp, "#=GF %-*s %s\n", maxgf, msa->gf_tag[i], msa->gf[i]); 
  fprintf(fp, "\n");
  return;
}
void write_pfam_msa_top ( FILE * fp , ESL_MSA * msa ) { int i , maxgf ; fprintf ( fp , " \n " ) ; for ( i = 0 ; i < msa -> ncomment ; i ++ ) fprintf ( fp , " \n " , msa -> comment [ i ] ) ; if ( msa -> ncomment > 0 ) fprintf ( fp , " \n " ) ; maxgf = maxwidth ( msa -> gf_tag , msa -> ngf ) ; if ( maxgf < 2 ) maxgf = 2 ; if ( msa -> name != NULL ) fprintf ( fp , " \n " , maxgf , " " , msa -> name ) ; if ( msa -> acc != NULL ) fprintf ( fp , " \n " , maxgf , " " , msa -> acc ) ; if ( msa -> desc != NULL ) fprintf ( fp , " \n " , maxgf , " " , msa -> desc ) ; if ( msa -> au != NULL ) fprintf ( fp , " \n " , maxgf , " " , msa -> au ) ; if ( msa -> cutset [ eslMSA_GA1 ] && msa -> cutset [ eslMSA_GA2 ] ) fprintf ( fp , " \n " , maxgf , " " , msa -> cutoff [ eslMSA_GA1 ] , msa -> cutoff [ eslMSA_GA2 ] ) ; else if ( msa -> cutset [ eslMSA_GA1 ] ) fprintf ( fp , " \n " , maxgf , " " , msa -> cutoff [ eslMSA_GA1 ] ) ; if ( msa -> cutset [ eslMSA_NC1 ] && msa -> cutset [ eslMSA_NC2 ] ) fprintf ( fp , " \n " , maxgf , " " , msa -> cutoff [ eslMSA_NC1 ] , msa -> cutoff [ eslMSA_NC2 ] ) ; else if ( msa -> cutset [ eslMSA_NC1 ] ) fprintf ( fp , " \n " , maxgf , " " , msa -> cutoff [ eslMSA_NC1 ] ) ; if ( msa -> cutset [ eslMSA_TC1 ] && msa -> cutset [ eslMSA_TC2 ] ) fprintf ( fp , " \n " , maxgf , " " , msa -> cutoff [ eslMSA_TC1 ] , msa -> cutoff [ eslMSA_TC2 ] ) ; else if ( msa -> cutset [ eslMSA_TC1 ] ) fprintf ( fp , " \n " , maxgf , " " , msa -> cutoff [ eslMSA_TC1 ] ) ; for ( i = 0 ; i < msa -> ngf ; i ++ ) fprintf ( fp , " \n " , maxgf , msa -> gf_tag [ i ] , msa -> gf [ i ] ) ; fprintf ( fp , " \n " ) ; return ; }
write_pfam_msa_top
write_pfam_msa_top
/* rest of code in this function was stolen verbatim from actually_write_stockholm in esl_msa.c */ /* Magic Stockholm header
   */ /* Free text comments
   */ /* GF section: per-file annotation
   */ /* Thresholds are hacky. Pfam has two. Rfam has one.
   */