[Bioperl-guts-l] [14460] bioperl-live/trunk/Bio/Search/HSP/GenericHSP.pm: bug 2436; add option for 'mismatch' (no match w/o gaps)

Christopher John Fields cjfields at dev.open-bio.org
Thu Jan 31 18:02:04 EST 2008


Revision: 14460
Author:   cjfields
Date:     2008-01-31 18:02:03 -0500 (Thu, 31 Jan 2008)

Log Message:
-----------
bug 2436; add option for 'mismatch' (no match w/o gaps)

Modified Paths:
--------------
    bioperl-live/trunk/Bio/Search/HSP/GenericHSP.pm

Modified: bioperl-live/trunk/Bio/Search/HSP/GenericHSP.pm
===================================================================
--- bioperl-live/trunk/Bio/Search/HSP/GenericHSP.pm	2008-01-30 19:54:38 UTC (rev 14459)
+++ bioperl-live/trunk/Bio/Search/HSP/GenericHSP.pm	2008-01-31 23:02:03 UTC (rev 14460)
@@ -727,10 +727,17 @@
            : May include ranges if collapse is true.
  Argument  : seq_type  = 'query' or 'hit' or 'sbjct'  (default = query)
            :  ('sbjct' is synonymous with 'hit')
-           : class     = 'identical' or 'conserved' or 'nomatch' or 'gap'
-           :              (default = identical)
-           :              (can be shortened to 'id' or 'cons')
-           :             or 'conserved-not-identical'
+           : class     = 'identical' - identical positions
+           :             'conserved' - conserved positions
+           :             'nomatch'   - mismatched residue or gap positions
+           :             'mismatch'  - mismatched residue positions (no gaps)
+           :             'gap'       - gap positions only
+           :             'conserved-not-identical' - conserved positions w/o 
+           :
+           :             The name can be shortened to 'id' or 'cons' unless
+           :             the name is ambiguous.  The default value is
+           :             'identical'
+           :
            : collapse  = boolean, if true, consecutive positions are merged
            :             using a range notation, e.g., "1 2 3 4 5 7 9 10 11"
            :             collapses to "1-5 7 9-11". This is useful for
@@ -775,6 +782,8 @@
        $class = 'identical';
    } elsif( $t eq 'n' ) {
        $class = 'nomatch';
+   } elsif( $t eq 'm' ) {
+       $class = 'mismatch';
    } elsif( $t eq 'g' ) {
        $class = 'gap';
    } else {
@@ -893,7 +902,6 @@
 sub significance {
     my $self = shift;
     my $signif = $self->query->significance(@_) if @_;
-    print STDERR $self->pvalue."\n" if $self->pvalue;
     if (!defined $signif) {
         $signif = $self->pvalue || $self->query->significance;
     }
@@ -965,7 +973,9 @@
     my %gapList_sbjct = ();
     my %nomatchList_query = ();
     my %nomatchList_sbjct = ();
-
+    my %mismatchList_query = ();
+    my %mismatchList_sbjct = ();
+    
     my $qdir = $self->query->strand || 1;
     my $sdir = $self->hit->strand || 1;
     my $resCount_query = ($qdir >=0) ? $self->query->end : $self->query->start;
@@ -1017,6 +1027,9 @@
 	} elsif( $mchar eq ' ') {
 	    $nomatchList_query{ $resCount_query } = 1;
 	    $nomatchList_sbjct{ $resCount_sbjct } = 1;
+        # mismatch; only count if the symbol matched to isn't a gap
+	    $mismatchList_query{ $resCount_query } = 1 if $schar ne $GAP_SYMBOL;
+	    $mismatchList_sbjct{ $resCount_sbjct } = 1 if $qchar ne $GAP_SYMBOL;
 	}
 	if( $qchar eq $GAP_SYMBOL ) {
 	    $gapList_query{ $resCount_query } ++;
@@ -1024,7 +1037,7 @@
 	    $resCount_query -= $qdir;
 	}
 	if( $schar eq $GAP_SYMBOL ) {
-	    $gapList_sbjct{ $resCount_query } ++;
+	    $gapList_sbjct{ $resCount_sbjct } ++;
 	} else {
 	    $resCount_sbjct -=$sdir;
 	}
@@ -1032,11 +1045,13 @@
     $self->{'_identicalRes_query'} = \%identicalList_query;
     $self->{'_conservedRes_query'} = \%conservedList_query;
     $self->{'_nomatchRes_query'}   = \%nomatchList_query;
+    $self->{'_mismatchRes_query'}  = \%mismatchList_query;
     $self->{'_gapRes_query'}       = \%gapList_query;
 
     $self->{'_identicalRes_sbjct'} = \%identicalList_sbjct;
     $self->{'_conservedRes_sbjct'} = \%conservedList_sbjct;
     $self->{'_nomatchRes_sbjct'}   = \%nomatchList_sbjct;
+    $self->{'_mismatchRes_sbjct'}  = \%mismatchList_sbjct;
     $self->{'_gapRes_sbjct'}       = \%gapList_sbjct;
     return 1;
 }




More information about the Bioperl-guts-l mailing list