-
Notifications
You must be signed in to change notification settings - Fork 4
/
proxy.h
94 lines (83 loc) · 3.16 KB
/
proxy.h
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
/*
Pheniqs : PHilology ENcoder wIth Quality Statistics
Copyright (C) 2018 Lior Galanti
NYU Center for Genetics and System Biology
Author: Lior Galanti <lior.galanti@nyu.edu>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PHENIQS_PROXY_H
#define PHENIQS_PROXY_H
#include "include.h"
#include "url.h"
#include "atom.h"
const ssize_t PEEK_BUFFER_CAPACITY(4096);
enum class FormatKind : uint8_t {
UNKNOWN,
DEV_NULL,
FASTQ,
HTS,
};
string to_string(const FormatKind& value);
bool from_string(const char* value, FormatKind& result);
void to_kstring(const FormatKind& value, kstring_t& result);
bool from_string(const string& value, FormatKind& result);
ostream& operator<<(ostream& o, const FormatKind& value);
void encode_key_value(const string& key, const FormatKind& value, Value& container, Document& document);
class FeedProxy {
friend ostream& operator<<(ostream& o, const FeedProxy& proxy);
public:
int32_t index;
URL url;
IoDirection direction;
uint8_t phred_offset;
int capacity;
int resolution;
Platform platform;
hFILE* hfile;
HtsHead head;
FeedProxy(const Value& ontology);
inline bool is_dev_null() const {
return url.is_dev_null();
};
inline bool is_stdin() const {
return url.is_stdin();
};
inline bool is_stdout() const {
return url.is_stdout();
};
inline bool is_stderr() const {
return url.is_stderr();
};
inline FormatKind kind() const {
if(!url.is_dev_null()) {
switch(url.type()) {
case FormatType::SAM:
case FormatType::BAM:
case FormatType::CRAM:
return FormatKind::HTS;
break;
case FormatType::FASTQ:
return FormatKind::FASTQ;
break;
default:
return FormatKind::UNKNOWN;
break;
}
} else { return FormatKind::DEV_NULL; }
};
void open();
};
bool encode_key_value(const string& key, const FeedProxy& value, Value& container, Document& document);
ostream& operator<<(ostream& o, const FeedProxy& proxy);
template<> FeedProxy decode_value< FeedProxy >(const Value& container);
template<> list< FeedProxy > decode_value_by_key< list< FeedProxy > >(const Value::Ch* key, const Value& container);
#endif /* PHENIQS_PROXY_H */