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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
/*
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: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
Version: 2.3.0
Date : 2015-08-21
*/
#ifndef _FASTQ_READER_H
#define _FASTQ_READER_H
#include "defs.h"
#include "params.h"
#include <stdio.h>
#include <iostream>
#include <zlib.h>
#include <bzlib.h>
using namespace std;
//************************************************************************************************************
// FASTA/FASTQ reader class
//************************************************************************************************************
class CFastqReader {
typedef enum {m_plain, m_gzip, m_bzip2} t_mode;
CMemoryMonitor *mm;
CMemoryPool *pmm_fastq;
string input_file_name;
input_type file_type;
int kmer_len;
t_mode mode;
FILE *in;
gzFile_s *in_gzip;
BZFILE *in_bzip2;
int bzerror;
uint64 part_size;
uchar *part;
uint64 part_filled;
uint32 gzip_buffer_size;
uint32 bzip2_buffer_size;
bool containsNextChromosome; //for multiline_fasta processing
bool SkipNextEOL(uchar *part, int64 &pos, int64 max_pos);
bool IsEof();
public:
CFastqReader(CMemoryMonitor *_mm, CMemoryPool *_pmm_fastq, input_type _file_type, uint32 _gzip_buffer_size, uint32 _bzip2_buffer_size, int _kmer_len);
~CFastqReader();
static uint64 OVERHEAD_SIZE;
bool SetNames(string _input_file_name);
bool SetPartSize(uint64 _part_size);
bool OpenFiles();
bool GetPartFromMultilneFasta(uchar *&_part, uint64 &_size);
bool GetPart(uchar *&_part, uint64 &_size);
};
//************************************************************************************************************
// Wrapper for FASTA/FASTQ reader class - for multithreading purposes
//************************************************************************************************************
class CWFastqReader {
CMemoryMonitor *mm;
CMemoryPool *pmm_fastq;
CFastqReader *fqr;
string file_name;
uint64 part_size;
CInputFilesQueue *input_files_queue;
CPartQueue *part_queue;
input_type file_type;
uint32 gzip_buffer_size;
uint32 bzip2_buffer_size;
int kmer_len;
public:
CWFastqReader(CKMCParams &Params, CKMCQueues &Queues);
~CWFastqReader();
void operator()();
};
//************************************************************************************************************
// Wrapper for FASTA/FASTQ reader class (stats mode) - for multithreading purposes
//************************************************************************************************************
class CWStatsFastqReader {
CMemoryMonitor *mm;
CMemoryPool *pmm_fastq;
CFastqReader *fqr;
string file_name;
uint64 part_size;
CInputFilesQueue *input_files_queue;
CStatsPartQueue *stats_part_queue;
input_type file_type;
uint32 gzip_buffer_size;
uint32 bzip2_buffer_size;
int kmer_len;
public:
CWStatsFastqReader(CKMCParams &Params, CKMCQueues &Queues);
~CWStatsFastqReader();
void operator()();
};
#endif
// ***** EOF
|