aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2013-11-07 17:25:33 -0500
committerCalvin Morrison <mutantturkey@gmail.com>2013-11-07 17:25:33 -0500
commitc85897eed647dc993bf832c9e17bf77cf31f5f2d (patch)
tree2928df40a3d7563cd5b22e597a8f9d8512a68f7a
parentb508436d6982205508d531ba19c9980570946ae7 (diff)
rename to counts per sequence, don't provide frequencies only counts
-rw-r--r--kmer_counts_per_sequence.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/kmer_counts_per_sequence.c b/kmer_counts_per_sequence.c
index d518efc..66accc8 100644
--- a/kmer_counts_per_sequence.c
+++ b/kmer_counts_per_sequence.c
@@ -9,20 +9,20 @@
unsigned long position = 0;
int main(int argc, char **argv) {
- char *line = NULL;
- size_t len = 0;
- ssize_t read;
+ char *line = NULL;
+ size_t len = 0;
+ ssize_t read;
- if(argc != 3) {
- printf("Please supply a filename and a kmer\n");
- exit(EXIT_FAILURE);
- }
+ if(argc != 3) {
+ printf("Please supply a filename and a kmer\n");
+ exit(EXIT_FAILURE);
+ }
- FILE *fh = fopen(argv[1], "r" );
- if(fh == NULL) {
- fprintf(stderr, "Error opening %s - %s\n", argv[1], strerror(errno));
- exit(EXIT_FAILURE);
- }
+ FILE *fh = fopen(argv[1], "r" );
+ if(fh == NULL) {
+ fprintf(stderr, "Error opening %s - %s\n", argv[1], strerror(errno));
+ exit(EXIT_FAILURE);
+ }
unsigned long kmer = atoi(argv[2]);
if(kmer == 0) {
@@ -36,36 +36,36 @@ int main(int argc, char **argv) {
if(counts == NULL)
exit(EXIT_FAILURE);
- while ((read = getline(&line, &len, fh)) != -1) {
- if(line[0] != '>' && (read > kmer)) {
+ while ((read = getline(&line, &len, fh)) != -1) {
+ if(line[0] != '>' && (read > kmer)) {
- unsigned int i = 0;
- unsigned long total = 0;
+ unsigned int i = 0;
+ unsigned long total = 0;
// reset our count matrix to zero
memset(counts, 0, width * sizeof(unsigned long long));
- for(i = 0; i < read - kmer; i++) {
+ for(i = 0; i < read - kmer; i++) {
line[i] = alpha[(int)line[i]];
}
- for(i = 0; i < read - kmer; i++) {
- counts[num_to_index(&line[i],kmer, width)]++;
- }
+ for(i = 0; i < read - kmer; i++) {
+ counts[num_to_index(&line[i],kmer, width)]++;
+ }
- for(i = 0; i < width; i++)
- total += counts[i];
+ for(i = 0; i < width; i++)
+ total += counts[i];
- for(i = 0; i < width - 1; i++)
- printf("%llu\t", counts[i]);
- printf("%llu\n", counts[width - 1]);
+ for(i = 0; i < width - 1; i++)
+ printf("%llu\t", counts[i]);
+ printf("%llu\n", counts[width - 1]);
- }
- }
+ }
+ }
free(counts);
- free(line);
+ free(line);
- return EXIT_SUCCESS;
+ return EXIT_SUCCESS;
}