diff options
Diffstat (limited to 'src/c')
-rw-r--r-- | src/c/Makefile | 2 | ||||
-rw-r--r-- | src/c/quikr_functions.c | 26 |
2 files changed, 9 insertions, 19 deletions
diff --git a/src/c/Makefile b/src/c/Makefile index ba0c799..152121a 100644 --- a/src/c/Makefile +++ b/src/c/Makefile @@ -1,7 +1,7 @@ UNAME := $(shell uname) CC = gcc QUIKR_TRAIN_CFLAGS = -O3 -s -mtune=native -Wall -lm -lz -D$(UNAME) -QUIKR_CFLAGS = -O3 -s -mtune=native -Wextra -Wall -lm -pthread -L../ -I../ -std=gnu99 -fopenmp -D$(UNAME) +QUIKR_CFLAGS = -O3 -s -mtune=native -Wextra -Wall -lm -pthread -L../ -I../ -std=gnu99 -fopenmp -D$(UNAME) -lz all: quikr_train_ quikr_ multifasta_to_otu_ multifasta_to_otu_: diff --git a/src/c/quikr_functions.c b/src/c/quikr_functions.c index 7e18e64..31afb3b 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]; @@ -86,19 +87,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); @@ -106,20 +102,14 @@ 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); + sensing_matrix[width*x + y] = atof(buffer); } } - pclose(sensing_matrix_fh); + gzclose(sensing_matrix_fh); return sensing_matrix; } |