Bioawk - using bash variables
1
0
Entering edit mode
5.4 years ago
spiral01 ▴ 110

Hi, I am using bioawk to extract entries in a fasta file based on partial matches on IDs. Now normally I can use a bash variable in awk by assigning it using -v. However, when using bioawk, the variable does not seem to be stored as gene, and as such I get no matches. I have tested this using the actual ID name instead of the variable and it works, so it must be an issue with assigning the variable. What am I doing wrong?

for i in ${IDs[@]}; do cat humanGeneOrthologs.fa | bioawk -v gene="$i" -c fastx '$name ~ /gene/ \
{ print ">"$name"\n"$seq"\n"; }'; done
awk software error • 2.1k views
ADD COMMENT
1
Entering edit mode
5.4 years ago
AK ★ 2.2k

Hi spiral01,

Try changing /gene/ to gene in your awk code:

for i in ${IDs[@]}; do
  cat humanGeneOrthologs.fa \
    | bioawk -v gene="$i" -c fastx '$name ~ gene { print ">"$name"\n"$seq }'
done
ADD COMMENT
0
Entering edit mode

Perfect. This works. Sorry but could explain why this change works? Thanks.

ADD REPLY
0
Entering edit mode

Hi spiral01,

When you use /gene/, (bio)awk understands it as a literal "gene", not the variable.

ADD REPLY

Login before adding your answer.

Traffic: 2435 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6