Entering edit mode
2.8 years ago
kaixas
•
0
Hi all,
I'm trying to loop through my sequence list for needle
command below:
while IFS="," read -r c1 c2
do \
echo ${c1} ${c2}; \
res=$(echo ${c1} | sed 's/_*.fasta//') \
needle -asequence "${c1}" -bsequence "${c2}" -gapopen 10 -gapextend 0.5 -outfile ${res}.needle \
done < <(tail -n +2 compare.txt)
compare.txt is comma-delimited file that contains list below:
list1,list2
Sample1.fasta,Sample6.fasta
Sample2.fasta,Sample7.fasta
But I got error that it cannot read the files for -bsequence
although I have checked that file existed, and I can echo the second variable correctly.
Error:
Sample1.fasta Sample6.fasta
Needleman-Wunsch global alignment of two sequences
'rror: Failed to open filename 'Sample6.fasta
'rror: Unable to read sequence 'Sample6.fasta
Died: needle terminated: Bad value for '-bsequence' and no prompt
Sample2.fasta Sample7.fasta
Needleman-Wunsch global alignment of two sequences
'rror: Failed to open filename 'Sample7.fasta
'rror: Unable to read sequence 'Sample7.fasta
Died: needle terminated: Bad value for '-bsequence' and no prompt
I believe it is not error from needle
command but actually from the scripting but I'm not sure what terms I can google for this error.
Appreciate if anyone can help with this.
Looks like your code should work. Are the files not in the directory where you are running this from? Try adding relative or full paths to the file names.
I did that too and it doesn't work. I tried to run the code manually like below and it worked so the files are definitely in the directory.
I did try add echo to check whether it prints correctly or not but in terminal it only printed this:
But if I added
> text.txt
at the end of the command, it can print correctly in the file so that is weird.