I'm pretty new to python and I'm trying to embed it in a bash script. I have the following bash shell script:
#!/bin/bash
while read line
do
ORD=`echo $line | cut -c 1-7`
if [[ -r ../FASTA_SEC/COMBI_RAW/${ORD}_COMBI_RAW.fa ]]
then
touch ../Results/Log_Files/Log_${ORD}.txt
for (( win = 2; win < 20; win += 2 )); do
printf 'The value of win is %d, now entereing inner loop\n' "$win"
for (( per = 50; per < 100; per += 2 )); do
printf 'Value of per is %d\n' "$per"
WCNO=`grep -o "n\|N" ../FASTA_SEC/COMBI_RAW/${ORD}_COMBI_RAW.fa | wc -l`
WCNF=`grep -o "n\|N" ../Results/COMBI/${ORD}_COMBI/${ORD}_w${win}_p${per}_COMBI.fa | wc -l`
WCAO=`grep -o "a\|A\|g\|G\|t\|T\|c\|C" ../FASTA_SEC/COMBI_RAW/${ORD}_COMBI_RAW.fa | wc -l`
WCAF=`grep -o "a\|A\|g\|G\|t\|T\|c\|C" ../Results/COMBI/${ORD}_COMBI/${ORD}_w${win}_p${per}_COMBI.fa | wc -l`
PERN=`echo print ($WCNO-$WCNF)/$WCNO. | python`
echo $ORD $PERN
done
done
else
echo ${ORD}"_COMBI_RAW.fa does not exist"
fi
done < ./Data_ORD.txt
I would like to carry out this percentage calculation stored in a variable calling python
PERN=`echo print ($WCNO-$WCNF)/$WCNO. | python`
Parenthesis are giving trouble so i get the following output when i run the bash script:
command substitution: line 17: syntax error near unexpected token `('
command substitution: line 17: `echo print ($WCNO-$WCNF)/$WCNO. | python'
Is it something wrong with bash? operation order are defined with parenthesis in python as far as I know.
Thank you,