aboutsummaryrefslogtreecommitdiff
path: root/src/c/quikr_functions.c
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2013-10-29 15:08:42 -0400
committerCalvin Morrison <mutantturkey@gmail.com>2013-10-29 15:08:42 -0400
commitdc260da91504a190b1833ad6859716a0116d7d4a (patch)
tree46229d55e72d0ab02d6a2ddcb56188e48cbb0d96 /src/c/quikr_functions.c
parent00e5701708abb6837982f9aa5d38117cc5bbaee6 (diff)
update errors from load_sensing_matrix
Diffstat (limited to 'src/c/quikr_functions.c')
-rw-r--r--src/c/quikr_functions.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/c/quikr_functions.c b/src/c/quikr_functions.c
index 2db3f6a..fd7b99e 100644
--- a/src/c/quikr_functions.c
+++ b/src/c/quikr_functions.c
@@ -91,7 +91,7 @@ double *load_count_matrix(const char *filename, const long width, const int kmer
}
-struct sensing_matrix *load_sensing_matrix(const char *filename) {
+struct matrix *load_sensing_matrix(const char *filename) {
char *line = NULL;
char **headers = NULL;
@@ -137,7 +137,7 @@ struct sensing_matrix *load_sensing_matrix(const char *filename) {
line = gzgets(fh, line, 1024);
sequences = strtoull(line, NULL, 10);
if(sequences == 0) {
- fprintf(stderr, "Error parsing sensing matrix, please retrain your matrix\n");
+ fprintf(stderr, "Error parsing sensing matrix, sequence count is zero\n");
exit(EXIT_FAILURE);
}
@@ -145,7 +145,7 @@ struct sensing_matrix *load_sensing_matrix(const char *filename) {
gzgets(fh, line, 1024);
kmer = atoi(line);
if(kmer == 0) {
- fprintf(stderr, "Error parsing sensing matrix, please retrain your matrix\n");
+ fprintf(stderr, "Error parsing sensing matrix, kmer is zero\n");
exit(EXIT_FAILURE);
}
@@ -164,7 +164,7 @@ struct sensing_matrix *load_sensing_matrix(const char *filename) {
headers = malloc(sequences * sizeof(char *));
if(headers == NULL) {
- fprintf(stderr, "could not allocated enough memory\n");
+ fprintf(stderr, "could not allocate enough memory for header pointers\n");
exit(EXIT_FAILURE);
}
@@ -174,18 +174,25 @@ struct sensing_matrix *load_sensing_matrix(const char *filename) {
// get header and add it to headers array
char *header = malloc(256 * sizeof(char));
gzgets(fh, header, 256);
+ if(header[0] != '>') {
+ fprintf(stderr, "Error parsing sensing matrix, could not read header\n");
+ exit(EXIT_FAILURE);
+ }
+
headers[i] = header+1;
for(j = 0; j < width; j++) {
line = gzgets(fh, line, 32);
if(line == NULL || line[0] == '>') {
- fprintf(stderr, "Error parsing sensing matrix, please retrain your matrix\n");
+ fprintf(stderr, "Error parsing sensing matrix, line does not look like a value\n");
exit(EXIT_FAILURE);
}
row[j] = strtoull(line, NULL, 10);
- if(errno)
+ if(errno) {
+ printf("could not parse '%s'\n into a number", line);
exit(EXIT_FAILURE);
+ }
sum += row[j];
}