[Bioperl-l] new_fast methods

Chris Fields cjfields at illinois.edu
Thu Feb 26 16:01:34 UTC 2009


I'm okay with that; it would be a global optimization.

Other points of optimization: cache/clone of objects representing the  
same 'string' (i.e. Locations).  That could be done in  
Bio::Factory::FTLocationFactory.  I tested this out once and had a  
decent enough speedup, particularly with large sequences, but never  
got around to discussing in on list.

chris

On Feb 26, 2009, at 3:28 AM, Albert Vilella wrote:

> Hi,
>
> I would like to ask for comments to the list on the convenience of
> having "new_fast" methods in Bioperl.
> If one does some profiling on Bioperl scripts that parse large
> quantities of data, the "_rearrange" method stands out as a possible
> easy point of optimization. There are parts of the code that call the
> new method with explicit options. See for example:
>
> We should be able to create a "new_fast" method for this cases that
> takes the ordering as given and doesn't call "_rearrange". This
> wouldn't disrupt existing code that still calls "new".
>
> Comments?
>
> Bio/Seq/SeqWithQuality.pm
>
>   if (!$seq) {
>      my $id;
>      unless ($self->{supress_warnings} == 1) {
>         $self->warn("You did not provide sequence information during  
> the ".
>           "construction of a Bio::Seq::SeqWithQuality object.  
> Sequence ".
>           "components for this object will be empty.");
>      }
>      if (!$alphabet) {
>         $self->throw("If you want me to create a PrimarySeq object  
> for your ".
>           "empty sequence <boggle> you must specify a -alphabet to  
> satisfy ".
>           "the constructor requirements for a Bio::PrimarySeq object  
> with no ".
>           "sequence. Read the POD for it, luke.");
>      }
>      $self->{seq_ref} = Bio::PrimarySeq->new( -seq              =>   
> "",
>                                               -accession_number =>   
> $acc,
>                                               -primary_id       =>   
> $pid,
>                                               -desc             =>   
> $desc,
>                                               -display_id       =>   
> $id,
>                                               -alphabet         =>
> $alphabet );
>   } elsif ($seq->isa('Bio::PrimarySeqI') || $seq->isa('Bio::SeqI')) {
>      $self->{seq_ref} = $seq;
>   } elsif (ref($seq)) {
>      $self->throw("You passed a seq argument into a SeqWithQUality  
> object and".
>        " it was a reference ($seq) which did not inherit from  
> Bio::SeqI or ".
>        "Bio::PrimarySeqI. I don't know what to do with this!");
>   } else {
>      my $seqobj = Bio::PrimarySeq->new( -seq              => $seq,
>                                         -accession_number => $acc,
>                                         -primary_id       => $pid,
>                                         -desc             => $desc,
>                                         -display_id       => $id   );
>      $self->{seq_ref} = $seqobj;
>   }
>   # Then import the quality scores
>   if (!defined($qual)) {
>      $self->{qual_ref} = Bio::Seq::PrimaryQual->new( - 
> qual             => "",
>                                                      - 
> accession_number => $acc,
>                                                      - 
> primary_id       => $pid,
>                                                      -desc
> => $desc,
>                                                      -display_id
> => $id, );
>   } elsif (ref($qual) eq "Bio::Seq::PrimaryQual") {
>      $self->{qual_ref} = $qual;
>   } else {
>      my $qualobj = Bio::Seq::PrimaryQual->new( -qual             =>  
> $qual,
>                                                -accession_number =>  
> $acc,
>                                                -primary_id       =>  
> $pid,
>                                                -desc             =>  
> $desc,
>                                                -display_id       =>  
> $id,
>                                                -trace_indices    =>
> $trace_indices );
>      $self->{qual_ref} = $qualobj;
>   }
> _______________________________________________
> 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