-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeqFileInWrapper.cpp
More file actions
63 lines (54 loc) · 1.53 KB
/
SeqFileInWrapper.cpp
File metadata and controls
63 lines (54 loc) · 1.53 KB
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
/*
* Class to wrap SeqFileIn
*
* Might be better to just inherit from SeqFileIn, add input
* and input_stream as private variables, and make a new
* definition of open and close, but that's a more involved
* project, and the method I use below will work for my own
* programs.
*
* FormattedFile is defined in seqan/stream/formatted_file.h
*
* Note that Seqan is supposed to be able to handle gzipped files,
* but only is SEQAN_HAS_ZLIB is defined as 1 and it is compiled
* with zlib support. This seems to be a somewhat sketchy feature.
*
*/
#include <string>
#include <iostream>
#include <seqan/seq_io.h>
#include <SeqFileInWrapper.h>
using std::string;
using std::cin;
using std::ifstream;
using std::istream;
using namespace seqan;
namespace bltools {
void SeqFileInWrapper::open(char * infile) {
string inf(infile);
open(inf);
}
void SeqFileInWrapper::open(string &infile) {
bool file_ok = false;
if(infile == "-") {
input_stream = &cin;
file_ok = true;
} else {
input.open(infile.c_str(), ifstream::in);
file_ok = input.is_open() && input.good();
input_stream = &input;
}
file_ok &= seqan::open(sqh, *input_stream);
if(!file_ok) {
throw "problem opening file";
}
}
bool SeqFileInWrapper::close() {
bool close_ok = seqan::close(sqh);
input.close();
return close_ok;
}
bool SeqFileInWrapper::atEnd() {
return seqan::atEnd(sqh);
}
}