#!/bin/bash
helpdoc(){
cat << EOF
Description:
This shellscript is used to run the pipeline to call snp using GATK4
- Data merge: merge multi-BAM files coresponding to specified strain
- Data pre-processing: Mark Duplicates + Base (Quality Score) Recalibration
- Call variants per-sample
- Filter Variants: hard-filtering
Usage:
$0 -S <strain name> -R <bwa index> -k <know-site> -i <intervals list>
Option:
-S strain name, if exist character "/", place "/" with "_" (Required)
-R the path of bwa index (Required)
-k known-sites variants VCF file
-i intervals list file,must be sorted (Required)
EOF
}
#$# 代表所有参数的个数
#若无指定参数,输出h说明文档
if [ $# = 0 ]
then
helpdoc
exit 1
fi
while getopts "h:S:R:k:i:" opt
do
case $opt in
h)
helpdoc
exit 0
;;
S)
strain=$OPTARG
if [[ $strain =~ / ]]
then
echo "Error in specifing strain name , if exist character \"/\", place \"/\" with \"_\""
helpdoc
exit 1
fi
;;
R)
index=$OPTARG
;;
k)
vcf=$OPTARG
if [ ! -f $vcf ]
then
echo "NO SUCH FILE: $vcf"
helpdoc
exit 1
fi
;;
i)
intervals=$OPTARG
if [ ! -f $intervals ]
then
echo "NO SUCH FILE: $intervals"
helpdoc
exit 1
fi
;;
?)
echo "Unknown option: $opt"
helpdoc
exit 1
;;
esac
done
echo $strain
echo $index
echo $vcf
echo $intervals
参考:
perl、shell、python输出参数文档