From 9beee3e285febb8b777ff16b314bf0d399c2300c Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Thu, 27 Feb 2014 12:27:20 -0500 Subject: fixed sparse in combination with --mer-file --- kmer_counts_per_sequence.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/kmer_counts_per_sequence.c b/kmer_counts_per_sequence.c index bd18f04..946b491 100644 --- a/kmer_counts_per_sequence.c +++ b/kmer_counts_per_sequence.c @@ -129,7 +129,6 @@ int main(int argc, char **argv) { width = pow_four(kmer); if(specific_mers) { - sparse = false; desired_indicies = malloc((width) * sizeof(size_t)); if(desired_indicies == NULL) { fprintf(stderr, "%s\n", strerror(errno)); @@ -137,7 +136,7 @@ int main(int argc, char **argv) { } num_desired_indicies = load_specific_mers_from_file(mer_fn, kmer, width, desired_indicies); if(num_desired_indicies == 0) { - fprintf(stderr, "Error: no mers loaded from file"); + fprintf(stderr, "Error: no mers loaded from file\n"); exit(EXIT_FAILURE); } } @@ -181,9 +180,16 @@ int main(int argc, char **argv) { if(specific_mers) { - for(k = 0; k < num_desired_indicies; k++) { - if(desired_indicies[k] != 0) + if(sparse) { + for(k = 0; k < num_desired_indicies; k++) { + if(counts[desired_indicies[k]] != 0) + fprintf(stdout, "%llu\t%zu\t%llu\n", sequence, desired_indicies[k], counts[desired_indicies[k]]); + } + } + else { + for(k = 0; k < num_desired_indicies; k++) { fprintf(stdout, "%llu\t%zu\t%llu\n", sequence, desired_indicies[k], counts[desired_indicies[k]]); + } } } else if(sparse) { -- cgit v1.2.3