diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2014-02-02 00:40:35 -0500 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2014-02-02 00:40:35 -0500 |
commit | 18580d2bd0fc240d337b285e6e805104867e891a (patch) | |
tree | 51f497a196ce8325f33928f42dbb0a1616dc9b77 | |
parent | 9e8c8b136fbee0c55c5a428f58fad4ffa2a19702 (diff) |
add a helper function for python
-rw-r--r-- | kmer_utils.c | 11 | ||||
-rw-r--r-- | kmer_utils.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/kmer_utils.c b/kmer_utils.c index a8589c5..587404d 100644 --- a/kmer_utils.c +++ b/kmer_utils.c @@ -229,3 +229,14 @@ unsigned long long * get_kmer_counts_from_file(FILE *fh, const unsigned int kmer return counts; } + +unsigned long long * get_kmer_counts_from_filename(const char *fn, const unsigned int kmer) { + FILE *fh = fopen(fn, "r"); + if(fh == NULL) { + fprintf(stderr, "Could not open %s - %s\n", fn, strerror(errno)); + return 0; + } + + return get_kmer_counts_from_file(fh, kmer); +} + diff --git a/kmer_utils.h b/kmer_utils.h index d71a607..ceb28eb 100644 --- a/kmer_utils.h +++ b/kmer_utils.h @@ -12,4 +12,5 @@ const unsigned char alpha[256]; // file loading functions unsigned long long load_specific_mers_from_file(const char *fn, unsigned int kmer, size_t width, size_t *arr); +unsigned long long * get_kmer_counts_from_filename(const char *fn, const unsigned int kmer); unsigned long long * get_kmer_counts_from_file(FILE *fh, const int kmer); |