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

Abhishek Pratap abhishek.vit at gmail.com
Thu Jun 24 17:03:00 UTC 2010


After a bit more error checking, I was able to resolve the previous error

 Resolved Error : Can't call method "write_seq" on an undefined value
at  /home/apratap/dev/eclipse_workspace/Illumina/demultiplex_GA_data.pl
line 139, <GEN12> line 5.
This happened due to null value returned by one of the hash.

However I am hitting a new issue.
New Error : Can't call method "isa" on unblessed reference at
/local/projects/grc/devel/packages/bioperl-live/Bio/SeqIO/fastq.pm line 126,
<GEN12> line 49


-A



On Thu, Jun 24, 2010 at 12:55 PM, Abhishek Pratap <abhishek.vit at gmail.com>wrote:

> Hi Chris
>
> Thanks for joining this conversation. I dont think max limit of file
> handles is a problem. I am opening about 12 in this case.
>
> [apratap at grima]$ ulimit -n
> 4096
>
> -A
>
>
> On Thu, Jun 24, 2010 at 12:52 PM, Chris Fields <cjfields at illinois.edu>wrote:
>
>> Are you sure you haven't hit the max limit for open filehandles for your
>> OS?  Attempting to open a filehandle when you exceed this limit simply
>> returns undef, which might explain the error.  On my Mac:
>>
>> cjfields4:~ cjfields$ ulimit -n
>> 256
>>
>> On my ubuntu box:
>>
>> cjfields at pyrimidine:~$ ulimit -n
>> 1024
>>
>> I think Windows used to be much less, not sure now.  You might not be able
>> to reset this on some systems.
>>
>> chris
>>
>> On Jun 24, 2010, at 11:26 AM, Abhishek Pratap wrote:
>>
>> > Sure. Here is the full subroutine where I am opening the file handle and
>> > storing them
>> >
>> > Thanks for your help,
>> > -A
>> >
>> > sub createBins {
>> > my $SUB ='createBins';
>> > my $PWD = `pwd`;
>> > my $outpath = shift @_;
>> > my $lane = shift @_ ;
>> >
>> > 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");
>> > $bins{$bin}=$out;
>> > }
>> > }
>> >
>> >
>> > On Thu, Jun 24, 2010 at 12:22 PM, Warren W. Kretzschmar <
>> wkretzsch at gmail.com
>> >> wrote:
>> >
>> >> Where are you getting the filehandles from? That is, How are you
>> >> opening them? Can you show me the code?
>> >>
>> >> Warren
>> >>
>> >> On Thu, Jun 24, 2010 at 12:19 PM, Abhishek Pratap
>> >> <abhishek.vit at gmail.com> wrote:
>> >>> Dear Warren
>> >>> Thanks for your quick reply.  I am doing something very close to what
>> you
>> >>> have suggested but I see errors which might be due to some silly
>> mistake
>> >> I
>> >>> am making. The difference is instead of array I am using a hash to
>> help
>> >> me
>> >>> extract file names by key value later.
>> >>> I am writing data like this.
>> >>> my $file_handle = $bins{$bin_name};
>> >>> $file_handle->write_seq($data);
>> >>> Gives me an error
>> >>> Can't call method "write_seq" on an undefined value at
>> >>> /home/apratap/dev/eclipse_workspace/Illumina/demultiplex_GA_data.pl
>> line
>> >>> 139, <GEN12> line 5.
>> >>> -Abhi
>> >>> On Thu, Jun 24, 2010 at 11:24 AM, Warren W. Kretzschmar
>> >>> <wkretzsch at gmail.com> wrote:
>> >>>>
>> >>>> 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
>> >>>>>
>> >>>
>> >>>
>> >>
>> > _______________________________________________
>> > 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