aboutsummaryrefslogtreecommitdiff
path: root/src/sequence_length.c
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2014-03-21 13:42:54 -0400
committerCalvin Morrison <mutantturkey@gmail.com>2014-03-21 13:42:54 -0400
commitf363df2ac34c34b1c2f223bb5a81c456a764ac38 (patch)
treeb353cc9cb2666a9fea870ef92ac62b07bcab77f3 /src/sequence_length.c
parent8a6d1d0373b1acbe563a777f6da2850a06178c34 (diff)
add end of sequences in as points in our array
Diffstat (limited to 'src/sequence_length.c')
-rw-r--r--src/sequence_length.c55
1 files changed, 0 insertions, 55 deletions
diff --git a/src/sequence_length.c b/src/sequence_length.c
deleted file mode 100644
index 3df7175..0000000
--- a/src/sequence_length.c
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2013 Calvin Morrison
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <errno.h>
-int main() {
-
- size_t len = 0;
-
- char buffer[4096];
- bool header = false;
-
- len = fread(&buffer, 1, 1, stdin);
-
- unsigned long long seq_length = 0;
- if(!errno) {
- if(buffer[0] == '>') {
- header = true;
-
- while((len = fread(&buffer, 1, 4096, stdin)) != 0) {
- size_t i = 0;
- for(i = 0; i < len; i++) {
- if(buffer[i] == '>') {
- printf("%llu\n", seq_length);
- seq_length = 0;
- header = true;
- continue;
- }
- else if(buffer[i] == '\n' && header == true) {
- header = false;
- continue;
- }
- if(header == false && buffer[i] != '\n') {
- seq_length++;
- }
- }
- }
- }
- else {
- fprintf(stderr, "this does not look like a fasta file\n");
- return EXIT_FAILURE;
- }
- }
- else {
- fprintf(stderr, "could not read file\n");
- return EXIT_FAILURE;
- }
-
- printf("%llu\n", seq_length);
-
- return EXIT_SUCCESS;
-}
-