Code:
#!/bin/bash
menu() {
printf "\n MENU \n
==================================\n\n
\t 1 Match patient\n
\t 2 Sanger analysis\n
\t 3 Batch analysis\n
\t 4 Individual analysis\n
\t 5 Supplemental analysis\n
\t 6 Exit\n\n
==================================\n\n"
printf "\t Your choice: "; read menu_choice
case "$menu_choice" in
1) match ;;
2) sanger ;;
3) batch ;;
4) individual ;;
5) supplemental ;;
6) printf "\n Bye! \n\n"; exit ;;
*) printf "\n Invalid choice."; sleep 2; menu ;;
esac
}
match() {
printf "\n\n"
printf "DEBUG INFO: VALUE OF \$id: %s, VALUE OF \$panel: %s\n" $id $panel
printf "What is the id of the patient to be matched : "; read id
printf "What panel: "; read panel
[ -z "$id" ] && printf "\n No ID supplied. Leaving match function." && sleep 2 && menu
[ "$id" = "end" ] && printf "\n Leaving match function." && sleep 2 && menu
cd 'C:\Users\cmccabe\Desktop\annovar'
OMR=Output_Mutation_Report
perl -aF/\\t/ -lne 'BEGIN{%m=map{chomp;s/\cM|\cJ//g;$p=join("\t",(split/\t/)[4,5]);($p,$_)} <>;$m{"#CHROM\tINFO"}=$m{"Chr\tSegment Position"}};/SEGPOS=(\d+)/ || /\t(INFO)\t/ or next;$p=$F[0]."\t".$1;exists $m{$p} and print join("\t",$_,$m{$p})' ${id}_${panel}_${OMR}.txt < ${id}_${panel}_${OMR}_Filtered.vcf > ${id}_matched.vcf
convert
}
convert() {
printf "\n\n"
printf "DEBUG INFO: VALUE OF \$id: %s, VALUE OF \$panel: %s\n" $id $panel
printf "Does the file need to be converted? Y/N "; read convert_choice
case "$convert_choice" in
[yY]) perl convert2annovar.pl -includeinfo -format vcf4old ${id}_matched.vcf > ${id}_matched.avinput
additional ;;
[nN]) additional ;;
*) convert ;;
esac
}
add2text() {
printf "\n\n"
printf "DEBUG INFO: VALUE OF \$id: %s, VALUE OF \$panel: %s\n" $id $panel
cd 'C:\Users\cmccabe\Desktop\annovar'
while read line; do echo -e "$line\n"; done < file.txt
esac
}
additional() {
printf "\n\n"
printf "Are there additonal patients to be matched? Y/N "; read match_choice
case "$match_choice" in
[yY]) id=""; panel=""; match ;;
[nN]) id=""; panel=""; menu ;;
*) additional ;;
esac
}
sanger() {
printf "\n\n"
printf "DEBUG INFO: VALUE OF \$id: %s\n" $id
printf "What is the name of the patient to have sanger annotation : "; read id
[ -z "$id" ] && printf "\n No ID supplied. Leaving match function." && sleep 2 && menu
[ "$id" = "end" ] && printf "\n Leaving match function." && sleep 2 && menu
cd 'C:\Users\cmccabe\Desktop\annovar'
$( perl table_annovar.pl ${id}.txt humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f -otherinfo )
additionalsanger
}
additionalsanger() {
printf "\n\n"
printf "Are there additonal sanger patients? Y/N "; read match_choice
case "$match_choice" in
[yY]) id=""; sanger ;;
[nN]) id=""; panel=""; menu ;;
*) additional ;;
esac
}
batch() {
printf "\n\n"
printf "How many patients : "; read id
[ -z "$id" ] && printf "\n No ID supplied. Leaving match function." && sleep 2 && menu
[ "$id" = "end" ] && printf "\n Leaving match function." && sleep 2 && menu
cd 'C:\Users\cmccabe\Desktop\annovar'
$( perl -ne 'chomp; system ("perl table_annovar.pl $_ humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f -otherinfo")' < file.txt )
printf "Are there additional patients : "; read id
case "$match_choice" in
[yY]) id=""; individual ;;
[nN]) id=""; panel=""; menu ;;
*) individual ;;
esac
}
individual() {
printf "\n\n"
printf "DEBUG INFO: VALUE OF \$id: %s, VALUE OF \$panel: %s\n" $id $panel
printf "What is the id of the patient : "; read id
printf "What panel: "; read panel
[ -z "$id" ] && printf "\n No ID supplied. Leaving match function." && sleep 2 && menu
[ "$id" = "end" ] && printf "\n Leaving match function." && sleep 2 && menu
cd 'C:\Users\cmccabe\Desktop\annovar'
$( perl table_annovar.pl ${id}_matched.avinput humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f -otherinfo )
printf "Are there additional patients : "; read id
case "$match_choice" in
[yY]) id=""; individual ;;
[nN]) id=""; panel=""; menu ;;
*) additional ;;
esac
}
supplemental() {
printf "\n\n"
printf "DEBUG INFO: VALUE OF \$id: %s, VALUE OF \$panel: %s\n" $id $panel
printf "What is the id of the patient : "; read id
printf "What panel: "; read panel
[ -z "$id" ] && printf "\n No ID supplied. Leaving match function." && sleep 2 && menu
[ "$id" = "end" ] && printf "\n Leaving match function." && sleep 2 && menu
cd 'C:\Users\cmccabe\Desktop\annovar'
$( perl table_annovar.pl ${id}_matched.avinput humandb/ -buildver hg19 -protocol refGene,popfreq_all,exac02,1000g2014oct_all,KAT6B,SPRED1,NF1 -operation g,f,f,f,f,f,f -otherinfo )
printf "Are there additional patients : "; read id
case "$match_choice" in
[yY]) id=""; individual ;;
[nN]) id=""; panel=""; menu ;;
*) additional ;;
esac
}
# actual start of this program
menu # run menu function