How to run Unicycler for hybrid assembly with multiple samples
1
0
Entering edit mode
2.7 years ago
Kumar ▴ 170

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,

assembly fastq Unicycler bacteria • 1.5k views
ADD COMMENT
1
Entering edit mode
2.7 years ago
Mensur Dlakic ★ 28k

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
ADD COMMENT
0
Entering edit mode

Thank you for the suggestion!

ADD REPLY

Login before adding your answer.

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