Hi
I am trying to convert .qual and .fna file to fastq using the script provided here. http://seqanswers.com/forums/showthread.php?t=2775&highlight=fasta+qual+fastq
The code is as follows:
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
use File::Basename;
my $inFasta = $ARGV[0];
my $baseName = basename($inFasta, qw/Reads.fna/);
my $inQual = $baseName . "/Users/myfolder/Reads.qual";
my $outFastq = $baseName . "Reads.fastq";
my %seqs;
$/ = ">";
open (FASTA, "<$inFasta");
my $junk = (<FASTA>);
while (my $frecord = <FASTA>) {
chomp $frecord;
my ($fdef, @seqLines) = split /\n/, $frecord;
my $seq = join '', @seqLines;
$seqs{$fdef} = $seq;
}
close FASTA;
open (QUAL, "<$inQual");
$junk = <QUAL>;
open (FASTQ, ">$outFastq");
while (my $qrecord = <QUAL>) {
chomp $qrecord;
my ($qdef, @qualLines) = split /\n/, $qrecord;
my $qualString = join ' ', @qualLines;
$qualString =~ s/\s+/ /g;
my @quals = split / /, $qualString;
print FASTQ "@","$qdef\n";
print FASTQ "$seqs{$qdef}\n";
print FASTQ "+\n";
foreach my $qual (@quals) {
print FASTQ chr($qual + 33);
}
print FASTQ "\n";
}
close QUAL;
close FASTQ;
I keep getting the error:
readline() on closed filehandle QUAL at fastaQual2fastq.pl line 30.
readline() on closed filehandle QUAL at fastaQual2fastq.pl line 33.
I am running it from command line as:
perl fastaQual2fastq.pl Reads.fna
I get an output file but its 0 kb file which is clearly incorrect. Am I missing something?