-
Notifications
You must be signed in to change notification settings - Fork 0
/
Antobiotic_resistance.sh
executable file
·141 lines (117 loc) · 4.09 KB
/
Antobiotic_resistance.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
path1=./Reference_genome
if [[ ! -e $path1 ]]
then
mkdir Reference_genome
fi
cd ./Reference_genome
fna=./GCA_000005845.2_ASM584v2_genomic.fna
if [[ ! -f $fna ]]
then
echo "Downloading reference genom GCA_000005845.2_ASM584v2.fna GCA_000005845.2_ASM584v2"
wget ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/005/845/GCA_000005845.2_ASM584v2/GCA_000005845.2_ASM584v2_genomic.fna.gz
gunzip GCA_000005845.2_ASM584v2_genomic.fna.gz
fi
gff=./GCA_000005845.2_ASM584v2_genomic.gff
if [[ ! -f $gff ]]
then
wget ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/005/845/GCA_000005845.2_ASM584v2/GCA_000005845.2_ASM584v2_genomic.gff.gz
gunzip GCA_000005845.2_ASM584v2_genomic.gff.gz
fi
cd ../
assembly_genome=./assembly_genome
if [[ ! -e $assembly_genome ]]
then
mkdir assembly_genome
fi
cd ./assembly_genome
forward_as=./amp_res_1.fastq
if [[ ! -f $forward_as ]]
then
echo "Downloading amp_res assembly"
wget http://public.dobzhanskycenter.ru/mrayko/amp_res_1.fastq.zip
unzip amp_res_1.fastq.zip
fi
reversed_as=./amp_res_2.fastq
if [[ ! -f $reversed_as ]]
then
wget http://public.dobzhanskycenter.ru/mrayko/amp_res_2.fastq.zip
unzip amp_res_2.fastq.zip
fi
date +%F >> ../laboratory_book.txt
echo -n "Number of reads forvard: " >> ../laboratory_book.txt
echo "$(cat amp_res_1.fastq | wc -l)/4" | bc >> ../laboratory_book.txt
echo -n "Number of reads reversed: " >> ../laboratory_book.txt
echo "$(cat amp_res_2.fastq | wc -l)/4" | bc >> ../laboratory_book.txt
cd ../
fastqc=./fastqc_results
if [[ ! -e $fastqc ]]
then
mkdir fastqc_results
fi
ampfastq1=./fastqc_results/amp_res_1_fastqc.html
ampfastq2=./fastqc_results/amp_res_2_fastqc.html
if [[ ! -f $ampfastq1 ]]
then
fastqc -o ./fastqc_results ./assembly_genome/amp_res_1.fastq
fi
if [[ ! -f $ampfastq2 ]]
then
fastqc -o ./fastqc_results ./assembly_genome/amp_res_2.fastq
fi
trimmomatic=./assembly_genome/trimmomatic
if [[ ! -e $trimmomatic ]]
then
mkdir ./assembly_genome/trimmomatic
fi
TrimmomaticPE -phred33 ./assembly_genome/amp_res_1.fastq ./assembly_genome/amp_res_2.fastq ${trimmomatic}/_1P$1_$2.fq ${trimmomatic}/ _1U$1_$2.fq ${trimmomatic}/_2P$1_$2.fq ${trimmomatic}/_2U$1_$2.fq LEADING:$1 TRAILING:$2 SLIDINGWINDOW:10:20 MINLEN:20
echo "Number of reads after filte: " >> ./laboratory_book.txt
echo -n "Number of reads forvard: " >> ./laboratory_book.txt
echo "$(cat $trimmomatic/_1P$1_$2.fq | wc -l)/4" | bc >> ./laboratory_book.txt
echo -n "Number of reads reversed: " >> ./laboratory_book.txt
echo "$(cat $trimmomatic/_2P$1_$2.fq | wc -l)/4" | bc >> ./laboratory_book.txt
#_1P= ${trimmomatic}/_1P$1_$2.fq
#_2P= ${trimmomatic}/_2P$1_$2.fq
trimmomatic_f=./fastqc_results/trimmomatic
if [[ ! -e $trimmomatic_f ]]
then
mkdir ./fastqc_results/trimmomatic
fi
trimfastq1=./fastqc_results/trimmomatic/_1P$1_$2_fastqc.html
trimfastq2=./fastqc_results/trimmomatic/_2P$1_$2_fastqc.html
if [[ ! -f $trimfastq1 ]]
then
fastqc -o ./fastqc_results/trimmomatic ./assembly_genome/trimmomatic/_1P$1_$2.fq
fi
if [[ ! -f $trimfastq2 ]]
then
fastqc -o ./fastqc_results/trimmomatic ./assembly_genome/trimmomatic/_2P$1_$2.fq
fi
bwa index ./Reference_genome/GCA_000005845.2_ASM584v2_genomic.fna
sam=./alignment_$1_$2.sam
if [[ ! -f $sam ]]
then
bwa mem ./Reference_genome/GCA_000005845.2_ASM584v2_genomic.fna ./assembly_genome/trimmomatic/_1P$1_$2.fq ./assembly_genome/trimmomatic/_2P$1_$2.fq > alignment_$1_$2.sam
fi
bam=./alignment_$1_$2.bam
if [[ ! -f $bam ]]
then
samtools view -S -b alignment_$1_$2.sam > alignment_$1_$2.bam
echo cat "$(samtools flagstat alignment_$1_$2.bam)" | sed -n 5p >> ./laboratory_book.txt
fi
bam_sort=./alignment_$1_$2_sorted.bam
if [[ ! -f $bam_sort ]]
then
samtools sort alignment_$1_$2.bam > alignment_$1_$2_sorted.bam
samtools index alignment_$1_$2_sorted.bam
fi
mpi=./my.mpileup
if [[ ! -f $mpi ]]
then
samtools mpileup -f ./Reference_genome/GCA_000005845.2_ASM584v2_genomic.fna ./alignment_$1_$2_sorted.bam > my.mpileup
fi
vcf=./varscan_results_$3.vcf
if [[ ! -f $vcf ]]
then
varscan mpileup2snp my.mpileup --min_var_freq $3 --variants --output-vcf 1 > varscan_results_$3.vcf
fi