Thank you for the suggestion!
• 0 views
•
link
Hi, I am trying to run Unicycler for hybrid assembly using the following command. However, I have more than 40 samples. I am looking to run Unicycler in a "for loop". Please suggest a bash or python script to run it.
unicycler -1 sample1_R1.fastq.gz -2 sample1_R2.fastq.gz -l sample1_ont.fastq.gz --verbosity 2 -o sample1_hybrid_assembly
unicycler -1 sample2_R1.fastq.gz -2 sample2_R2.fastq.gz -l sample2_ont.fastq.gz --verbosity 2 -o sample2_hybrid_assembly
unicycler -1 sample3_R1.fastq.gz -2 sample3_R2.fastq.gz -l sample3_ont.fastq.gz --verbosity 2 -o sample3_hybrid_assembly
.
.
I tried following code: But I am uncertain it is correct.
for f in *.fastq.gz*
do
unicycler -1 $f -2 ${f/R1/R2} -l $f -o ${f/_R1*/\/Assembly}
done
Thank you,
It always amazes me how seldom people use the echo command to check whether their scripts work. Basically, you do the same as above but print the command on screen and see if you get what you wanted. If you do it like this:
for f in *.fastq.gz*
do
echo "unicycler -1 $f -2 ${f/R1/R2} -l $f -o ${f/_R1*/\/Assembly}"
done
... it should be obvious that your for statement needs to be like so:
for f in *R1*.fastq.gz*
do
echo "unicycler -1 $f -2 ${f/R1/R2} -l ${f/R1/ont} --verbosity 2 -o ${f/_R1*/_hybrid_assembly}"
done
Now you do the same as above, but delete the echo and its quotation marks:
for f in *R1*.fastq.gz*
do
unicycler -1 $f -2 ${f/R1/R2} -l ${f/R1/ont} --verbosity 2 -o ${f/_R1*/_hybrid_assembly}
done
Thank you for the suggestion!
Log in to answer this question.