A little Perl one liner I borrowed from The Edwards Lab that converts FASTQ to FASTA. Please note I had to truncate the line to make it show properly in this blog entry.
$ cat file_to_covert.fq | perl -e \ '$i=0;while(<>){if(/^\@/&&$i==0){s/^\@/\>/;print;}elsif($i==1){print;$i=-3}$i++;}' \ > output.fastaThanks Edwards Lab!
I wrote the above post and a reader rightly pointed out that it is incorrect (see post comments below). I solved the problem of converting FASTQ to FASTA with the following script, which seems to work fine:
use Bio::SeqIO;
my ($file1,$file2)=@ARGV;
my $seqin = Bio::SeqIO -> new (-format => 'fastq',-file => $file1);
my $seqout = Bio::SeqIO -> new (-format => 'fasta',-file => ">$file2");
while (my $seq_obj = $seqin -> next_seq)
{
$seqout -> write_seq($seq_obj);
}


















































Leave a comment