fastq.c
/***************************************************************************
 *  Library:
 *      #include <biolibc/fastq.h>
 *      -lbiolibc -lxtend
 *
 *  Description:
 *      Write a FASTQ record to the specified FILE stream, writing at most
 *      max_line_len sequence characters per line.  The special value
 *      BL_FASTQ_LINE_UNLIMITED indicates no line length limit.
 *  
 *  Arguments:
 *      fastq_stream    FILE stream to which data are written
 *      record          Pointer to a bl_fastq_t structure to be written
 *      max_line_len    Maximum length of a sequence line in output
 *
 *  Returns:
 *      BL_WRITE_OK upon success, BL_WRITE_FAILURE if a write error occurs.
 *
 *  Examples:
 *      bl_fastq_t  rec = BL_FASTQ_INIT;
 *
 *      while ( bl_fastq_read(stdin, &rec) != BL_READ_EOF )
 *          bl_fastq_write(stdout, &rec, BL_FASTQ_LINE_UNLIMITED);
 *      bl_fastq_free(&rec);
 *
 *  See also:
 *      bl_fastq_read(3), bl_fastq_read(3), bl_fastq_write(3),
 *
 *
 *  History: 
 *  Date        Name        Modification
 *  2021-07-28  Jason Bacon Begin
 ***************************************************************************/
#include 
-lbiolibc -lxtend

Write a FASTQ record to the specified FILE stream, writing at most
max_line_len sequence characters per line.  The special value
BL_FASTQ_LINE_UNLIMITED indicates no line length limit.

fastq_stream    FILE stream to which data are written
record          Pointer to a bl_fastq_t structure to be written
max_line_len    Maximum length of a sequence line in output

BL_WRITE_OK upon success, BL_WRITE_FAILURE if a write error occurs.







Date        Name        Modification
2021-07-28  Jason Bacon Begin
#include - lbiolibc - lxtend Write a FASTQ record to the specified FILE stream writing at most max_line_len sequence characters per line . The special value BL_FASTQ_LINE_UNLIMITED indicates no line length limit . fastq_stream FILE stream to which data are written record Pointer to a bl_fastq_t structure to be written max_line_len Maximum length of a sequence line in output BL_WRITE_OK upon success BL_WRITE_FAILURE if a write error occurs . Date Name Modification 2021 - 07 - 28 Jason Bacon Begin
int     bl_fastq_write(bl_fastq_t *record, FILE *fastq_stream,
		       size_t max_line_len)
{
    size_t  c;
    int     save_ch = ' ';  
    if ( fprintf(fastq_stream, "%s\n", record->desc) < 0 )
	return BL_WRITE_FAILURE;
    if ( max_line_len == BL_FASTQ_LINE_UNLIMITED )
    {
	if ( fprintf(fastq_stream, "%s\n", record->seq) < 0 )
	    return BL_WRITE_FAILURE;
    }
    else
    {
	for (c = 0; c < record->seq_len; c += max_line_len)
	{
	    if ( record->seq_len - c > max_line_len )
	    {
		save_ch = record->seq[c + max_line_len];
		record->seq[c + max_line_len] = '\0';
	    }
	    if ( fprintf(fastq_stream, "%s\n", record->seq + c) < 0 )
		return BL_WRITE_FAILURE;
	    if ( record->seq_len - c > max_line_len )
		record->seq[c + max_line_len] = save_ch;
	}
    }
    if ( fprintf(fastq_stream, "%s\n", record->plus) < 0 )
	return BL_WRITE_FAILURE;
    if ( max_line_len == BL_FASTQ_LINE_UNLIMITED )
    {
	if ( fprintf(fastq_stream, "%s\n", record->qual) < 0 )
	    return BL_WRITE_FAILURE;
    }
    else
    {
	for (c = 0; c < record->qual_len; c += max_line_len)
	{
	    if ( record->qual_len - c > max_line_len )
	    {
		save_ch = record->qual[c + max_line_len];
		record->qual[c + max_line_len] = '\0';
	    }
	    if ( fprintf(fastq_stream, "%s\n", record->qual + c) < 0 )
		return BL_WRITE_FAILURE;
	    if ( record->qual_len - c > max_line_len )
		record->qual[c + max_line_len] = save_ch;
	}
    }
    return BL_WRITE_OK;
}
int bl_fastq_write ( bl_fastq_t * record , FILE * fastq_stream , size_t max_line_len ) { size_t c ; int save_ch = ' ' ; if ( fprintf ( fastq_stream , " \n " , record -> desc ) < 0 ) return BL_WRITE_FAILURE ; if ( max_line_len == BL_FASTQ_LINE_UNLIMITED ) { if ( fprintf ( fastq_stream , " \n " , record -> seq ) < 0 ) return BL_WRITE_FAILURE ; } else { for ( c = 0 ; c < record -> seq_len ; c += max_line_len ) { if ( record -> seq_len - c > max_line_len ) { save_ch = record -> seq [ c + max_line_len ] ; record -> seq [ c + max_line_len ] = ' \0 ' ; } if ( fprintf ( fastq_stream , " \n " , record -> seq + c ) < 0 ) return BL_WRITE_FAILURE ; if ( record -> seq_len - c > max_line_len ) record -> seq [ c + max_line_len ] = save_ch ; } } if ( fprintf ( fastq_stream , " \n " , record -> plus ) < 0 ) return BL_WRITE_FAILURE ; if ( max_line_len == BL_FASTQ_LINE_UNLIMITED ) { if ( fprintf ( fastq_stream , " \n " , record -> qual ) < 0 ) return BL_WRITE_FAILURE ; } else { for ( c = 0 ; c < record -> qual_len ; c += max_line_len ) { if ( record -> qual_len - c > max_line_len ) { save_ch = record -> qual [ c + max_line_len ] ; record -> qual [ c + max_line_len ] = ' \0 ' ; } if ( fprintf ( fastq_stream , " \n " , record -> qual + c ) < 0 ) return BL_WRITE_FAILURE ; if ( record -> qual_len - c > max_line_len ) record -> qual [ c + max_line_len ] = save_ch ; } } return BL_WRITE_OK ; }
Library:
      #include <biolibc/fastq.h>
      -lbiolibc -lxtend
Library : #include <biolibc / fastq . h > - lbiolibc - lxtend
// Silence false uninit warning on CentOS // Temporarily null-terminate segment of string to be printed // Print segment // Remove temporary null-termination // Temporarily null-terminate segment of string to be printed // Print segment // Remove temporary null-termination