-
Notifications
You must be signed in to change notification settings - Fork 0
/
21-BCFtools_Bowtie2.sh
37 lines (29 loc) · 1.76 KB
/
21-BCFtools_Bowtie2.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
#!/bin/bash
# This program calls variants in BAM files generated by Bowtie2 and sorted and indexed by samtools using bcftools
#______________________________________________________________________________________________________________
################################################################################
# #
# Specifying input and output path variables that are consistent over the loop #
# #
################################################################################
PATH_IN_BAMS=/media/rna/INIA/benchmark/Alignment/Bowtie2/Alignment_BAM
PATH_REF_FILE=/media/rna/INIA/benchmark/Alignment/Bowtie2/Reference_Bowtie2/DM_1-3_516_R44_potato_genome_assembly.v6.1.fa
PATH_VCF_OUT=/media/rna/INIA/benchmark/Variant_calling/BCF_Tools/Bowtie2/VCF_output
mkdir -p $PATH_VCF_OUT
PATH_STAT_OUT=/media/rna/INIA/benchmark/Variant_calling/BCF_Tools/Bowtie2/stat
mkdir -p $PATH_STAT_OUT
# Calculating number of total input samples
TOTAL_SAMPLES=$(ls -l $PATH_IN_BAMS | grep -c ^d)
for folder in ${PATH_IN_BAMS}/*; do
sample=$(basename $folder)
# Output path and name for the VCF file for every sample
VCF_OUT_FILE=$PATH_VCF_OUT/${sample}.vcf
# Specifying file name for compuation times for every sample
COMP=${PATH_STAT_OUT}/computation_times_${sample}.txt
#reads= samtools view -c $PATH_IN_BAMS/$sample/*_sorted*.bam
bcf_start=`date +%s`
bcftools mpileup -f $PATH_REF_FILE $PATH_IN_BAMS/$sample/*_sorted*.bam -d 250 | bcftools call --ploidy 2 -mv -o $VCF_OUT_FILE
bcf_end=`date +%s`
bcf_time=$(($bcf_end-$bcf_start))
echo "bcftools variant calling time in s ($sample): $bcf_time" >> $COMP
done