[Bioperl-l] Creating a fastq format file?

Dan Bolser dan.bolser at gmail.com
Wed Apr 22 13:36:03 UTC 2009


Cheers Mark - I was having difficulty understanding that module... I
should read more and post less ;-) I got it figured out now...

Here is my working code, based on the example kindly posted by Phillip
San Miguel

#!/usr/bin/perl -w

use warnings;
use strict;
use Bio::SeqIO;
use Bio::Seq::Quality;

my ($seq_infile,$qual_infile)  =(scalar @ARGV == 1)
                         ?($ARGV[0]    ,"$ARGV[0].qual")
                         :@ARGV;

#Create input objects for both a seq (fasta) and qual file

my $in_seq_obj =
  Bio::SeqIO->new( -file   => $seq_infile,
		   -format => 'fasta',
		 );

my $in_qual_obj =
  Bio::SeqIO->new( -file   => $qual_infile,
		   -format => 'qual',
		 );

my $out_fastq_obj =
  Bio::SeqIO->new( -format => 'fastq'
		 );

while (1){
  ## create objects for both a seq and its associated qual
  my $seq_obj  = $in_seq_obj->next_seq || last;
  my $qual_obj = $in_qual_obj->next_seq;

  #use seq and qual object methods feed info for new BSQ object
  my $bsq_obj =
    Bio::Seq::Quality->new( -seq  => $seq_obj->seq(),
			    -qual => $qual_obj->qual(),
			  );

  $out_fastq_obj->write_fastq($bsq_obj);

  exit;
}




2009/4/22 Mark A. Jensen <maj at fortinbras.us>:
> Dan- There is a fastq module under Bio::SeqIO. Do something like
>
>         use Bio::Seq::Quality;
>         use Bio::SeqIO;
>                # from Bio::Seq::Quality synopsis...
>        my $qual = '0 1 2 3 4 5 6 7 8 9 11 12';
>        my $trace = '0 5 10 15 20 25 30 35 40 45 50 55';
>
>        my $seq = Bio::Seq::Quality->new
>            ( -qual => $qual,
>              -trace_indices => $trace,
>              -seq =>  'atcgatcgatcg',
>              -id  => 'human_id',
>              -accession_number => 'S000012',
>              -verbose => -1   # to silence deprecated methods
>        );
>       # typical Bio::SeqIO call
>       $seqio = Bio::SeqIO( -file => ">your_file", -format=>'fastq');
>       $seqio->write_seq($seq);
>
> Mark
> ----- Original Message ----- From: "Dan Bolser" <dan.bolser at gmail.com>
> To: <bioperl-l at lists.open-bio.org>
> Sent: Wednesday, April 22, 2009 6:49 AM
> Subject: [Bioperl-l] Creating a fastq format file?
>
>
>> Creating a fastq format file from fasta and 'fasta quality file'?
>>
>>
>> Hi,
>>
>> I'm sure this is easy, but I'm still not able to 'think bioperl'...
>>
>> I have a 'fasta quality file' and a fasta file, and I would like to
>> output a fastq file. I followed the discussion on the previous thread
>> here:
>>
>> http://bioperl.org/pipermail/bioperl-l/2008-July/028013.html
>>
>>
>> With the conclusion seeming to be 'just do it'. Could someone point me
>> at a way to do this, or was that suggestion an error? i.e. the poster
>> was working out a way to create a fastq the only way possible...
>>
>> I get the feeling that this should be a one-liner, but perhaps the
>> above thread was demonstrating the code I need to copy.
>>
>>
>> Thanks for any suggestions,
>>
>> Dan.
>> _______________________________________________
>> Bioperl-l mailing list
>> Bioperl-l at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>>
>>
>




More information about the Bioperl-l mailing list