forked from deltadev/bbi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_records.h
121 lines (100 loc) · 3.13 KB
/
data_records.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef _DATA_RECORDS_H_
#define _DATA_RECORDS_H_
#include <stdint.h>
#include <iostream>
#include <cfloat>
//Enums for diffrent BigWig file types
enum bigWigDataType
{
bigWigTypeBedGraph = 1,
bigWigTypeVariableStep = 2,
bigWigTypeFixedStep = 3
};
////////////////////////////////////////////////////////////////////////////
// data_record
//
// This is simply for code re-use. Only intended for static dispatch so
// no virtual methods are needed.
//
////////////////////////////////////////////////////////////////////////////
struct data_record
{
uint32_t chrom_id;
uint32_t chrom_start;
uint32_t chrom_end;
void print(std::ostream& os) const;
void pack(std::ostream& os) const;
void unpack(std::istream& os);
};
////////////////////////////////////////////////////////////////////////////
// zoom_data_record
//
// common to wig and bed
//
////////////////////////////////////////////////////////////////////////////
struct zoom_data_record : data_record
{
static const unsigned byte_size = 32;
uint32_t valid_count;
float min_val;
float max_val;
float sum_data;
float sum_squares;
void print(std::ostream& os) const;
void pack(std::ostream& os) const;
void unpack(std::istream& os);
// zoom_data_record(uint32_t chrom_id = 0,
// uint32_t chrom_start = std::numeric_limits<uint32_t>::max(),
// uint32_t chrom_end = 0,
// uint32_t valid_count = 0,
// float min_val = FLT_MAX,
// float max_val = FLT_MIN,
// float sum_data = 0,
// float sum_squares = 0);
};
/////////////////////////////////////////////////////////////////////
// bed_data_record
//
/////////////////////////////////////////////////////////////////////
struct bed_data_record : data_record
{
std::string rest;
void print(std::ostream& os) const;
void pack(std::ostream& os) const;
void unpack(std::istream& os);
};
/////////////////////////////////////////////////////////////////////
// wig_data_record
//
/////////////////////////////////////////////////////////////////////
struct wig_data_header : data_record
{
void print(std::ostream& os) const;
void pack(std::ostream& os) const;
void unpack(std::istream& os);
uint32_t item_step;
uint32_t item_span;
bigWigDataType type;
uint8_t reserved;
uint16_t item_count;
uint32_t position; //data start position (position right after data header)
// wig_data_record(uint32_t chrom_id = 0,
// uint32_t chrom_start = std::numeric_limits<uint32_t>::max(),
// uint32_t chrom_end = 0,
// uint32_t item_step = 0,
// uint32_t item_span = 0,
// uint8_t type = 1, // 1 bed graph, 2 var step, 3 fixed step
// uint8_t reserved = 0,
// uint16_t item_count = 0);
};
struct wig_data_record
{
void print(std::ostream& os) const;
void pack(std::ostream& os) const;
void unpack(std::istream& os, const wig_data_header& head);
uint32_t chrom_start;
uint32_t chrom_end;
float val;
bigWigDataType record_type;
};
#endif /* _DATA_RECORDS_H_ */