Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lala2013
    Junior Member
    • Oct 2013
    • 9

    #1

    Concatenate Paired End Reads Files In Order

    Hi, I wanted to combine paired end reads into two files--one for R1 and one for R2. How do I do it using Linux Command line while making sure the orders are the same in the two file files?

    For example, here are all the files in the directory
    L001_R1_001.fastq
    L002_R2_001.fastq
    L004_R1_001.fastq
    L005_R2_001.fastq
    L001_R2_001.fastq
    L003_R1_001.fastq
    L004_R2_001.fastq
    L006_R1_001.fastq
    L002_R1_001.fastq
    L003_R2_001.fastq
    L005_R1_001.fastq
    L006_R2_001.fastq

    I wanted to do the following:
    cat L001_R1_001.fastq L002_R1_001.fastq L003_R1_001.fastq L004_R1_001.fastq L005_R1_001.fastq L006_R1_001.fastq > R1.fastq

    cat L001_R2_001.fastq L002_R2_001.fastq L003_R2_001.fastq L004_R2_001.fastq L005_R2_001.fastq L006_R2_001.fastq > R2.fastq

    I can manually sort, copy, and paste for now. But what is a good way of doing it for large number of samples?

    Thanks
  • kcchan
    Senior Member
    • Jul 2012
    • 186

    #2
    The quick and dirty way would be
    Code:
    cat *R1* > R1.fastq
    cat *R2* > R2.fastq

    Comment

    • lala2013
      Junior Member
      • Oct 2013
      • 9

      #3
      Can you make sure the two output files combined the input files in the same order, like L001-L006?

      Comment

      • winsettz
        Member
        • Sep 2012
        • 91

        #4
        Originally posted by lala2013 View Post
        Can you make sure the two output files combined the input files in the same order, like L001-L006?
        Code:
        [m@f ~]$ head 1
        1
        [m@f ~]$ head 2
        2
        [m@f ~]$ head 3
        3
        [m@f ~]$ cat 1 2 3 | head
        1
        2
        3
        [m@f ~]$ cat 2 1 3 | head
        2
        1
        3
        In short, doing

        cat L001 L002 L003 L004 > filename

        If you feel fancy with for-loops:

        Code:
        for SUFFIX in R1_001.fastq R2_001.fastq
        do
        cat L001_$SUFFIX L002_$SUFFIX L003_$SUFFIX L004_$SUFFIX L005_$SUFFIX L006_$SUFFIX > cat_$SUFFIX
        done
        Last edited by winsettz; 10-15-2013, 11:56 AM.

        Comment

        Latest Articles

        Collapse

        • SEQadmin2
          16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
          by SEQadmin2




          NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification, detection...
          Yesterday, 06:46 AM
        • SEQadmin2
          Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
          by SEQadmin2



          Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

          Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
          ...
          10-14-2026, 09:55 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, 10-28-2026, 09:57 AM
        0 responses
        27 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-28-2026, 09:51 AM
        0 responses
        18 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 11:13 AM
        0 responses
        71 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 10:48 AM
        0 responses
        48 views
        0 reactions
        Last Post SEQadmin2  
        Working...