-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter.sh
103 lines (75 loc) · 1.87 KB
/
filter.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
#!/bin/sh
#SBATCH -A mdiop
#SBATCH -J filter
#SBATCH -p bigmem
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem=50000
#SBATCH --array=1-10
#SBATCH --error="filter.error"
#SBATCH --output="filter-%A_%a.out"
#SBATCH --mail-type=BEGIN,FAIL,END
#SBATCH [email protected]
typeset -F SECONDS
module load R
#Treat expanding unset parameters as error
set -u
#Exit with status 1 if a command throws an error
set -e
if [ $# -le 0 ]
then
echo ""
echo "Filter missing data from vcf file"
echo "Dependencies: vcf files / working directory"
echo "Produces: filtered.vcf.gz"
echo ""
echo "usage: PATH/scripts/filter.sh -p path"
echo ""
echo "-p, --path: Full path to folder where VCF files are stored."
# echo "-v, --vcf: vcf files."
echo ""
exit 1;
fi
PATH_TO_SCRIPT=$0
PATH_TO_SCRIPT=$(echo ${PATH_TO_SCRIPT} | awk -F\scripts/filter.sh '{print $1}')
##############################################################
########### Read arguments from command line #################
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-p|--path)
path="$2"
shift # past argument
shift # past value
;;
# -v|--vcf)
# vcf="$2"
# shift # past argument
# shift # past value
# ;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
echo "********************************"
echo "Parameters passed to script:"
echo "Full Path = $path"
echo "********************************"
#### check if data exists
check_file_existence (){
if [ ! -f $1 ]; then
echo "0"
else
echo "1"
fi
}
#####################################
vcf_files=`ls $path/*.vcf.gz`
vcf=`echo $vcf_files | cut -f $SLURM_ARRAY_TASK_ID -d" "`
Rscript filter.R $path $vcf
sleep 1
echo -e "\n\nWall time is "$SECONDS" seconds"