Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • landrjos
    Junior Member
    • Aug 2018
    • 3

    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,
  • anoopkmr
    Junior Member
    • Aug 2018
    • 4

    #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

    • landrjos
      Junior Member
      • Aug 2018
      • 3

      #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

      • anoopkmr
        Junior Member
        • Aug 2018
        • 4

        #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

        • GenoMax
          Senior Member
          • Feb 2008
          • 7142

          #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

          • lethalfang
            Member
            • Aug 2011
            • 95

            #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

            • SEQadmin2
              Nine Things a Sample Prep Scientist Thinks About Before Sequencing
              by SEQadmin2


              I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.


              Here are nine questions we think about, in roughly the order they matter, before...
              Yesterday, 07:11 AM
            • SEQadmin2
              From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
              by SEQadmin2


              Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


              The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
              ...
              06-02-2026, 10:05 AM
            • SEQadmin2
              Single-Cell Sequencing at an Inflection Point: Early Impacts of New Platforms and Emerging Trends
              by SEQadmin2


              With the launch of new single-cell sequencing platforms in 2026, the field stands at an exciting inflection point. This article surveys the most impactful advances in the field and discusses how they’re reshaping research in cancer, immunology, and beyond.


              Introduction

              Single-cell sequencing technologies have undergone remarkable advances over the past decade, transitioning from low-throughput experimental approaches to highly scalable platforms capable of...
              05-22-2026, 06:42 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, 06-17-2026, 06:09 AM
            0 responses
            17 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-09-2026, 11:58 AM
            0 responses
            38 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-05-2026, 10:09 AM
            0 responses
            43 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-04-2026, 08:59 AM
            0 responses
            49 views
            0 reactions
            Last Post SEQadmin2  
            Working...