You are sending the wrong file names.
From the error message I understand that megahit is looking for the file "assembly_sample1_1.fq_1.fq", which doesn't exist
Try this:
for i in *_1.fq
do
read1=${i/.fq/}
read2=${read1/_1/_2}
/home/fernado/megahit/megahit -1 $read1 -2 $read2 -o assembly$i
done
Sorry... I don't understand what you mean by "it seems that you do not recognize the key and change it by parentheses, but I have a error"
Let's debug step by step:
try this and let me know if this gives an error.
mkdir test_dir
cd test_dir
touch sample1_1.fq sample1_2.fq sample2_1.fq sample2_2.fq
for i in *_1.fq
do
read1=${i/.fq/}
read2=${read1/_1/_2}
echo "/home/fernado/megahit/megahit -1 $read1 -2 $read2 -o assembly$i"
done
I am sorry... I don't know what to do. For me it works :-(
However, try to change the way you feed the read name to megahit. Maybe, if you have a few files, you can start by feeding the names by hand and then when you will have figured out the correct way to feed the names you can use automated scripts.
As far as the Bad substitution, try to give a look here
Hi, I try as you suggest but it seems that not recognize the key in the script, therefore I have a error
.
/assembly.sh ./assembly.sh:6: ./assembly.sh: Bad substitution
This the script
When I changed the key by parentheses it works but does not recognize the files
For example this the error
Sorry... I don't understand what you mean by "it seems that you do not recognize the key and change it by parentheses, but I have a error" Let's debug step by step: try this and let me know if this gives an error.
copy the script exactly, but there is an error
And the lines 6 is this:
I am sorry... I don't know what to do. For me it works :-(
However, try to change the way you feed the read name to megahit. Maybe, if you have a few files, you can start by feeding the names by hand and then when you will have figured out the correct way to feed the names you can use automated scripts.
As far as the Bad substitution, try to give a look here
I think my shell is the problem because donĀ“t recognize "{ }", I try to use the script in other computer