[Bioperl-l] Passing/Storing "Bio::SeqIO" object to a function

Warren W. Kretzschmar wkretzsch at gmail.com
Thu Jun 24 15:24:34 UTC 2010


Hi,
My understanding is that you are using a SeqIO object in order to
create correctly parsed output files.

In that case for each SeqIO object, open it like this:

for (0..9){
$file = "my_file_$_";
push @outseqIOs, Bio::SeqIO->new(-file   => ">$file", -format => $format );
}

simply make $file correspond to the file (or bin) you want to put your
data into.

then pass @outseqIOs to your other subroutine and once you've created
a seq object, write it to the bin you want it to go to (in this case
file number "7"):

$outseqIOs[7]->write_seq($seq);

I haven't tested the code, but that's the kind of thing I think you're
looking for. For more info, look at the howto:
http://www.bioperl.org/wiki/HOWTO:SeqIO

Warren

On Thu, Jun 24, 2010 at 10:20 AM, Abhishek Pratap
<abhishek.vit at gmail.com> wrote:
> Hi All
>
> I may be hitting a problem which probably hints at my grip of the language.
> I am trying to store Bio::SeqIO object in a hash. I have creates couple of
> Bio::SeqIO objects in a method and storing them as a hash reference. The
> goal is to use them in another subroutine for writing out data to each file.
> The script is trying to bin data into different files.
>
>
> Any idea how I could achieve creating file handles  thru "Bio::SeqIO" object
> in one routine and pass them to another for writing.
>
>
> Thanks!
> -Abhi
>
> foreach my $bin (keys %{ $indexes->{$lane} })
>  {
> my $sample_name = $indexes->{$lane}->{$bin}->{'sample'};
>  my $path="$outpath".'/'."$sample_name";
> mkpath( $path, { verbose => 1, mode => 0711 });
>        my $out = Bio::SeqIO->new(-format=>'fastq-illumina', -file =>
> ">$outpath/$sample_name/$fastQFile");
> $indexes->{$lane}->{$bin}->{'file_handle'}=$out;
>  }
> }
> _______________________________________________
> 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