Skip to content

Instantly share code, notes, and snippets.

@josephhughes
Created August 24, 2011 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephhughes/1167694 to your computer and use it in GitHub Desktop.
Save josephhughes/1167694 to your computer and use it in GitHub Desktop.
Perl script to split a file containing multiple fastq into separate fast files names according to the fast ID
SplitFastq.pl is a perlscript written by Joseph Hughes, university of Glasgow
Usage:
perl SplitFastq.pl -in ourmultifastqfile
This script will split a file containing multiple fastq into separate fast files names according to the fast ID.
The script uses Bioperl.
#!/usr/bin/perl
#
# use this to split a file containing multiple fastq sequences
use strict;
use Bio::SeqIO;
use Getopt::Long;
my ($file);
&GetOptions(
'in:s' => \$file,#file with mutliple fastq
);
my $seq_in = Bio::SeqIO->new(-file => $file, -format=> 'fastq');
while( my $seq = $seq_in->next_seq() ) {
my $id=$seq->id();
print "ID: $id\n";
my $outfile=$id.".fastq";
my $seq_out = Bio::SeqIO->new(-file => ">$outfile",
-format => 'fastq',);
$seq_out->write_seq($seq);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment