hmmer-3.3/easel/esl_msafile_afa.c
/* Function:  esl_msafile_afa_Write()
 * Synopsis:  Write an aligned FASTA format alignment file to a stream.
 *
 * Purpose:   Write alignment <msa> in aligned FASTA format to a stream
 *            <fp>.
 * 
 *            If <msa> is in text mode, residues and gaps are written
 *            exactly as they appear in the data structure. If <msa>
 *            is digital, residues are in uppercase and all gaps are
 *            dots (.). Dots are preferred to dashes because it 
 *            minimizes confusion with A2M format.
 *
 * Args:      fp  - open stream to write to
 *            msa - MSA to write
 *
 * Returns:   <eslOK> on success.
 *
 * Throws:    <eslEWRITE> on any system write failure, such as filled disk.
 */
esl_msafile_afa_Write()
Synopsis:  Write an aligned FASTA format alignment file to a stream.

Write alignment  in aligned FASTA format to a stream
.

If  is in text mode, residues and gaps are written
exactly as they appear in the data structure. If 
is digital, residues are in uppercase and all gaps are
dots (.). Dots are preferred to dashes because it
minimizes confusion with A2M format.

fp  - open stream to write to
msa - MSA to write

 on success.

 on any system write failure, such as filled disk.
esl_msafile_afa_Write () Synopsis : Write an aligned FASTA format alignment file to a stream . Write alignment in aligned FASTA format to a stream . If is in text mode residues and gaps are written exactly as they appear in the data structure . If is digital residues are in uppercase and all gaps are dots ( . ) . Dots are preferred to dashes because it minimizes confusion with A2M format . fp - open stream to write to msa - MSA to write on success . on any system write failure such as filled disk .
int
esl_msafile_afa_Write(FILE *fp, const ESL_MSA *msa)
{
  int     i;
  int64_t pos;
  char    buf[61];
  int     acpl;       
  for (i = 0; i < msa->nseq; i++)
    {
      if (fprintf(fp, ">%s", msa->sqname[i])                                                      < 0) ESL_EXCEPTION_SYS(eslEWRITE, "afa msa file write failed");
      if (msa->sqacc  != NULL && msa->sqacc[i]  != NULL) { if (fprintf(fp, " %s", msa->sqacc[i])  < 0) ESL_EXCEPTION_SYS(eslEWRITE, "afa msa file write failed"); }
      if (msa->sqdesc != NULL && msa->sqdesc[i] != NULL) { if (fprintf(fp, " %s", msa->sqdesc[i]) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "afa msa file write failed"); }
      if (fputc('\n', fp)                                                                         < 0) ESL_EXCEPTION_SYS(eslEWRITE, "afa msa file write failed");
      pos = 0;
      while (pos < msa->alen)
	{
	  acpl = (msa->alen - pos > 60)? 60 : msa->alen - pos;
	  if (msa->abc)   esl_abc_TextizeN(msa->abc, msa->ax[i] + pos + 1, acpl, buf);
	  if (! msa->abc) strncpy(buf, msa->aseq[i] + pos, acpl);
	  buf[acpl] = '\0';
	  if (fprintf(fp, "%s\n", buf) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "afa msa file write failed");
	  pos += 60;
	}
    } 
  return eslOK;
}
int esl_msafile_afa_Write ( FILE * fp , const ESL_MSA * msa ) { int i ; int64_t pos ; char buf [ 61 ] ; int acpl ; for ( i = 0 ; i < msa -> nseq ; i ++ ) { if ( fprintf ( fp , " " , msa -> sqname [ i ] ) < 0 ) ESL_EXCEPTION_SYS ( eslEWRITE , " " ) ; if ( msa -> sqacc != NULL && msa -> sqacc [ i ] != NULL ) { if ( fprintf ( fp , " " , msa -> sqacc [ i ] ) < 0 ) ESL_EXCEPTION_SYS ( eslEWRITE , " " ) ; } if ( msa -> sqdesc != NULL && msa -> sqdesc [ i ] != NULL ) { if ( fprintf ( fp , " " , msa -> sqdesc [ i ] ) < 0 ) ESL_EXCEPTION_SYS ( eslEWRITE , " " ) ; } if ( fputc ( ' \n ' , fp ) < 0 ) ESL_EXCEPTION_SYS ( eslEWRITE , " " ) ; pos = 0 ; while ( pos < msa -> alen ) { acpl = ( msa -> alen - pos > 60 ) ? 60 : msa -> alen - pos ; if ( msa -> abc ) esl_abc_TextizeN ( msa -> abc , msa -> ax [ i ] + pos + 1 , acpl , buf ) ; if ( ! msa -> abc ) strncpy ( buf , msa -> aseq [ i ] + pos , acpl ) ; buf [ acpl ] = ' \0 ' ; if ( fprintf ( fp , " \n " , buf ) < 0 ) ESL_EXCEPTION_SYS ( eslEWRITE , " " ) ; pos += 60 ; } } return eslOK ; }
Function:  esl_msafile_afa_Write()
 Synopsis:  Write an aligned FASTA format alignment file to a stream.
Function : esl_msafile_afa_Write () Synopsis : Write an aligned FASTA format alignment file to a stream .
/* actual number of characters per line */