aboutsummaryrefslogtreecommitdiff
path: root/kmer_frequency_per_sequence.c
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2013-11-07 17:25:06 -0500
committerCalvin Morrison <mutantturkey@gmail.com>2013-11-07 17:25:06 -0500
commitb508436d6982205508d531ba19c9980570946ae7 (patch)
tree370577206060fee5d08b784839462aef9c548918 /kmer_frequency_per_sequence.c
parent62343db316259d551ba5924148ef728b9909e6a5 (diff)
rename to counts per sequence, don't provide frequencies only counts
Diffstat (limited to 'kmer_frequency_per_sequence.c')
-rw-r--r--kmer_frequency_per_sequence.c71
1 files changed, 0 insertions, 71 deletions
diff --git a/kmer_frequency_per_sequence.c b/kmer_frequency_per_sequence.c
deleted file mode 100644
index 7b14f6d..0000000
--- a/kmer_frequency_per_sequence.c
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2013 Calvin Morrison
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "kmer_utils.h"
-
-unsigned long position = 0;
-int main(int argc, char **argv) {
-
- 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);
- }
-
- 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) {
- fprintf(stderr, "Error: invalid kmer.\n");
- exit(EXIT_FAILURE);
- }
-
- const unsigned long width = (unsigned long)1 << (kmer * 2);
-
- unsigned long long *counts = malloc((width+ 1) * sizeof(unsigned long long));
- if(counts == NULL)
- exit(EXIT_FAILURE);
-
- while ((read = getline(&line, &len, fh)) != -1) {
- if(line[0] != '>' && (read > kmer)) {
-
- 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++) {
- 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 < width; i++)
- total += counts[i];
-
- for(i = 0; i < width - 1; i++)
- printf("%.12f\t", (double)counts[i] / total);
- printf("%.12f\n", (double)counts[width - 1] / total);
-
- }
- }
-
- free(counts);
- free(line);
-
-
- return EXIT_SUCCESS;
-}