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

MikkelSchubert / adapterremoval / #46

27 Nov 2024 03:10PM UTC coverage: 27.245% (+1.0%) from 26.244%
#46

push

travis-ci

MikkelSchubert
fix convenience executable make target

2609 of 9576 relevant lines covered (27.25%)

4268.73 hits per line

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

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

22
#include "sequence.hpp" // for sequence_pair_vec
23
#include <array>        // for array
24
#include <cstddef>      // for size_t
25
#include <cstdint>      // for int32_t
26
#include <vector>       // for vector
27

28
namespace adapterremoval {
29

30
class sample_set;
31
class fastq;
32
struct barcode_match;
33
struct next_subsequence;
34

35
/** The sample/barcode IDs associated with a set of sequences */
36
struct barcode_key
465✔
37
{
38
  constexpr static const int32_t unidentified = -1;
39
  constexpr static const int32_t ambiguous = -2;
40

41
  //! Sample identified by 1 or more barcodes
42
  int32_t sample = unidentified;
43
  //! The specific barcode(s) used to identify this sample
44
  int32_t barcode = unidentified;
45

46
  bool operator==(const barcode_key& other) const
161✔
47
  {
48
    return sample == other.sample && barcode == other.barcode;
161✔
49
  }
50

51
  bool operator<(const barcode_key& other) const
×
52
  {
53
    return sample < other.sample ||
×
54
           (sample == other.sample && barcode < other.barcode);
×
55
  }
56
};
57

58
using barcode_pair = std::pair<sequence_pair, barcode_key>;
59
using barcode_vec = std::vector<barcode_pair>;
60

61
/**
62
 * Struct representing node in quad-tree; children are referenced using the
63
 * corresponding index in the vector representing the tree; -1 is used to
64
 * represent unassigned children.
65
 */
66
struct barcode_node
67
{
68
  barcode_node();
69

70
  std::array<int32_t, 4> children;
71
  barcode_key key;
72
};
73

74
/**
75
 *
76
 */
77
class barcode_table
62✔
78
{
79
public:
80
  barcode_table(const sample_set& samples,
81
                size_t max_mm,
82
                size_t max_mm_r1,
83
                size_t max_mm_r2);
84

85
  [[nodiscard]] barcode_key identify(const fastq& read_r1) const;
86
  [[nodiscard]] barcode_key identify(const fastq& read_r1,
87
                                     const fastq& read_r2) const;
88

89
  /** Returns the length of barcodes in read 1  */
90
  [[nodiscard]] size_t length_1() const { return m_barcode_1_len; }
×
91

92
  /** Returns the length of barcodes in read 2  */
93
  [[nodiscard]] size_t length_2() const { return m_barcode_2_len; }
×
94

95
private:
96
  barcode_match lookup(const char* seq,
97
                       int32_t parent,
98
                       size_t max_global_mismatches,
99
                       const char* next) const;
100

101
  barcode_match lookup_with_mm(const char* seq,
102
                               int32_t parent,
103
                               size_t max_global_mismatches,
104
                               size_t max_local_mismatches,
105
                               const char* next) const;
106

107
  std::vector<barcode_node> m_nodes{};
108
  size_t m_max_mismatches = 0;
109
  size_t m_max_mismatches_r1 = 0;
110
  size_t m_max_mismatches_r2 = 0;
111
  size_t m_barcode_1_len = 0;
112
  size_t m_barcode_2_len = 0;
113
};
114

115
} // 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