-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbbi-spec.txt
161 lines (145 loc) · 6.06 KB
/
bbi-spec.txt
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* bigWig/bigBed file structure:
* fixedWidthHeader
* magic# 4 bytes
* version 2 bytes
* zoomLevels 2 bytes
* chromosomeTreeOffset 8 bytes
* fullDataOffset 8 bytes
* fullIndexOffset 8 bytes
* fieldCount 2 bytes (for bigWig 0)
* definedFieldCount 2 bytes (for bigWig 0)
* autoSqlOffset 8 bytes (for bigWig 0) (0 if no autoSql information)
* totalSummaryOffset 8 bytes (0 in earlier versions of file lacking totalSummary)
* uncompressBufSize 4 bytes (Size of uncompression buffer. 0 if uncompressed.)
* extensionOffset 8 bytes (Offset to header extension 0 if no such extension)
* zoomHeaders there are zoomLevels number of these
* reductionLevel 4 bytes
* reserved 4 bytes
* dataOffset 8 bytes
* indexOffset 8 bytes
* autoSql string (zero terminated - only present if autoSqlOffset non-zero)
* totalSummary - summary of all data in file - only present if totalSummaryOffset non-zero
* basesCovered 8 bytes
* minVal 8 bytes float (for bigBed minimum depth of coverage)
* maxVal 8 bytes float (for bigBed maximum depth of coverage)
* sumData 8 bytes float (for bigBed sum of coverage)
* sumSquared 8 bytes float (for bigBed sum of coverage squared)
* extendedHeader
* extensionSize 2 size of extended header in bytes - currently 64
* extraIndexCount 2 number of extra fields we will be indexing
* extraIndexListOffset 8 Offset to list of non-chrom/start/end indexes
* reserved 48 All zeroes for now
* extraIndexList - one of these for each extraIndex
* type 2 Type of index. Always 0 for bPlusTree now
* fieldCount 2 Number of fields used in this index. Always 1 for now
* indexOffset 8 offset for this index in file
* reserved 4 All zeroes for now
* fieldList - one of these for each field being used in _this_ index
* fieldId 2 index of field within record
* reserved 2 All zeroes for now
* chromosome b+ tree bPlusTree index
* full data
* sectionCount 8 bytes (item count for bigBeds)
* section data section count sections, of three types (bed data for bigBeds)
* full index cirTree index
* zoom info one of these for each zoom level
* zoom data
* zoomCount 4 bytes
* zoom data there are zoomCount of these items
* chromId 4 bytes
* chromStart 4 bytes
* chromEnd 4 bytes
* validCount 4 bytes
* minVal 4 bytes float
* maxVal 4 bytes float
* sumData 4 bytes float
* sumSquares 4 bytes float
* zoom index cirTree index
* extraIndexes [optional] bPlusTreeIndex for each extra field that is indexed
* magic# 4 bytes - same as magic number at start of header
*/
//////////////////////////////////////////////////////////
//
// Big bed file data types
//
//////////////////////////////////////////////////////////
struct bigBedInterval
/* A partially parsed out bed record plus some extra fields. Use this directly
* or convert it to an array of characters with bigBedIntervalToRow. */
{
bits32 start, end; /* Range inside chromosome - half open zero based. */
char *rest; /* Rest of line. May be NULL*/
bits32 chromId; /* ID of chromosome. */
};
//////////////////////////////////////////////////////////
//
// Big wig file data types
//
//////////////////////////////////////////////////////////
enum bwgSectionType
/* Code to indicate section type. */
{
bwgTypeBedGraph=1,
bwgTypeVariableStep=2,
bwgTypeFixedStep=3,
};
struct bwgBedGraphItem
/* An bedGraph-type item in a bwgSection. */
{
bits32 start,end; /* Range of chromosome covered. */
float val; /* Value. */
};
struct bwgVariableStepItem
/* An variableStep type item in a bwgSection. */
{
bits32 start; /* Start position in chromosome. */
float val; /* Value. */
};
struct bwgVariableStepPacked
/* An variableStep type item in a bwgSection. */
{
bits32 start; /* Start position in chromosome. */
float val; /* Value. */
};
struct bwgFixedStepItem
/* An fixedStep type item in a bwgSection. */
{
float val; /* Value. */
};
union bwgItem
/* Union of item pointers for all possible section types. */
{
struct bwgBedGraphItem *bedGraphList; /* A linked list */
struct bwgFixedStepPacked *fixedStepPacked; /* An array */
struct bwgVariableStepPacked *variableStepPacked; /* An array */
/* No packed format for bedGraph... */
};
struct bwgSection
/* A section of a bigWig file - all on same chrom. This is a somewhat fat data
* structure used by the bigWig creation code. See also bwgSection for the
* structure returned by the bigWig reading code. */
{
char *chrom; /* Chromosome name. */
bits32 start,end; /* Range of chromosome covered. */
enum bwgSectionType type;
union bwgItem items; /* List/array of items in this section. */
bits32 itemStep; /* Step within item if applicable. */
bits32 itemSpan; /* Item span if applicable. */
bits16 itemCount; /* Number of items in section. */
bits32 chromId; /* Unique small integer value for chromosome. */
bits64 fileOffset; /* Offset of section in file. */
};
struct bwgSectionHead
/* A header from a bigWig file section - similar to above bug what is on disk. */
{
bits32 chromId; /* Chromosome short identifier. */
bits32 start,end; /* Range covered. */
bits32 itemStep; /* For some section types, the # of bases between items. */
bits32 itemSpan; /* For some section types, the # of bases in each item. */
UBYTE type; /* Type byte. */
UBYTE reserved; /* Always zero for now. */
bits16 itemCount; /* Number of items in block. */
};
;; Local Variables:
;; mode: c++
;; End: