Bio::Align PairwiseStatistics
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::Align::PairwiseStatistics - Base statistic object for Pairwise Alignments
Package variables
No package variables defined.
Inherit
Bio::Align::StatisticsI Bio::Root::Root
Synopsis
  use strict;
my $stats = Bio::Align::DNAStatistics->new();
# get alignment object of two sequences somehow my $pwaln; print $stats->number_of_comparable_bases($pwaln);
Description
Calculate pairwise statistics.
Methods
BEGIN Code
number_of_comparable_basesDescriptionCode
number_of_differencesDescriptionCode
number_of_gapsDescriptionCode
Methods description
number_of_comparable_basescode    nextTop
 Title   : number_of_comparable_bases
Usage : my $bases = $stat->number_of_comparable_bases($aln);
Function: Returns the count of the number of bases that can be
compared (L) in this alignment ( length - gaps)
Returns : integer
Args : Bio::Align::AlignI
number_of_differencescodeprevnextTop
 Title   : number_of_differences
Usage : my $nd = $stat->number_of_distances($aln);
Function: Returns the number of differences between two sequences
Returns : integer
Args : Bio::Align::AlignI
number_of_gapscodeprevnextTop
 Title   : number_of_gaps
Usage : my $nd = $stat->number_of_gaps($aln);
Function: Returns the number of gapped positions among sequences in alignment
Returns : integer
Args : Bio::Align::AlignI
Methods code
BEGINTop
BEGIN {
 $GapChars = '(\.|\-)';
}
number_of_comparable_basesdescriptionprevnextTop
sub number_of_comparable_bases {
   my ($self,$aln) = @_;
   if( ! defined $aln || ! $aln->isa('Bio::Align::AlignI') ) {
       $self->warn("Must provide a Bio::Align::AlignI compliant object to Bio::Align::PairwiseStatistics");
       return 0;
   } elsif( $aln->no_sequences != 2 ) { 
       $self->warn("only pairwise calculations currently supported ". $aln->no_sequences."\n");
   }
   my $L = $aln->length - $self->number_of_gaps($aln);
   return $L;
}
number_of_differencesdescriptionprevnextTop
sub number_of_differences {
   my ($self,$aln) = @_;
    if( ! defined $aln || ! $aln->isa('Bio::Align::AlignI') ) {
	$self->warn("Must provide a Bio::Align::AlignI compliant object to Bio::Align::PairwiseStatistics");
	return 0;
    } elsif( $aln->no_sequences != 2 ) { 
	$self->warn("only pairwise calculations currently supported");
    }
   my (@seqs);
   foreach my $seq ( $aln->each_seq) {
       push @seqs, [ split(//,$seq->seq())];
   }
   my $firstseq = shift @seqs;
#    my $secondseq = shift @seqs;
my $diffcount = 0; for (my $i = 0;$i<$aln->length; $i++ ) { next if( $firstseq->[$i] =~ /^$GapChars$/); foreach my $seq ( @seqs ) { next if( $seq->[$i] =~ /^$GapChars$/); if( $firstseq->[$i] ne $seq->[$i] ) { $diffcount++; } } } return $diffcount;
}
number_of_gapsdescriptionprevnextTop
sub number_of_gaps {
   my ($self,$aln) = @_;
    if( ! defined $aln || ! $aln->isa('Bio::Align::AlignI') ) {
	$self->warn("Must provide a Bio::Align::AlignI compliant object to Bio::Align::PairwiseStatistics");
	return 0;
    }
   my $gapline = $aln->gap_line;
   # this will count the number of '-' characters
return $gapline =~ tr/-/-/;
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
  bioperl-l@bioperl.org                  - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via the
web:
  http://bugzilla.open-bio.org/
AUTHOR - Jason StajichTop
Email jason-at-bioperl-dot-org
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _