-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathsplit_fastq.pl
executable file
·46 lines (38 loc) · 1.12 KB
/
split_fastq.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl
# Script: split_fastq.pl
# Description: Splits a fastq file into a fasta and a qual file
# Author: Steven Ahrendt
# email: [email protected]
# Date: 9.8.14
#####################################
# Usage: split_fastq.pl -i fastqfile
#####################################
use warnings;
use strict;
use Bio::Perl;
use Getopt::Long;
#####-----Global Variables-----######
my $input;
my ($help,$verb);
GetOptions ('i|input=s' => \$input,
'h|help' => \$help,
'v|verbose' => \$verb);
my $usage = "Usage: split_fastq.pl -i fastqfile\n";
die $usage if ($help);
die "No input.\n$usage" if (!$input);
#####-----Main-----#####
my $fastqfile = $input;
my $sampleID = (split(/\./, $fastqfile))[0];
my $fastafile = "$sampleID\.fna";
my $qualfile = "$sampleID\.qual";
my $in=Bio::SeqIO->new(-file=>$fastqfile,-format=>"fastq");
my $seqOut=Bio::SeqIO->new(-file=>">$fastafile",-format=>"fasta");
my $qualOut=Bio::SeqIO->new(-file=>">$qualfile",-format=>"qual");
while(my $seq=$in->next_seq)
{
$seqOut->write_seq($seq);
$qualOut->write_seq($seq);
}
warn "Done.\n";
exit(0);
#####-----Subroutines-----#####