I have a fastq file and need to remove the identifier, quality, and white space. So far my script looks something like this:
#!/usr/bin/perl -w
use strict;
my $inputFileName = shift;
my $outputFileName = shift;
open INPUTFILE, "<$inputFileName" or die "poop";
open OUTPUT, ">$outputFileName" or die "poop";
my @bases = ('A', 'G', 'T', 'C');
my $line;
while ($line = <INPUTFILE>) {
chomp $line;
if ($line =~ /^\s*$/)
elsif ($line =~ /^\s*@/)
elsif ($line =~ /^+/)
else {print OUTPUT $line, "\n";
}
}
However I keep getting an empty output file. I'm very new to perl, so be gently.
Thanks!!
Your problem is the fastq format doesn't contains spaces, to get only the sequence, it's better to count lines like the solutions proposed below. Also you have no instructions after your
if
,elsif
, you should usenext
.