-
Notifications
You must be signed in to change notification settings - Fork 0
/
snp_parser.sh
executable file
·75 lines (65 loc) · 2.24 KB
/
snp_parser.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
#filtered_snps and degenerate_pos folders should be created in the directory before
if [ -z "$1" ]; then
echo "input data will be expected in ./data/..."
echo "...orfs/"
echo "...filtered_snps/"
echo "computed data will be saved to ./data/..."
echo "...snp_codons/"
echo "...degenerate_pos/"
mkdir -p './data/filtered_snps'
mkdir -p './data/degenerate_pos'
mkdir -p './data/snp_codons'
else
echo "saving computed data to $1..."
echo "...filtered_snps"
echo "...degenerate_pos"
echo "crating output folders in $1"
mkdir -p $1'filtered_snps'
mkdir -p $1'degenerate_pos'
mkdir -p $1'snp_codons'
if [ -h './data/filtered_snps' ]
then
echo "./data/filtered_snps already exist, the input is expected to be there."
else
echo "creating sybolic link of $1'filtered_snps' to ./data/"
ln -s $1'filtered_snps' ./data/
fi
if [ -h './data/orfs' ]
then
echo "./data/orfs already exist, the input is expected to be there."
else
echo "creating sybolic link of $1'orfs' to ./data/"
ln -s $1'orfs' ./data/
fi
if [ -h './data/degenerate_pos' ]
then
echo "./data/filtered_snps already exist, the output will be saved there."
else
echo "creating sybolic link of $1'degenerate_pos' to ./data/"
ln -s $1'degenerate_pos' ./data/
fi
if [ -h './data/snp_codons' ]
then
echo "./data/snp_codons already exist, the output will be saved there."
else
echo "creating sybolic link of $1'snp_codons' to ./data/"
ln -s $1'snp_codons' ./data/
fi
fi
if [ -f ./data/genetic_code_stats.csv ]
then
echo "using precomputed stats of genetics code ./data/genetic_code_stats.csv"
else
echo "computing stats of genetics code ./data/genetic_code.csv"
Rscript ./scripts/genetic_code_parser.r
fi
declare -a timemas=("Tdi" "Tps" "Tsi" "Tcm" "Tms" "Tce" "Tge" "Tpa" "Tte" "Tbi")
## now loop through the above array
for sp in "${timemas[@]}"; do
python ./scripts/snp2codonVariants.py './data/orfs/'$sp'.cds.fa' './data/filtered_snps/'$sp'.filtered.snps' > './data/snp_codons/'$sp'_snp_codons.csv'
python ./scripts/degeneratedSites.py './data/orfs/'$sp'.cds.fa' ./data/genetic_code_stats.csv > './data/degenerate_pos/'$sp'_degenerate_pos.csv'
echo "$sp ... Done"
done
Rscript ./scripts/SynSubsFreq.R
Rscript ./scripts/SynSubsFreqTotal.R