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
          Recent Advances in Sequencing Analysis Tools
          by seqadmin


          The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
          Today, 07:48 AM
        • 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

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, Today, 07:17 AM
        0 responses
        11 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 05-02-2024, 08:06 AM
        0 responses
        19 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-30-2024, 12:17 PM
        0 responses
        20 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-29-2024, 10:49 AM
        0 responses
        28 views
        0 likes
        Last Post seqadmin  
        Working...
        X