Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • Split Fastq into 2 files

    Hi All,

    I have a fastq file which I would like to split into 2 files with every other read going into the 2 separate files. What would the Split function command line be for this? I am a new to computing, so it you are most explicit that would be helpful.

    Best,

  • #2
    Found it in a post here:https://stackoverflow.com/questions/...om-a-text-file

    "sed
    You can accomplish the same thing with sed. devnulls answer shows how to do it with GNU sed. Below are alternatives for versions of sed that do not have the ~ operator:

    keep odd lines

    sed 'n; d' infile > outfile
    keep even lines

    sed '1d; n; d' infile > outfile"

    Comment


    • #3
      Fastq reads are in groups of 4 lines

      Hi anoopkmr,

      Thanks for the reply. I made a mistake, I was not clear enough. I would like to partition the odd or even "reads" from a fastq file. The reads are in groups of 4 lines in the fastq file. So I would like read 1 (lines 1-4) to go to file1, and read 2 (lines 5-8) to go to file2, and so on until the whole fastq file is divided into two files, the odd (lines 1-4, 9-12, etc...) output file and the even (lines 5-8, 13-16, etc...) output file.

      Not every even line and every odd line going to the output files.

      Is there a way to do that?

      Best,

      Comment


      • #4
        That makes a lot more sense. Sorry, in my own confusion I thought you were trying something more creative and beyond my understanding.

        fastq-dump seems like an option but if you are generating these files from BAMs it might be easier to step back to the previous step and generate them all at once.

        Not very useful but I hope it helps. Good luck!

        Comment


        • #5
          @landrjos: What you are describing is called an interleaved fastq file where R1 and R2 reads are present in a single file.

          You can use reformat.sh from BBMap suite to separate the R1 and R2 reads into their own files.

          Code:
          reformat.sh in=interleaved.fq.gz out1=R1.fq.gz out2=R2.fq.gz

          Comment


          • #6
            Try this:
            cat original.fastq | awk 'NR%8==1 || NR%8==2 || NR%8==3 || NR%8==4' > first4s.fastq
            cat original.fastq | awk 'NR%8==5 || NR%8==6 || NR%8==7 || NR%8==0' > second4s.fastq

            Comment

            Latest Articles

            Collapse

            • seqadmin
              Strategies for Sequencing Challenging Samples
              by seqadmin


              Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
              03-22-2024, 06:39 AM
            • seqadmin
              Techniques and Challenges in Conservation Genomics
              by seqadmin



              The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

              Avian Conservation
              Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
              03-08-2024, 10:41 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by seqadmin, Yesterday, 06:37 PM
            0 responses
            10 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, Yesterday, 06:07 PM
            0 responses
            9 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, 03-22-2024, 10:03 AM
            0 responses
            49 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, 03-21-2024, 07:32 AM
            0 responses
            67 views
            0 likes
            Last Post seqadmin  
            Working...
            X