Last active
December 24, 2015 08:19
-
-
Save maasha/6769603 to your computer and use it in GitHub Desktop.
Script for alphabetical sorting FASTQ files by their identifier. Example: `bzcat unsorted.fq.bz2 | sortfq | bzip2 > sorted.fq.bz2`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Martin A. Hansen (mail@maasha.dk), September 2011 | |
use strict; | |
use warnings; | |
use IPC::Open2; | |
use File::Which; | |
print STDERR "Usage: sortfq < unsorted.fq > sorted.fq\n\n" and exit if -t STDIN; | |
my $exe = which("psort") ? "psort" : "sort"; | |
open2(\*IN, \*OUT, qq(paste - - - - | $exe -k1,1 -t " " | tr "\t" "\n")); | |
while (<>) { | |
print OUT $_; | |
} | |
close OUT; | |
while (<IN>) { | |
print; | |
} | |
close IN; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment