I am trying the following to replace fasta
headers without key-value pairs using bioawk
for infile in $(ls *.faa)
do
prefix=$(basename $infile .faa)
bioawk -c fastx '{ print ">"$prefix"_" ++i "\n"$seq }' < ${infile} > ${prefix}_hdrrn.faa
done
Basically, I want to change the headers in my species_name.faa
file to
>species_name_1
>species_name_2
...
>species_name_n
The problem is the $prefix
inside bioawk
print
is not working. The error I get is:
bioawk: illegal field $(), name "prefix" input record number 1, file source line number 1
Why the substitution is not happening?
It was too easy with seqkit. using 'nr
' does the trick !
for infile in $(ls *.faa)
do
prefix=$(basename $infile .faa)
echo "prefix is ${prefix}"
seqkit replace -p .+ -r ${prefix}_{nr} --nr-width 4 $infile -o ${prefix}_hdrrn.faa
done
echo "done"