FORUMfastq_mergepairs Vsearch
Genevieve asked 5 months ago



  • Is there a way to merge multiple files in one script in Vsearch. Or I need to do one by one (I have 300 samples) ?
    vsearch –fastq_mergepairs filename.fastq –reverse filename.fastq –fastq_maxdiffs 15 –fastq_minovlen 100 –eetabbedout filename.txt –fastaout filename.fasta
    Thank 🙂

    2 Answers
    dmorais Staff answered 5 months ago



  • Hi Genevieve,
     
    I’ve never used vsearch myself, but according to the documentation you can do something like this.
    Considering that your samples names has *_R1_* for forward and *_R2_* for reverse you can use this simple  bash script.
     
    #!/bin/sh
    THREADS=1
    VSEARCH=$(which vsearch)

    for f in *_R1_*.fastq; do
    r=$(sed -e "s/_R1_/_R2_/" <<< "$f")
    s=$(cut -d_ -f1 <<< "$f")
    echo
    echo ====================================
    echo Processing sample $s
    echo ====================================
    $VSEARCH --threads $THREADS \
    --fastq_mergepairs $f \
    --reverse $r \
    --fastq_minovlen 100 \
    --fastq_maxdiffs 15 \
    --eetabbedout $s.txt
    --fastqout $s.merged.fastq \
    done
     
    You can modify the THREADS to the number of threads available in your computer, and in the for loop and sed modify __R1__ to whatever differentiate forward and reverse in you samples.
     
    Cheers
     

    Genevieve replied 5 months ago

    Ok i’m very new in bio-informatic. I’m not sure to understand the first line of your script
    #!/bin/sh
    THREADS=1
    VSEARCH=$(which vsearch)

    When I want to use vsearch on windows. I go to my document that contain vsearch.exe, right clic on the mouse, Git bash here, cmd-enter and now i start to enter command
    Sorry but i don’t know how to start your simple bash script. Could you help me ?

    dmorais Staff answered 5 months ago



  • Hi Genevieve,
    Since you did not specified the OS I assumed that you were on Linux.
    Those tasks are easily done on Linux, unfortunately I don’t use window, but I will check with others here on the forum how to automate this on widows.

    Cheers
     

    Genevieve replied 5 months ago

    Thank for your help