From: Mart Lubbers Date: Tue, 3 Feb 2015 20:47:26 +0000 (+0100) Subject: final final final mart X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=3da54df39fa6aeb4f3f861d0d6a0af91671f9492;p=sws1-1415.git final final final mart --- diff --git a/ass1/mart/sws1-s4109503-s4202015/exercise1/commands b/ass1/mart/sws1-s4109503-s4202015/exercise1/commands index 8748d46..d98ef31 100644 --- a/ass1/mart/sws1-s4109503-s4202015/exercise1/commands +++ b/ass1/mart/sws1-s4109503-s4202015/exercise1/commands @@ -1,4 +1,4 @@ -mkdir -p sws1-s4109503-s4202015/exercise{1,2,3} +mkdir -p sws1-s4109503-s4202015/exercise{1,2} cd sws1-s4109503-s4202015 echo -e "s4109503: Mart Lubbers\ns4202015: Chris Kamphuis" > names.txt du -sb | cut -f 1 > exercise1/1b.txt diff --git a/ass1/mart/sws1-s4109503-s4202015/exercise2/Makefile b/ass1/mart/sws1-s4109503-s4202015/exercise2/Makefile index e7ef6d1..fa18e55 100644 --- a/ass1/mart/sws1-s4109503-s4202015/exercise2/Makefile +++ b/ass1/mart/sws1-s4109503-s4202015/exercise2/Makefile @@ -1,5 +1,5 @@ CC=gcc -CFLAGS=-Wall -Wextra +CFLAGS=-std=c99 -Wall -Wextra all: parsegenome.c $(CC) $(CFLAGS) parsegenome.c -o parsegenome diff --git a/ass1/mart/sws1-s4109503-s4202015/exercise2/parsegenome.c b/ass1/mart/sws1-s4109503-s4202015/exercise2/parsegenome.c index d561d4f..9acb1cf 100644 --- a/ass1/mart/sws1-s4109503-s4202015/exercise2/parsegenome.c +++ b/ass1/mart/sws1-s4109503-s4202015/exercise2/parsegenome.c @@ -1,29 +1,30 @@ -#include /* - Basically we save the 4 frequencies in a 64bit int */ -#include /* - The polynome fits the following coordinates: */ -#include /* (65,0), (67, 16), (71, 32), (84, 48) */ -#include /* - Which is the mapping from ascii value and shiftwidth*/ - /* - When no input file is given assume stdin */ +#include +#include +#include +#include + int main(int argc, char* argv[]) { + char *alphabet = "AGTC"; char c; - char charsperline = 0; - short numlines = 0; + int charsperline = 0; + int numlines = 0; uint64_t occs = 0; - FILE *f = (argc!=2 || strcmp(argv[1], "-")==0) ? stdin : fopen(argv[1], "r"); + FILE *f = argc != 2 ? stdin : fopen(argv[1], "r"); if(f == NULL) return 2; - while((c=fgetc(f)) != EOF) + while((c = fgetc(f)) != EOF) if(c == '\n' && charsperline == 100 && numlines++ < 500) charsperline = 0; - else if((c=='A' ||c=='C' || c=='G' || c=='T') && charsperline++<100) - occs += 1LL<<(char)(0.026514*c*c*c-6.049*c*c+459.96*c-11621.2); + else if(strchr(alphabet, c) && charsperline++ < 100) + occs += 1LL<<((int)(strchr(alphabet, c)-alphabet)*16); else break; - if(f != stdout) + if(f != stdin) fclose(f); - if(numlines!=500) + if(numlines != 500) return -1; - printf("A:%u\nC:%u\nG:%u\nT:%u\n", (uint16_t)occs, (uint16_t)(occs>>16), - (uint16_t)(occs>>32), (uint16_t)(occs>>48)); + for(unsigned i=0; i> (16*i))); return 0; }