aboutsummaryrefslogtreecommitdiff
path: root/src/c/quikr_functions.c
diff options
context:
space:
mode:
authorCalvin <calvin@EESI>2013-06-10 12:01:11 -0400
committerCalvin <calvin@EESI>2013-06-10 12:01:11 -0400
commit884f6d5a31d66ca20f6f88200c2dae031e470029 (patch)
tree456d9d9eef8e256f4973c128d51ff0796fc7e645 /src/c/quikr_functions.c
parent474f45736147895e5d1e0bd5669bbea4554ad608 (diff)
native zlib decoding for quikr/multifasta, was done earlier but never commited for some reason
Diffstat (limited to 'src/c/quikr_functions.c')
-rw-r--r--src/c/quikr_functions.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/c/quikr_functions.c b/src/c/quikr_functions.c
index e55b28c..42c9f7d 100644
--- a/src/c/quikr_functions.c
+++ b/src/c/quikr_functions.c
@@ -6,6 +6,7 @@
#include <unistd.h>
#include <string.h>
#include <math.h>
+#include <zlib.h>
int count_sequences(char *filename) {
char command[512];
@@ -87,19 +88,14 @@ double *load_sensing_matrix(char *filename, int height, int width) {
int x = 0;
int y = 0;
- char *line = NULL;
- char *val;
- char command[512];
- size_t len = 0;
- FILE *sensing_matrix_fh = NULL;
+ gzFile sensing_matrix_fh = NULL;
double *sensing_matrix = malloc(height * width * sizeof(double));
if(sensing_matrix == NULL) {
fprintf(stderr, "Could not allocate memory for the sensing matrix\n");
}
- sprintf(command, "gzip -cd %s", filename);
- sensing_matrix_fh = popen(command, "r");
+ sensing_matrix_fh = gzopen(filename, "r");
if(sensing_matrix_fh == NULL) {
fprintf(stderr, "could not open %s", filename);
exit(EXIT_FAILURE);
@@ -107,21 +103,15 @@ double *load_sensing_matrix(char *filename, int height, int width) {
// read our sensing matrix in
for(x = 0; x < height; x++) {
- getline(&line, &len, sensing_matrix_fh);
- char *ptr;
-
- // Read our first element in outside of the loop
- val = strtok_r(line,"\t", &ptr);
- sensing_matrix[width*x + 1] = atof(val);
- // iterate through and load the array
- for (y = 2; y < width; y++) {
- val = strtok_r(NULL, "\t", &ptr);
- sensing_matrix[width*x + y] = atof(val);
+ for (y = 1; y < width; y++) {
+ char buffer[14];
+ gzgets(sensing_matrix_fh, buffer, 14);
+ printf("%s\n", buffer);
+ sensing_matrix[width*x + y] = atof(buffer);
}
}
- free(line);
- pclose(sensing_matrix_fh);
+ gzclose(sensing_matrix_fh);
return sensing_matrix;
}