Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

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

    Comment


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

      Comment


      • #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

        • seqadmin
          Essential Discoveries and Tools in Epitranscriptomics
          by seqadmin




          The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
          04-22-2024, 07:01 AM
        • seqadmin
          Current Approaches to Protein Sequencing
          by seqadmin


          Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
          04-04-2024, 04:25 PM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 04-11-2024, 12:08 PM
        0 responses
        59 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 10:19 PM
        0 responses
        57 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 09:21 AM
        0 responses
        51 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-04-2024, 09:00 AM
        0 responses
        56 views
        0 likes
        Last Post seqadmin  
        Working...
        X