• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MikkelSchubert / adapterremoval / #45

20 Sep 2024 06:49PM UTC coverage: 26.244% (-49.2%) from 75.443%
#45

push

travis-ci

web-flow
attempt to fix coveralls run

2458 of 9366 relevant lines covered (26.24%)

4362.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/serializer.hpp
1
/*************************************************************************\
2
 * AdapterRemoval - cleaning next-generation sequencing reads            *
3
 *                                                                       *
4
 * Copyright (C) 2024 by Mikkel Schubert - mikkelsch@gmail.com           *
5
 *                                                                       *
6
 * This program is free software: you can redistribute it and/or modify  *
7
 * it under the terms of the GNU General Public License as published by  *
8
 * the Free Software Foundation, either version 3 of the License, or     *
9
 * (at your option) any later version.                                   *
10
 *                                                                       *
11
 * This program is distributed in the hope that it will be useful,       *
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 * GNU General Public License for more details.                          *
15
 *                                                                       *
16
 * You should have received a copy of the GNU General Public License     *
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. *
18
\*************************************************************************/
19
#pragma once
20

21
#include "commontypes.hpp"   // for string_vec
22
#include "sequence_sets.hpp" // for sample
23
#include <cstddef>           // for size_t
24
#include <functional>        // for function
25

26
namespace adapterremoval {
27

28
class buffer;
29
class fastq;
30
class read_group;
31
enum class output_format;
32

33
enum class fastq_flags
34
{
35
  //! SE read
36
  se,
37
  //! SE read that failed QC
38
  se_fail,
39
  //! Mate 1 read
40
  pe_1,
41
  //! Mate 1 read that failed QC
42
  pe_1_fail,
43
  //! Mate 1 read
44
  pe_2,
45
  //! Mate 1 read that failed QC
46
  pe_2_fail,
47

48
};
49

50
/** Struct containing metadata required to serialize a record */
51
struct serializer_settings
52
{
53
  const fastq_flags flags = fastq_flags::se;
54
  const char mate_separator = '\0';
55
  const bool demultiplexing_only = false;
56
};
57

58
class fastq_serializer
59
{
60
public:
61
  static void header(buffer& buf, const string_vec& args, const sample& s);
62
  static void record(buffer& buf,
63
                     const fastq& record,
64
                     const sample_sequences& sequences,
65
                     const serializer_settings& settings);
66
};
67

68
class sam_serializer
69
{
70
public:
71
  static void header(buffer& buf, const string_vec& args, const sample& s);
72
  static void record(buffer& buf,
73
                     const fastq& record,
74
                     const sample_sequences& sequences,
75
                     const serializer_settings& settings);
76
};
77

78
class bam_serializer
79
{
80
public:
81
  static void header(buffer& buf, const string_vec& args, const sample& s);
82
  static void record(buffer& buf,
83
                     const fastq& record,
84
                     const sample_sequences& sequences,
85
                     const serializer_settings& settings);
86
};
87

88
class serializer
89
{
90
public:
91
  explicit serializer(output_format format);
92

93
  /** Set the sample; used to write headers/records for SAM/BAM */
94
  void set_sample(const sample& s) { m_sample = s; }
×
95

96
  /** Set the mate separator; used to trim mate information for SAM/BAM */
97
  void set_mate_separator(char value) { m_mate_separator = value; }
×
98

99
  /** In demultiplexing only mode, barcodes must always be recorded */
100
  void set_demultiplexing_only(bool value) { m_demultiplexing_only = value; }
×
101

102
  void header(buffer& buf, const string_vec& args) const;
103
  void record(buffer& buf,
104
              const fastq& record,
105
              fastq_flags flags,
106
              size_t barcode) const;
107

108
private:
109
  //! Sample information to be added to SAM/BAM records
110
  sample m_sample{};
111
  //! Mate separator in processed reads
112
  char m_mate_separator = '\0';
113
  //! Indicates if output has only been demultiplexed but not trimmed
114
  bool m_demultiplexing_only = false;
115
  //! Function used to serialize file headers for processed reads
116
  std::function<decltype(fastq_serializer::header)> m_header{};
117
  //! Function used to serialize processed reads
118
  std::function<decltype(fastq_serializer::record)> m_record{};
119
};
120

121
} // namespace adapterremoval
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc