1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
/*
This file is a part of KMC software distributed under GNU GPL 3 licence.
The homepage of the KMC project is http://sun.aei.polsl.pl/kmc
Authors: Marek Kokot
Version: 3.2.4
Date : 2024-02-09
*/
#include "fastq_writer.h"
#include <iostream>
using namespace std;
/*****************************************************************************************************************************/
/******************************************************** CONSTRUCTOR ********************************************************/
/*****************************************************************************************************************************/
CFastqWriter::CFastqWriter(CFilteringParams& Params, CFilteringQueues& Queues)
{
output_src = Params.output_src;
filtered_part_queue = Queues.filtered_part_queue;
pmm_fastq_filter = Queues.pmm_fastq_filter;
}
/*****************************************************************************************************************************/
/********************************************************** PUBLIC ***********************************************************/
/*****************************************************************************************************************************/
void CFastqWriter::Process()
{
uchar* part;
uint64 size;
FILE* f = fopen(output_src.c_str(), "wb");
if (!f)
{
cerr << "cannot open file :" << output_src;
exit(1);
}
while (filtered_part_queue->pop(part, size))
{
if (fwrite(part, 1, size, f) != size)
{
cerr << "Error while writing to " << output_src << "\n";
exit(1);
}
pmm_fastq_filter->free(part);
}
fclose(f);
}
/*****************************************************************************************************************************/
/******************************************************** CONSTRUCTOR ********************************************************/
/*****************************************************************************************************************************/
CWFastqWriter::CWFastqWriter(CFilteringParams& Params, CFilteringQueues& Queues)
:writer(Params, Queues)
{
}
/*****************************************************************************************************************************/
/********************************************************** PUBLIC ***********************************************************/
/*****************************************************************************************************************************/
void CWFastqWriter::operator()()
{
writer.Process();
}
// ***** EOF
|