diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2013-09-11 10:25:14 -0400 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2013-09-11 10:25:14 -0400 |
commit | d74c19c8fceac333f9420a898b85ad0b1a8a85ff (patch) | |
tree | f7224b9d59dae07d3305597771431219c9fe06dd | |
parent | f682537abf93fcbc1d91320ba256bd8389f5d84d (diff) |
update convert_kmer_to_index for brevity and clarity
-rw-r--r-- | kmer_utils.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/kmer_utils.c b/kmer_utils.c index ae01b05..7647965 100644 --- a/kmer_utils.c +++ b/kmer_utils.c @@ -16,40 +16,34 @@ // long kmer - how long of a index value you want to return // long error_pos - what index to return for a non ACGT character // -long convert_kmer_to_index(char *str, long kmer, long error_pos) { +inline long convert_kmer_to_index(char *str, unsigned long kmer, long error_pos) { char **ptr = NULL; char vals[kmer]; - long i = 0; - long ret = 0; + unsigned long i = 0; for(i = 0; i < kmer; i++) { - int val = 0; switch(str[i]) { case 'a': case 'A': - val = 48; + vals[i] = '0'; break; case 'c': case 'C': - val = 49; + vals[i] = '1'; break; case 'g': case 'G': - val = 50; + vals[i] = '2'; break; case 't': case 'T': - val = 51; + vals[i] = '3'; break; default: return error_pos; } - - - vals[i] = val; } - ret = strtol(vals, ptr, 4); - return ret; + return strtol(vals, ptr, 4); } |