diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2013-10-31 15:42:05 -0400 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2013-10-31 15:42:05 -0400 |
commit | 8b543ec38690a7a41297fda56335b7f15cb0be8d (patch) | |
tree | c8e325566ba89568ab41d242a4d1c96c5bb4f441 /src/c/quikr.c | |
parent | 87cf0208484b33d3194add9570b936998b44e9a3 (diff) |
finish up removing OCaml Code and general code refactoring
Diffstat (limited to 'src/c/quikr.c')
-rw-r--r-- | src/c/quikr.c | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/src/c/quikr.c b/src/c/quikr.c index a9b90e0..af6275e 100644 --- a/src/c/quikr.c +++ b/src/c/quikr.c @@ -24,7 +24,6 @@ int main(int argc, char **argv) { char *output_filename = NULL; unsigned long long x = 0; - unsigned long long y = 0; unsigned long long width = 0; @@ -131,45 +130,11 @@ int main(int argc, char **argv) { width = width + 1; // load counts matrix - unsigned long long *integer_counts = get_kmer_counts_from_file(input_fasta_filename, kmer); - double *count_matrix = malloc(sizeof(double) * width); - if(count_matrix == NULL) { - fprintf(stderr, "Could not allocate memory:\n"); - exit(EXIT_FAILURE); - } - - count_matrix[0] = 0; - - for(x = 1; x < width; x++) - count_matrix[x] = (double)integer_counts[x-1]; - - free(integer_counts); - - // normalize our count_matrix - normalize_matrix(count_matrix, 1, width); - - for(x = 0; x < width; x++) - count_matrix[x] = count_matrix[x] * lambda; + double *count_matrix = setup_count_matrix(input_fasta_filename, kmer, lambda, width); // load sensing matrix - struct matrix *sensing_matrix = load_sensing_matrix(sensing_matrix_filename); - if(sensing_matrix->kmer != kmer) { - fprintf(stderr, "The sensing_matrix was trained with a different kmer than your requested kmer\n"); - exit(EXIT_FAILURE); - } - - // multiply our sensing matrix by lambda - for(x = 1; x < sensing_matrix->sequences; x++) { - for(y = 0; y < width - 1; y++) { - sensing_matrix->matrix[width*x + y] = sensing_matrix->matrix[width*x + y] * lambda; - } - } + struct matrix *sensing_matrix = setup_sensing_matrix(input_fasta_filename, kmer, lambda, width); - // set the first column of our sensing matrix to 0 - for(x = 0; x < sensing_matrix->sequences; x++) { - sensing_matrix->matrix[width * x] = 1.0; - } - // run NNLS double *solution = nnls(sensing_matrix->matrix, count_matrix, sensing_matrix->sequences, width); |