Skip to content

Commit a40107a

Browse files
Removing commented code that was committed accidentally
1 parent 78abf3a commit a40107a

File tree

2 files changed

+30
-53
lines changed

2 files changed

+30
-53
lines changed

htslib_wrapper.cpp

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Part of SMITHLAB_CPP software
22
*
3-
* Copyright (C) 2013-2019 University of Southern California and
3+
* Copyright (C) 2013-2023 University of Southern California and
44
* Andrew D. Smith
55
*
66
* Authors: Meng Zhou, Qiang Song, Andrew Smith
@@ -16,43 +16,29 @@
1616
* General Public License for more details.
1717
*/
1818

19-
#include <string>
20-
#include <vector>
19+
#include "htslib_wrapper.hpp"
20+
2121
#include <fstream>
2222
#include <iostream>
23+
#include <string>
24+
#include <vector>
2325

24-
#include "htslib_wrapper.hpp"
25-
#include "smithlab_utils.hpp"
2626
#include "MappedRead.hpp"
27+
#include "smithlab_utils.hpp"
2728

28-
// extern "C" {
29-
// #include <htslib/thread_pool.h>
30-
// }
31-
32-
using std::string;
33-
using std::vector;
3429
using std::cerr;
3530
using std::endl;
3631
using std::runtime_error;
32+
using std::string;
33+
using std::vector;
3734

38-
char check_htslib_wrapper() {return 1;}
39-
40-
/*
41-
void
42-
SAMReader::add_threads(const size_t n_threads) {
43-
// ADS: should probably check that `hts_tpool` succeeded
44-
tp = new htsThreadPool{hts_tpool_init(n_threads), 0};
45-
// tp->pool = hts_tpool_init(n_threads);
46-
// tp->qsize = 0;
47-
const int err_code = hts_set_thread_pool(hts, tp);
48-
if (err_code < 0) throw runtime_error("error setting threads");
35+
char
36+
check_htslib_wrapper() {
37+
return 1;
4938
}
50-
*/
51-
52-
SAMReader::SAMReader(const string &fn) :
53-
filename(fn), good(true), hts(nullptr),
54-
hdr(nullptr), b(nullptr) { // , tp(nullptr) {
5539

40+
SAMReader::SAMReader(const string &fn)
41+
: filename(fn), good(true), hts(nullptr), hdr(nullptr), b(nullptr) {
5642
if (!(hts = hts_open(filename.c_str(), "r")))
5743
throw runtime_error("cannot open file: " + filename);
5844

@@ -79,17 +65,10 @@ SAMReader::~SAMReader() {
7965
assert(hts_close(hts) >= 0);
8066
hts = nullptr;
8167
}
82-
// if (tp) {
83-
// assert(tp->pool);
84-
// hts_tpool_destroy(tp->pool);
85-
// tp->pool = nullptr;
86-
// tp = nullptr;
87-
// }
8868
good = false;
8969
}
9070

91-
92-
SAMReader&
71+
SAMReader &
9372
operator>>(SAMReader &reader, sam_rec &aln) {
9473
reader.get_sam_record(aln);
9574
return reader;
@@ -111,7 +90,7 @@ SAMReader::get_sam_record(sam_rec &sr) {
11190
if ((fmt_ret = sam_format1(hdr, b, &hts->line)) <= 0)
11291
throw runtime_error("failed reading record from: " + filename);
11392
sr = sam_rec(hts->line.s);
114-
good = true; //reader.get_sam_record(reader.hts->line.s, sr);
93+
good = true; // reader.get_sam_record(reader.hts->line.s, sr);
11594
// ADS: line below seems to be needed when the file format is SAM
11695
// because the hts_getline for parsing SAM format files within
11796
// sam_read1 only get called when "(fp->line.l == 0)". For BAM
@@ -122,12 +101,12 @@ SAMReader::get_sam_record(sam_rec &sr) {
122101
}
123102
else if (rd_ret == -1)
124103
good = false;
125-
else // rd_ret < -1
104+
else // rd_ret < -1
126105
throw runtime_error("failed to read record from file: " + filename);
127106
return good;
128107
}
129108

130109
string
131110
SAMReader::get_header() const {
132-
return hdr->text; // includes newline
111+
return hdr->text; // includes newline
133112
}

htslib_wrapper.hpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/*
2-
* Part of SMITHLAB_CPP software
1+
/* Part of SMITHLAB_CPP software
32
*
4-
* Copyright (C) 2019 Meng Zhou and Andrew Smith
3+
* Copyright (C) 2019-2-23 Meng Zhou and Andrew Smith
54
*
65
* Authors: Meng Zhou and Andrew Smith
76
*
@@ -19,46 +18,45 @@
1918
#ifndef HTSLIB_WRAPPER_HPP
2019
#define HTSLIB_WRAPPER_HPP
2120

22-
#include "smithlab_utils.hpp"
23-
#include "sam_record.hpp"
24-
21+
#include <fstream>
2522
#include <string>
2623
#include <vector>
27-
#include <fstream>
24+
25+
#include "sam_record.hpp"
26+
#include "smithlab_utils.hpp"
2827

2928
extern "C" {
30-
#include <htslib/sam.h>
3129
#include <htslib/hts.h>
30+
#include <htslib/sam.h>
3231
}
3332

34-
extern "C" {char check_htslib_wrapper();}
33+
extern "C" {
34+
char check_htslib_wrapper();
35+
}
3536

3637
class SAMReader {
3738
public:
3839
SAMReader(const std::string &filename);
3940
~SAMReader();
4041

41-
operator bool() const {return good;}
42+
operator bool() const { return good; }
4243

4344
bool get_sam_record(sam_rec &sr);
4445

4546
void add_threads(const size_t n_threads);
4647

4748
std::string get_header() const;
48-
4949
private:
50-
5150
// data
5251
std::string filename;
5352
bool good;
5453

55-
htsFile* hts{};
54+
htsFile *hts{};
5655
bam_hdr_t *hdr{};
5756
bam1_t *b{};
58-
// htsThreadPool *tp{};
5957
};
6058

6159
SAMReader &
62-
operator>>(SAMReader& sam_stream, sam_rec &samr);
60+
operator>>(SAMReader &sam_stream, sam_rec &samr);
6361

6462
#endif

0 commit comments

Comments
 (0)