bio-bigwig 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -14
- data/ext/bio/bigwig/bigwigext.c +1 -1
- data/ext/bio/bigwig/extconf.rb +7 -25
- data/ext/bio/bigwig/libBigWig/bigWig.h +20 -20
- data/ext/bio/bigwig/libBigWig/bigWigIO.h +2 -2
- data/ext/bio/bigwig/libBigWig/bwCommon.h +4 -0
- data/ext/bio/bigwig/libBigWig/bwRead.c +21 -10
- data/ext/bio/bigwig/libBigWig/bwStats.c +4 -4
- data/ext/bio/bigwig/libBigWig/bwValues.c +18 -18
- data/ext/bio/bigwig/libBigWig/bwWrite.c +11 -11
- data/ext/bio/bigwig/libBigWig/io.c +3 -3
- data/lib/bio/bigwig/version.rb +1 -1
- metadata +4 -11
- data/ext/bio/bigwig/libBigWig/test/exampleWrite.c +0 -76
- data/ext/bio/bigwig/libBigWig/test/testBigBed.c +0 -132
- data/ext/bio/bigwig/libBigWig/test/testIterator.c +0 -67
- data/ext/bio/bigwig/libBigWig/test/testLocal.c +0 -223
- data/ext/bio/bigwig/libBigWig/test/testRemote.c +0 -203
- data/ext/bio/bigwig/libBigWig/test/testRemoteManyContigs.c +0 -46
- data/ext/bio/bigwig/libBigWig/test/testWrite.c +0 -68
@@ -1,203 +0,0 @@
|
|
1
|
-
#include "bigWig.h"
|
2
|
-
#include <stdio.h>
|
3
|
-
#include <inttypes.h>
|
4
|
-
#include <stdlib.h>
|
5
|
-
#include <assert.h>
|
6
|
-
|
7
|
-
//Print overly verbose header information
|
8
|
-
void bwPrintHdr(bigWigFile_t *bw) {
|
9
|
-
uint64_t i;
|
10
|
-
int64_t i64;
|
11
|
-
printf("Version: %"PRIu16"\n", bw->hdr->version);
|
12
|
-
printf("Levels: %"PRIu16"\n", bw->hdr->nLevels);
|
13
|
-
printf("ctOffset: 0x%"PRIx64"\n", bw->hdr->ctOffset);
|
14
|
-
printf("dataOffset: 0x%"PRIx64"\n", bw->hdr->dataOffset);
|
15
|
-
printf("indexOffset: 0x%"PRIx64"\n", bw->hdr->indexOffset);
|
16
|
-
printf("sqlOffset: 0x%"PRIx64"\n", bw->hdr->sqlOffset);
|
17
|
-
printf("summaryOffset: 0x%"PRIx64"\n", bw->hdr->summaryOffset);
|
18
|
-
printf("bufSize: %"PRIu32"\n", bw->hdr->bufSize);
|
19
|
-
printf("extensionOffset: 0x%"PRIx64"\n", bw->hdr->extensionOffset);
|
20
|
-
|
21
|
-
if(bw->hdr->nLevels) {
|
22
|
-
printf(" i level data index\n");
|
23
|
-
}
|
24
|
-
for(i=0; i<bw->hdr->nLevels; i++) {
|
25
|
-
printf("\t%"PRIu64"\t%"PRIu32"\t%"PRIx64"\t%"PRIx64"\n", i, bw->hdr->zoomHdrs->level[i], bw->hdr->zoomHdrs->dataOffset[i], bw->hdr->zoomHdrs->indexOffset[i]);
|
26
|
-
}
|
27
|
-
|
28
|
-
printf("nBasesCovered: %"PRIu64"\n", bw->hdr->nBasesCovered);
|
29
|
-
printf("minVal: %f\n", bw->hdr->minVal);
|
30
|
-
printf("maxVal: %f\n", bw->hdr->maxVal);
|
31
|
-
printf("sumData: %f\n", bw->hdr->sumData);
|
32
|
-
printf("sumSquared: %f\n", bw->hdr->sumSquared);
|
33
|
-
|
34
|
-
//Chromosome idx/name/length
|
35
|
-
if(bw->cl) {
|
36
|
-
printf("Chromosome List\n");
|
37
|
-
printf(" idx\tChrom\tLength (bases)\n");
|
38
|
-
for(i64=0; i64<bw->cl->nKeys; i64++) {
|
39
|
-
printf(" %"PRIu64"\t%s\t%"PRIu32"\n", i64, bw->cl->chrom[i64], bw->cl->len[i64]);
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
void bwPrintIndexNode(bwRTreeNode_t *node, int level) {
|
45
|
-
uint16_t i;
|
46
|
-
if(!node) return;
|
47
|
-
for(i=0; i<node->nChildren; i++) {
|
48
|
-
if(node->isLeaf) {
|
49
|
-
printf(" %i\t%"PRIu32"\t%"PRIu32"\t%"PRIu32"\t%"PRIu32"\t0x%"PRIx64"\t%"PRIu64"\n", level,\
|
50
|
-
node->chrIdxStart[i], \
|
51
|
-
node->baseStart[i], \
|
52
|
-
node->chrIdxEnd[i], \
|
53
|
-
node->baseEnd[i], \
|
54
|
-
node->dataOffset[i], \
|
55
|
-
node->x.size[i]);
|
56
|
-
} else {
|
57
|
-
printf(" %i\t%"PRIu32"\t%"PRIu32"\t%"PRIu32"\t%"PRIu32"\t0x%"PRIx64"\tNA\n", level,\
|
58
|
-
node->chrIdxStart[i], \
|
59
|
-
node->baseStart[i], \
|
60
|
-
node->chrIdxEnd[i], \
|
61
|
-
node->baseEnd[i], \
|
62
|
-
node->dataOffset[i]);
|
63
|
-
bwPrintIndexNode(node->x.child[i], level+1);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
void bwPrintIndexTree(bigWigFile_t *fp) {
|
69
|
-
printf("\nIndex tree:\n");
|
70
|
-
printf("nItems:\t%"PRIu64"\n", fp->idx->nItems);
|
71
|
-
printf("chrIdxStart:\t%"PRIu32"\n", fp->idx->chrIdxStart);
|
72
|
-
printf("baseStart:\t%"PRIu32"\n", fp->idx->baseStart);
|
73
|
-
printf("chrIdxEnd:\t%"PRIu32"\n", fp->idx->chrIdxEnd);
|
74
|
-
printf("baseEnd:\t%"PRIu32"\n", fp->idx->baseEnd);
|
75
|
-
printf("idxSize:\t%"PRIu64"\n", fp->idx->idxSize);
|
76
|
-
printf(" level\tchrIdxStart\tbaseStart\tchrIdxEnd\tbaseEnd\tchild\tsize\n");
|
77
|
-
bwPrintIndexNode(fp->idx->root, 0);
|
78
|
-
}
|
79
|
-
|
80
|
-
void printIntervals(bwOverlappingIntervals_t *ints, uint32_t start) {
|
81
|
-
uint32_t i;
|
82
|
-
if(!ints) return;
|
83
|
-
for(i=0; i<ints->l; i++) {
|
84
|
-
if(ints->start && ints->end) {
|
85
|
-
printf("Interval %"PRIu32"\t%"PRIu32"-%"PRIu32": %f\n",i, ints->start[i], ints->end[i], ints->value[i]);
|
86
|
-
} else if(ints->start) {
|
87
|
-
printf("Interval %"PRIu32"\t%"PRIu32"-%"PRIu32": %f\n",i, ints->start[i], ints->start[i]+1, ints->value[i]);
|
88
|
-
} else {
|
89
|
-
printf("Interval %"PRIu32"\t%"PRIu32"-%"PRIu32": %f\n",i, start+i, start+i+1, ints->value[i]);
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
93
|
-
|
94
|
-
//This is an example call back function
|
95
|
-
CURLcode callBack(CURL *curl) {
|
96
|
-
CURLcode rv;
|
97
|
-
|
98
|
-
rv = curl_easy_setopt(curl, CURLOPT_USERNAME, "anonymous");
|
99
|
-
if(rv != CURLE_OK) return rv;
|
100
|
-
|
101
|
-
rv = curl_easy_setopt(curl, CURLOPT_PASSWORD, "libBigWig@github.com");
|
102
|
-
return rv;
|
103
|
-
}
|
104
|
-
|
105
|
-
int main(int argc, char *argv[]) {
|
106
|
-
bigWigFile_t *fp = NULL;
|
107
|
-
bwOverlappingIntervals_t *intervals = NULL;
|
108
|
-
double *stats = NULL;
|
109
|
-
char chrom[] = "chr1";
|
110
|
-
if(argc != 2) {
|
111
|
-
fprintf(stderr, "Usage: %s {file.bw|URL://path/file.bw}\n", argv[0]);
|
112
|
-
return 1;
|
113
|
-
}
|
114
|
-
|
115
|
-
if(bwInit(1<<17) != 0) {
|
116
|
-
fprintf(stderr, "Received an error in bwInit\n");
|
117
|
-
return 1;
|
118
|
-
}
|
119
|
-
|
120
|
-
fp = bwOpen(argv[1], callBack, "r");
|
121
|
-
if(!fp) {
|
122
|
-
fprintf(stderr, "An error occured while opening %s\n", argv[1]);
|
123
|
-
return 1;
|
124
|
-
}
|
125
|
-
|
126
|
-
bwPrintHdr(fp);
|
127
|
-
bwPrintIndexTree(fp);
|
128
|
-
|
129
|
-
//Try to get some blocks
|
130
|
-
printf("%s:10000000-10000100 Intervals\n", chrom);
|
131
|
-
intervals = bwGetOverlappingIntervals(fp, chrom, 10000000, 10000100);
|
132
|
-
printIntervals(intervals,0);
|
133
|
-
bwDestroyOverlappingIntervals(intervals);
|
134
|
-
|
135
|
-
printf("%s:10000000-10000100 Values\n", chrom);
|
136
|
-
intervals = bwGetValues(fp, chrom, 10000000, 10000100, 0);
|
137
|
-
printIntervals(intervals,0);
|
138
|
-
bwDestroyOverlappingIntervals(intervals);
|
139
|
-
|
140
|
-
stats = bwStats(fp, chrom, 10000000, 10000100, 1, mean);
|
141
|
-
if(stats) {
|
142
|
-
printf("%s:10000000-10000100 mean: %f\n", chrom, stats[0]);
|
143
|
-
free(stats);
|
144
|
-
}
|
145
|
-
|
146
|
-
stats = bwStats(fp, chrom, 10000000, 10000100, 2, mean);
|
147
|
-
if(stats) {
|
148
|
-
printf("%s:10000000-10000100 mean: %f %f\n", chrom, stats[0], stats[1]);
|
149
|
-
free(stats);
|
150
|
-
}
|
151
|
-
|
152
|
-
stats = bwStats(fp, chrom, 10000000, 10000100, 1, dev);
|
153
|
-
if(stats) {
|
154
|
-
printf("%s:10000000-10000100 std. dev.: %f\n", chrom, stats[0]);
|
155
|
-
free(stats);
|
156
|
-
}
|
157
|
-
|
158
|
-
stats = bwStats(fp, chrom, 10000000, 10000100, 2, dev);
|
159
|
-
if(stats) {
|
160
|
-
printf("%s:10000000-10000100 std. dev.: %f %f\n", chrom, stats[0], stats[1]);
|
161
|
-
free(stats);
|
162
|
-
}
|
163
|
-
|
164
|
-
stats = bwStats(fp, chrom, 10000000, 10000100, 1, min);
|
165
|
-
if(stats) {
|
166
|
-
printf("%s:10000000-10000100 min: %f\n", chrom, stats[0]);
|
167
|
-
free(stats);
|
168
|
-
}
|
169
|
-
|
170
|
-
stats = bwStats(fp, chrom, 10000000, 10000100, 2, min);
|
171
|
-
if(stats) {
|
172
|
-
printf("%s:10000000-10000100 min: %f %f\n", chrom, stats[0], stats[1]);
|
173
|
-
free(stats);
|
174
|
-
}
|
175
|
-
|
176
|
-
stats = bwStats(fp, chrom, 10000000, 10000100, 1, max);
|
177
|
-
if(stats) {
|
178
|
-
printf("%s:10000000-10000100 max: %f\n", chrom, stats[0]);
|
179
|
-
free(stats);
|
180
|
-
}
|
181
|
-
|
182
|
-
stats = bwStats(fp, chrom, 10000000, 10000100, 2, max);
|
183
|
-
if(stats) {
|
184
|
-
printf("%s:10000000-10000100 max: %f %f\n", chrom, stats[0], stats[1]);
|
185
|
-
free(stats);
|
186
|
-
}
|
187
|
-
|
188
|
-
stats = bwStats(fp, chrom, 10000000, 10000100, 1, cov);
|
189
|
-
if(stats) {
|
190
|
-
printf("%s:10000000-10000100 coverage: %f\n", chrom, stats[0]);
|
191
|
-
free(stats);
|
192
|
-
}
|
193
|
-
|
194
|
-
stats = bwStats(fp, chrom, 10000000, 10000100, 2, cov);
|
195
|
-
if(stats) {
|
196
|
-
printf("%s:10000000-10000100 coverage: %f %f\n", chrom, stats[0], stats[1]);
|
197
|
-
free(stats);
|
198
|
-
}
|
199
|
-
|
200
|
-
bwClose(fp);
|
201
|
-
bwCleanup();
|
202
|
-
return 0;
|
203
|
-
}
|
@@ -1,46 +0,0 @@
|
|
1
|
-
#include "bigWig.h"
|
2
|
-
#include <stdio.h>
|
3
|
-
#include <inttypes.h>
|
4
|
-
#include <stdlib.h>
|
5
|
-
#include <assert.h>
|
6
|
-
|
7
|
-
//This is an example call back function
|
8
|
-
CURLcode callBack(CURL *curl) {
|
9
|
-
CURLcode rv;
|
10
|
-
|
11
|
-
rv = curl_easy_setopt(curl, CURLOPT_USERNAME, "anonymous");
|
12
|
-
if(rv != CURLE_OK) return rv;
|
13
|
-
|
14
|
-
rv = curl_easy_setopt(curl, CURLOPT_PASSWORD, "libBigWig@github.com");
|
15
|
-
return rv;
|
16
|
-
}
|
17
|
-
|
18
|
-
int main(int argc, char *argv[]) {
|
19
|
-
bigWigFile_t *fp = NULL;
|
20
|
-
int64_t i;
|
21
|
-
|
22
|
-
if(argc != 2) {
|
23
|
-
fprintf(stderr, "Usage: %s {file.bw|URL://path/file.bw}\n", argv[0]);
|
24
|
-
return 1;
|
25
|
-
}
|
26
|
-
|
27
|
-
if(bwInit(1<<17) != 0) {
|
28
|
-
fprintf(stderr, "Received an error in bwInit\n");
|
29
|
-
return 1;
|
30
|
-
}
|
31
|
-
|
32
|
-
fp = bwOpen(argv[1], callBack, "r");
|
33
|
-
if(!fp) {
|
34
|
-
fprintf(stderr, "An error occured while opening %s\n", argv[1]);
|
35
|
-
return 1;
|
36
|
-
}
|
37
|
-
|
38
|
-
//Return the number of chromosomes/contigs
|
39
|
-
for(i=0; i<fp->cl->nKeys; i++) {
|
40
|
-
printf("%s\t%"PRIu32"\n", fp->cl->chrom[i], fp->cl->len[i]);
|
41
|
-
}
|
42
|
-
|
43
|
-
bwClose(fp);
|
44
|
-
bwCleanup();
|
45
|
-
return 0;
|
46
|
-
}
|
@@ -1,68 +0,0 @@
|
|
1
|
-
#include "bigWig.h"
|
2
|
-
#include <stdio.h>
|
3
|
-
#include <inttypes.h>
|
4
|
-
#include <stdlib.h>
|
5
|
-
#include <assert.h>
|
6
|
-
|
7
|
-
int main(int argc, char *argv[]) {
|
8
|
-
bigWigFile_t *ifp = NULL;
|
9
|
-
bigWigFile_t *ofp = NULL;
|
10
|
-
uint32_t tid, i;
|
11
|
-
char **chroms;
|
12
|
-
bwOverlappingIntervals_t *o;
|
13
|
-
if(argc != 3) {
|
14
|
-
fprintf(stderr, "Usage: %s {inputfile.bw|URL://path/inputfile.bw} outputfile.bw\n", argv[0]);
|
15
|
-
return 1;
|
16
|
-
}
|
17
|
-
|
18
|
-
if(bwInit(1<<17) != 0) {
|
19
|
-
fprintf(stderr, "Received an error in bwInit\n");
|
20
|
-
return 1;
|
21
|
-
}
|
22
|
-
|
23
|
-
ifp = bwOpen(argv[1], NULL, "r");
|
24
|
-
if(!ifp) {
|
25
|
-
fprintf(stderr, "An error occured while opening %s\n", argv[1]);
|
26
|
-
return 1;
|
27
|
-
}
|
28
|
-
|
29
|
-
ofp = bwOpen(argv[2], NULL, "w");
|
30
|
-
if(!ofp) {
|
31
|
-
bwClose(ifp);
|
32
|
-
fprintf(stderr, "An error occured while opening %s\n", argv[2]);
|
33
|
-
return 1;
|
34
|
-
}
|
35
|
-
|
36
|
-
if(bwCreateHdr(ofp, 10)) goto error; //ten zoom levels
|
37
|
-
ofp->cl = bwCreateChromList(ifp->cl->chrom, ifp->cl->len, ifp->cl->nKeys);
|
38
|
-
if(!ofp->cl) goto error;
|
39
|
-
|
40
|
-
if(bwWriteHdr(ofp)) goto error;
|
41
|
-
|
42
|
-
//Copy all of the intervals
|
43
|
-
for(tid = 0; tid < ofp->cl->nKeys; tid++) {
|
44
|
-
o = bwGetOverlappingIntervals(ifp, ofp->cl->chrom[tid], 0, ofp->cl->len[tid]);
|
45
|
-
if(!o) goto error;
|
46
|
-
if(o->l) {
|
47
|
-
chroms = malloc(o->l * sizeof(char*));
|
48
|
-
if(!chroms) goto error;
|
49
|
-
for(i=0; i<o->l; i++) chroms[i] = ofp->cl->chrom[tid];
|
50
|
-
bwAddIntervals(ofp, chroms, o->start, o->end, o->value, o->l);
|
51
|
-
free(chroms);
|
52
|
-
}
|
53
|
-
bwDestroyOverlappingIntervals(o);
|
54
|
-
}
|
55
|
-
|
56
|
-
bwClose(ifp);
|
57
|
-
bwClose(ofp);
|
58
|
-
bwCleanup();
|
59
|
-
|
60
|
-
return 0;
|
61
|
-
|
62
|
-
error:
|
63
|
-
fprintf(stderr, "Got an error somewhere!\n");
|
64
|
-
bwClose(ifp);
|
65
|
-
bwClose(ofp);
|
66
|
-
bwCleanup();
|
67
|
-
return 1;
|
68
|
-
}
|