Hi!!

I have to analyze paired-end RNA-seq read that are in an unusual format: both pair-end reads are joined in one FASTQ. I need to split the file in two separated FASTQ paried-end files.

There are a galaxy tool named FASTQ splitter that can do this:

---

FASTQ splitter

What it does

Splits a single fastq dataset representing paired-end run into two datasets (one for each end). This tool works only for datasets where both ends have the same length.

Sequence identifiers will have /1 or /2 appended for the split left-hand and right-hand reads, respectively.

Input format

A multiple-fastq file, for example:

    @HWI-EAS91_1_30788AAXX:7:21:1542:1758
    GTCAATTGTACTGGTCAATACTAAAAGAATAGGATCGCTCCTAGCATCTGGAGTCTCTATCACCTGAGCCCA
    +HWI-EAS91_1_30788AAXX:7:21:1542:1758
    hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh`hfhhVZSWehR

Outputs

Left-hand Read:

    @HWI-EAS91_1_30788AAXX:7:21:1542:1758/1
    GTCAATTGTACTGGTCAATACTAAAAGAATAGGATC
    +HWI-EAS91_1_30788AAXX:7:21:1542:1758/1
    hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

Right-hand Read:

    @HWI-EAS91_1_30788AAXX:7:21:1542:1758/2
    GCTCCTAGCATCTGGAGTCTCTATCACCTGAGCCCA
    +HWI-EAS91_1_30788AAXX:7:21:1542:1758/2
    hhhhhhhhhhhhhhhhhhhhhhhh`hfhhVZSWehR

---

Do you know any other standard alone script that can do this job?
copy this code to a file, e.g. `splitPairedEndReads.pl`

    use strict;
    use warnings;
    my $file = $ARGV[0];
    open(FILE, "<$file") || die "cannot open $file\n";
    open(OUT1, ">$file\_1") || die "cannot open $file\_1\n";
    open(OUT2, ">$file\_2") || die "cannot open $file\_2\n";
    while(<FILE>){
        chomp;
        print OUT1 "$_\/1\n";
        print OUT2 "$_\/2\n";
        my $newline = <FILE>; chomp($newline);
        print OUT1 substr($newline, 0, length($newline)/2)."\n";
        print OUT2 substr($newline, length($newline)/2, length($newline)/2)."\n";
        $newline = <FILE>; chomp($newline);
        print OUT1 "$newline\/1\n";
        print OUT2 "$newline\/2\n";
        $newline = <FILE>; chomp($newline);
        print OUT1 substr($newline, 0, length($newline)/2)."\n";
        print OUT2 substr($newline, length($newline)/2, length($newline)/2)."\n";
    }
    close(FILE);

Now call it with `./splitPairedEndReads.pl input.fastq`.

I hope it works.... haven't checked it.