aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2013-11-11 19:42:48 -0500
committerCalvin Morrison <mutantturkey@gmail.com>2013-11-11 19:42:48 -0500
commit510a8001307afc24199d22bbfb7730c972ca6d69 (patch)
tree2afe9512e5748a5d6cfb1ba129e6c6739e803737
parent46f2d59d824805c7e6d14e84ff328a8004fd2949 (diff)
fix warnings
-rw-r--r--kmer_total_count.c35
-rw-r--r--kmer_utils.h1
2 files changed, 22 insertions, 14 deletions
diff --git a/kmer_total_count.c b/kmer_total_count.c
index 8310e00..57d4fcc 100644
--- a/kmer_total_count.c
+++ b/kmer_total_count.c
@@ -13,7 +13,7 @@ int main(int argc, char **argv) {
char *filename = NULL;
- unsigned int kmer = NULL;
+ unsigned int kmer = 0;
bool nonzero = 0;
bool label = 0;
@@ -21,9 +21,7 @@ int main(int argc, char **argv) {
unsigned long long width = 0;
- unsigned long long i = 0;
-
- long long j = 0;
+ unsigned long long i = 0;
static struct option long_options[] = {
{"input", required_argument, 0, 'i'},
@@ -69,7 +67,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error: filename (-i) must be supplied\n");
exit(EXIT_FAILURE);
}
- if(kmer == NULL && !kmer_set) {
+ if(kmer == 0 && !kmer_set) {
fprintf(stderr, "Error: kmer (-k) must be supplied\n");
exit(EXIT_FAILURE);
}
@@ -87,26 +85,35 @@ int main(int argc, char **argv) {
// if labels is set, print out our labels
if(label) {
for(i = 0; i < width; i++)
- if(counts[i] != 0)
- fprintf(stdout, "%s\t%llu\n", index_to_kmer(i, kmer), counts[i]);
-
+ if(counts[i] != 0) {
+ char *kmer_str = index_to_kmer(i, kmer);
+ fprintf(stdout, "%s\t%llu\n", kmer_str, counts[i]);
+ free(kmer_str);
+ }
+
}
else {
for(i = 0; i < width; i++)
if(counts[i] != 0)
fprintf(stdout, "%llu\t%llu\n", i, counts[i]);
-
+
}
}
// If we aren't printing nonzeros print everything
else {
if(label) {
- for(i = 0; i < width; i++)
- fprintf(stdout, "%s\t%llu\n", index_to_kmer(i, kmer), counts[i]);
- }
+ for(i = 0; i < width; i++) {
+ if(counts[i] != 0) {
+ char *kmer_str = index_to_kmer(i, kmer);
+ fprintf(stdout, "%s\t%llu\n", kmer_str, counts[i]);
+ free(kmer_str);
+ }
+ }
+ }
else {
- for(i = 0; i < width; i=i+4)
- fprintf(stdout, "%llu\n%llu\n%llu\n%llu\n", counts[i], counts[i+1], counts[i+2], counts[i+3]);
+ for(i = 0; i < width; i=i+4) {
+ fprintf(stdout, "%llu\n%llu\n%llu\n%llu\n", counts[i], counts[i+1], counts[i+2], counts[i+3]);
+ }
}
}
return EXIT_SUCCESS;
diff --git a/kmer_utils.h b/kmer_utils.h
index 4ed5928..762c20c 100644
--- a/kmer_utils.h
+++ b/kmer_utils.h
@@ -1,6 +1,7 @@
// Kmer functions
void convert_kmer_to_num(char *str, const unsigned long length);
unsigned long num_to_index(const char *str, const int kmer, const long error_pos);
+char *index_to_kmer(unsigned long long index, long kmer);
unsigned long long * get_kmer_counts_from_file(const char *fn, const int kmer);
// Utility functions