[Bioperl-l] Rounding off to 100% in Tools::Blast::Sbjct::frac_identical()
Steve Chervitz
sac@bioperl.org
Sun, 31 Mar 2002 20:59:34 -0800 (PST)
Ben,
There's no compelling reason that I can think of as to why the frac_identical
and frac_conserved methods round to two significant figures. The only reason it
is there is to avoid excessive sig figs (e.g., 0.92014402179). Since this is
throwing out information, as you point out, this should be changed.
As for your recommended fix, I would prefer simply changing the sprintf line to
"0.3f", which will allow you to distinguish between 0.996, 0.998, and 1.000.
Steve
--- Benjamin Berman <benb@fruitfly.org> wrote:
>
> 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
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
=====
Steve Chervitz
sac@bioperl.org
__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - send holiday greetings for Easter, Passover
http://greetings.yahoo.com/