I am using awk
as part of and if then else statement. I am trying to have the user enter a gene name and then a variant or variants and have a specific transcript assigned to the variants depending on the gene. Below is my code but the if then else statement is wrong. Basically, the gene name would be the condition that assigns a particular transcript to a variant.
The desired output would be, if the user enters GJB2 as the gene name and then c.283G>A for the variant there is a statement for that condition that saves a file with NM_004004.5:c.283G>A
. However if MECP2 is entered as the gene name and c.48delC,c.255G>T are entered as the variants, the a file is saved:
NM_004992.3:c.48delC
NM_004992.3:c.255G>T
Thank you :).
syntax() {
printf "\n\n"
printf "Please enter the gene name : "; read gene
printf "Enter variant(s): "; IFS="," read -a variants
[ -z "$gene" ] && printf "\n No ID supplied. Leaving match function." && sleep 2 && return
[ "$gene" = "end" ] && printf "\n Leaving match function." && sleep 2 && return
awk '{
if(${gene} = "GJB2")
for ((i=0; i<${#variants[@]}; i++))
do printf "NM_004004.5:%s\n" "${variants}" >> c:/Users/cmccabe/Desktop/Python27/$gene.txt >> c:/Users/cmccabe/Desktop/Python27/out.txt;
done
else if(${gene} = "MECP2")
for ((i=0; i<${#variants[@]}; i++))
do printf "NM_004992.3:%s\n" "${variants}" >> c:/Users/cmccabe/Desktop/Python27/$gene.txt >> c:/Users/cmccabe/Desktop/Python27/out.txt;
done
else if(${gene} = "Phox2B")
for ((i=0; i<${#variants[@]}; i++))
do printf "NM_003924.3:%s\n" "${variants}" >> c:/Users/cmccabe/Desktop/Python27/$gene.txt >> c:/Users/cmccabe/Desktop/Python27/out.txt
}'
name
}