+2  A: 

try without the quotes. and you forgot some slashes.

for i in ${1}/*
do
filename=$(basename $i)
local/ncbi-blast-2.2.23+/bin/psiblast \
 -query "${i}" \
 -db "$db" \
 -out "${outfile}/${filename}.out" \
 -evalue "$e" \
 -num_threads "$threads" \
 -num_iterations "$itnum" \
 -out_pssm "${pssm}/$filename" \
 -out_ascii_pssm "${pssm_txt}/${filename}.txt" \
 -pseudocount "$pseudo" \
 -inclusion_ethresh "$pwa_inclusion"
done
ghostdog74
The slashes aren't supposed to be there, the variables give the absolute path plus the common filename suffix.
reve_etrange
Not quoting the entire multiline command fixed it, thanks.
reve_etrange
A: 

The behavior you're observing will occur if there are spaces in the filenames you're iterating over. For this reason, you'll want to properly quote your filenames, as in the following minimal example:

#!/bin/bash
for i in *
do
  filename="$(basename "$i")"
  command="ls -lah '$filename'"
  echo "filename=$filename"
  echo "Command = $command"
  eval "$command"
done
RTBarnard
None of my filenames have spaces. Adding quotes anyway doesn't help.
reve_etrange
A: 

Adding quotes to filenames will not help when using a for loop. To overcome this, I've always done something similar to the following example whenever I needed to loop over filenames:

ls -1 directory | { while read line; do echo $line; done; }
musashiXXX