Needle error - cannot get second filename
0
0
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.

needle bash • 779 views
ADD COMMENT
0
Entering edit mode

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.


$ while IFS="," read -r c1 c2; do echo ${c1} ${c2}; res=$(echo ${c1} | sed 's/_*.fasta//'); echo needle -asequence "${c1}" -bsequence "${c2}" -gapopen 10 -gapextend 0.5 -outfile ${res}.needle; done < <(tail -n +2 compare.txt)
Sample1.fasta Sample6.fasta
needle -asequence Sample1.fasta -bsequence Sample6.fasta -gapopen 10 -gapextend 0.5 -outfile Sample1.needle
Sample2.fasta Sample7.fasta
needle -asequence Sample2.fasta -bsequence Sample7.fasta -gapopen 10 -gapextend 0.5 -outfile Sample2.needle
ADD REPLY
0
Entering edit mode

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.

needle -asequence Sample1.fasta -bsequence Sample6.fasta -gapopen 10 -gapextend 0.5 -outfile t.needle

I did try add echo to check whether it prints correctly or not but in terminal it only printed this:

while IFS=$'\t' read -r c1 c2; do echo needle -asequence ${c1} -bsequence ${c2} -gapopen 10 -gapextend 0.5 -outfile t.needle; done < <(tail -n +2 compare.txt)

 -gapopen 10 -gapextend 0.5 -outfile t.needleence Sample6.fasta
 -gapopen 10 -gapextend 0.5 -outfile t.needleence Sample7.fasta

But if I added > text.txt at the end of the command, it can print correctly in the file so that is weird.

needle -asequence Sample1.fasta -bsequence Sample6.fasta
 -gapopen 10 -gapextend 0.5 -outfile t.needle
needle -asequence Sample2.fasta -bsequence Sample7.fasta
 -gapopen 10 -gapextend 0.5 -outfile t.needle
ADD REPLY

Login before adding your answer.

Traffic: 2711 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