I'm trying to write a script that will go through all of the directories within a directory where it will query a specific sequence against a local blast database. I've run the BLAST search without the bash for loop and used a for loop to create the databases in the first place. I have tried everything suggested by others having this problem (where applicable) to no avail. I'm not copying and pasting anything, I've retyped the script and looked for stupid errors (of which I make plenty). Maybe I'm just not seeing it? Anyway here's the code:
SRV01:~$ for d in ~/data/Shen_transcriptomes/transcriptomes/*/; do tblastn -query ~/data/chitin_binding_protein/cbp_Tectaria_macrodonta.fa -db "$d"*BLASTdb* -out "$(basename "$d")".out; done
When I run the same thing with: echo "$d"*BLASTdb*
, it returns the correct files. So the for loop seems to be working but the above script returns:
Error: Too many positional arguments (1), the offending value: /home/dwickell/data/Shen_transcriptomes/transcriptomes/Acrostichum_aureum_RS90/RS_90_BLASTdb.nin
for every BLASTdb file in the directory.
-edit-
So this works, but I don't know enough about bash to understand why:
SRV01:~/data$ for d in /home/dwickell/data/Shen_transcriptome/transcriptomes/*/*.nin; do
name=$(echo "$d" | cut -f 1 -d '.')
blastn -query ./chitin_binding_protein/cbp_Tectaria_macrodonta.fa -db "$name" -outfmt 6 -out RS_103_tblastn.out; done
I'm betting you have a directory with more than one matching BLAST file. Try this test: