Assignment 1 part 1 (Initial commit)

This commit is contained in:
2020-10-07 10:25:15 +02:00
commit e56d408905
8 changed files with 563 additions and 0 deletions

2
excercise2/2a.txt Normal file
View File

@ -0,0 +1,2 @@
9
3

19
excercise2/gengenome.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
letters=("A" "C" "G" "T")
num_lines=500
num_char=100
for i in {0..500}
do
line=""
for i in {0..100}
do
choice=$((RANDOM % 4))
line+=${letters[choice]}
done
mkdir -p out/
echo $line >> out/genome.txt
done

14
excercise2/genome.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
if [ [ -z $1 ] -o [ -z $2 ] ]
then
echo 'please provide arguments'
exit
fi
RESULT=`cat $1 | grep -c $2`
echo $2 appeared $RESULT times in $1

23
excercise2/parsegenome.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
#include <string.h>
int main ( int argc, char** args ){
if( argc != 2){
printf("Program use: ./a.out <filePath> );
} else {
string arg1 = args[1];
string arg2 = args[2];
printf("Argument 1 : %s , Argument 2 : %s \n", args[0], args[1]);
FILE* genomeFile = fopen(arg1, 'r' );
//TODO: check file
fclose (genomeFile);
}
}