File: fastq_filter.h

package info (click to toggle)
kmc 3.2.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,716 kB
  • sloc: cpp: 38,308; python: 664; makefile: 216; perl: 179; sh: 34
file content (106 lines) | stat: -rw-r--r-- 2,573 bytes parent folder | download
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
/*
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
*/

#ifndef _FASTQ_FILTER_H
#define _FASTQ_FILTER_H

#include "config.h"
#include "queues.h"

#include "kff_random_access.h"

//************************************************************************************************************
// CFastqFilter - filter of reads
//************************************************************************************************************
class CFastqFilter
{
private:
	CFilteringParams::FilterMode mode;
	CPartQueue *input_part_queue, *filtered_part_queue;
	CMemoryPool *pmm_fastq_reader;
	CMemoryPool *pmm_fastq_filter;
	CFilteringParams::file_type input_file_type, output_file_type;
	CKffAndKMCRandomAccess& kmc_api;
	uint64 output_part_size;

	uchar* input_part;
	uint64 input_part_size;
	uint64 input_part_pos;
	uchar* output_part;
	uint64 output_part_pos;

	std::vector<uint32> counters;
	std::string read;
	struct {
		uint64 read_header_start;
		uint64 read_header_end;
		uint64 read_start;
		uint64 read_end;
		uint64 quality_header_start;
		uint64 quality_header_end;
		uint64 quality_start;
		uint64 quality_end;
		uint64 end;
	}seq_desc;

	uint32 trim_len; //for trim mode

	bool use_float_value;
	float f_max_kmers;
	float f_min_kmers;
	uint32 n_max_kmers;
	uint32 n_min_kmers;
	uint32 kmer_len;

	template<class Helper> void ProcessImpl();



	bool NextSeqFastq();
	bool NextSeqFasta();
	bool FilterRead();
	bool FilterReadTrim();
	void HardMask();
public:
	CFastqFilter(CFilteringParams& Params, CFilteringQueues& Queues, CKffAndKMCRandomAccess& kmc_api);
	void Process();


private: //Helpers classes for ProcessImpl

	class FastqToFastqHelper;
	class FastqToFastaHelper;
	class FastaToFastaHelper;

	class TrimFastqToFastqHelper;
	class TrimFastqToFastaHelper;
	class TrimFastaToFastaHelper;

	class HardMaskFastqToFastqHelper;
	class HardMaskFastqToFastaHelper;
	class HardMaskFastaToFastaHelper;

};

//************************************************************************************************************
// CWFastqFilter - wrapper for CFastqFilter class - for multithreading purposes
//************************************************************************************************************
class CWFastqFilter
{
	std::unique_ptr<CFastqFilter> ff;
public:
	CWFastqFilter(CFilteringParams& Params, CFilteringQueues& Queues, CKffAndKMCRandomAccess& kmc_api);
	void operator()();
};


#endif

// ***** EOF