[Bioperl-l] Rounding off to 100% in Tools::Blast::Sbjct::frac_identical()

Benjamin Berman benb@fruitfly.org
Wed, 27 Mar 2002 18:27:36 -0800


Hi Steve,

I have a question about how you calculate the frac_identical and 
frac_conserved in Tools::Blast::Sbjct and other related classes.  If I have 
an alignment where 281 out of 282 residues are identical (99.6%), the 
frac_identical and frac_conserved functions round up to 100%.  I believe 
that BLAST itself (at least WU-BLAST) never rounds off to 100%.  For me, 
this is the preferred behavior (i.e. it's not 100% unless it's really 
-perfect-).  Did you have a specific reason for choosing the behavior that 
you did?

I am using the following logic.  How would you (and others) feel about me 
checking in this change?

>#------------------
>sub frac_identical {
>#------------------
>     my ($self, $seqType) = @_;
>     $seqType ||= 'total';
>
>     ## Sensitive to member name format.
>     $seqType = lc($seqType);
>
>     $self->_tile_hsps() if not $self->{'_tile_hsps'};
>
>     my $ident = $self->{'_totalIdentical'};
>     my $total = $self->{'_length_aln_'.$seqType};
>     my $ratio = $ident / $total;
>     my $ratio_rounded = sprintf( "%.2f", $ratio);
>
>     # Round down iff normal rounding yields 1 (just like blast)
>     $ratio_rounded = 0.99 if (($ratio_rounded == 1) && ($ratio != 1));
>
>     return $ratio_rounded;
>}

Thanks for the help,
ben.


------
Benjamin Berman
Rubin Lab, 539 Life Sciences Addition
Department of Molecular and Cell Biology
University of California, Berkeley
benb@fruitfly.org