From 1a024facb6b6d8747ecfe48dc510b2b0335d9da7 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Sun, 1 Feb 2015 22:58:48 +0100 Subject: [PATCH] mart: ex1 done --- ex1/mart/sws1-s4109503-s4202015.tar.gz | Bin 0 -> 1118 bytes .../sws1-s4109503-s4202015/exercise2/2a.txt | 2 + .../sws1-s4109503-s4202015/exercise2/Makefile | 2 + .../exercise2/gengenome.sh | 1 + .../exercise2/genome.sh | 1 + .../exercise2/parsegenome.c | 55 ++++++++++++++++++ 6 files changed, 61 insertions(+) create mode 100644 ex1/mart/sws1-s4109503-s4202015.tar.gz create mode 100644 ex1/mart/sws1-s4109503-s4202015/exercise2/2a.txt create mode 100644 ex1/mart/sws1-s4109503-s4202015/exercise2/Makefile create mode 100755 ex1/mart/sws1-s4109503-s4202015/exercise2/gengenome.sh create mode 100755 ex1/mart/sws1-s4109503-s4202015/exercise2/genome.sh create mode 100644 ex1/mart/sws1-s4109503-s4202015/exercise2/parsegenome.c diff --git a/ex1/mart/sws1-s4109503-s4202015.tar.gz b/ex1/mart/sws1-s4109503-s4202015.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..02e5755e05247bab9d9e8f20f773ff5e9ef212ba GIT binary patch literal 1118 zcmV-k1flyMiwFR7q0UqQ1MQjJZ`(Ey!1HST6*pyToX)aIeHn9`0!GjV!_xI7#U2tr z$TDSVl_gb_>keuD_a5bsD1kj~b)YWU{a`@+IP*jvk9U&fLUKdeoc-c33kxPQ8FzXI z4+%s1eMen+-(l73ngedyu4VW8+(kL8^w|M84|*3nn9IV;0S;zfUi_V0UH>CRZnwYq zEOI}R!g`3E@NewTTnp`QTTY+s-vl-GHygFTV=`OGDf^pb|0bxlf9B;G2Ywxl@N4MYD-!c1W|30(O{_J6=x}E>I{STwWkLMEsFJ&=_(r)-lyVDd$W7Vcb zNdYr2O4_R6EJlgjb2)S^k-gj$fc?E{b`cfQjWBO>4dR_53wF53r^*`fvhlT}Hh!6L}mZqSBnq zXR1Y3no{4Fm-Yx-u2~0Gznd30dVp;~nu(-c-U1(WK+kn`A2*KWkFWF`T_s1@RJN6k)!E@c zIAf}Nqru=xU28MjpHZZ2*|IEnE3KA@rKpZyDjgmz2Q62Kjc!L#(y$Rbt%~uTVrNw` zbEnuvRm{34wq=fYX0#T*Q48D({5X{YS9NKz&1&F+Im-pB45e)>IK(YDxk^r#m$T*N zVtK*sxLS=>fv*eZx?q(%bu}_B@QwDp-FI(l&;QlYFT-!wQ5*lUZxjE^^WWtzo&Sw+ z3HpzRIvC<3=%x-Mc=im69E?eMFu_ag<~n?VX)ZD_QmmS)y70k>AOG$rYW?5zy2a=H zc79F%hx*p}ALpjU(f=Krx#a&%a0tUhE<`>6M_XW~0>;O8282bC4SGF4|0^rfKgA^K zrunp&i9+PPLU?`{CDV0ez}&&{5ui5zcQ^6hwYiG_ zuIpIj|4pFcwvT~(czSlB(*52jM_mOPrz8Hw-8thg@-kKz^0Snsj$QU z6K^Ku-iiN;+W7C@|NduN7RCQYSet$TZ*hWfJ|B-oF17VW7{Fdt>_^Zl1|$0^_cs+5q<{|1B*cu6f7oST`ExirXbM;fE<00`%=6fR|K&RGrK2|gWA5$w&#dzOFFpp6|2F_Waa$&N5kU|HK@bE% k5ClOG1VIo4K@bE%5ClOG1VIo4K|CtH0=uInNdQm)0O`~_d;kCd literal 0 HcmV?d00001 diff --git a/ex1/mart/sws1-s4109503-s4202015/exercise2/2a.txt b/ex1/mart/sws1-s4109503-s4202015/exercise2/2a.txt new file mode 100644 index 0000000..30eb450 --- /dev/null +++ b/ex1/mart/sws1-s4109503-s4202015/exercise2/2a.txt @@ -0,0 +1,2 @@ +# Answer: 5 +wget -qO- http://cryptojedi.org/peter/teaching/genome.txt | tr -d '\n' | grep -o "GATTACA" | wc -l diff --git a/ex1/mart/sws1-s4109503-s4202015/exercise2/Makefile b/ex1/mart/sws1-s4109503-s4202015/exercise2/Makefile new file mode 100644 index 0000000..95d7d4d --- /dev/null +++ b/ex1/mart/sws1-s4109503-s4202015/exercise2/Makefile @@ -0,0 +1,2 @@ +all: + gcc -Wall parsegenome.c -o parsegenome diff --git a/ex1/mart/sws1-s4109503-s4202015/exercise2/gengenome.sh b/ex1/mart/sws1-s4109503-s4202015/exercise2/gengenome.sh new file mode 100755 index 0000000..4fd66dc --- /dev/null +++ b/ex1/mart/sws1-s4109503-s4202015/exercise2/gengenome.sh @@ -0,0 +1 @@ +tr -cd 'ACGT' < /dev/urandom | fold -w 100 | head -500 diff --git a/ex1/mart/sws1-s4109503-s4202015/exercise2/genome.sh b/ex1/mart/sws1-s4109503-s4202015/exercise2/genome.sh new file mode 100755 index 0000000..5a771a5 --- /dev/null +++ b/ex1/mart/sws1-s4109503-s4202015/exercise2/genome.sh @@ -0,0 +1 @@ +[ "$#" -eq "2" ] && tr -d '\n' < "$1" | grep -o "$2" | wc -l diff --git a/ex1/mart/sws1-s4109503-s4202015/exercise2/parsegenome.c b/ex1/mart/sws1-s4109503-s4202015/exercise2/parsegenome.c new file mode 100644 index 0000000..2572cbe --- /dev/null +++ b/ex1/mart/sws1-s4109503-s4202015/exercise2/parsegenome.c @@ -0,0 +1,55 @@ +#include +#include + +int main(int argc, char* argv[]) +{ + if(argc != 2) + { + printf("Usage: %s filepath\n", argv[0]); + return 2; + } + + FILE *f; + int c = 0; + int charsperline = 0; + int numlines = 0; + int occs[4] = {0, 0, 0, 0}; + + f = fopen(argv[1], "r"); + if(f == NULL) + { + printf("Unable to open file..."); + return 2; + } + + while((c = fgetc(f)) != EOF) + { + if(c == '\n') + { + if(charsperline != 100) + return -1; + numlines += 1; + charsperline = 0; + } + else + { + if(c == 'A') + occs[0] += 1; + else if(c == 'C') + occs[1] += 1; + else if(c == 'G') + occs[2] += 1; + else if(c == 'T') + occs[3] += 1; + else + return -1; + charsperline += 1; + } + } + fclose(f); + if(numlines != 500) + return -1; + + printf("A: %d\nC: %d\nG: %d\nT: %d\n", occs[0], occs[1], occs[2], occs[3]); + return 0; +} -- 2.20.1