]> git.donarmstrong.com Git - biopieces.git/commitdiff
AlignTwoSeq.pm briefly revisited
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 28 Sep 2010 13:12:35 +0000 (13:12 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 28 Sep 2010 13:12:35 +0000 (13:12 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1104 74ccb610-7750-0410-82ae-013aeee3265d

code_perl/Maasha/AlignTwoSeq.pm

index 50d75c79206df9dbb23d9af81b8c383921e2beac..cebd6edca2b8b94d0bb8d4a520b85b8ae606dd23 100644 (file)
@@ -37,6 +37,14 @@ use vars qw ( @ISA @EXPORT );
 
 @ISA = qw( Exporter );
 
+use constant {
+    SCORE_FACTOR_LEN    => 3,
+    SCORE_FACTOR_CORNER => 2,
+    SCORE_FACTOR_DIAG   => 1,
+    SCORE_FACTOR_NARROW => 0.5,
+    VERBOSE             => 0,
+};
+
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
@@ -48,10 +56,10 @@ sub align_two_seq
     # Generates an alignment by chaining matches, which are subsequences
     # shared between two sequences. The routine functions by considering 
     # only matches within a given search space. If no matches are given
-    # these will be generated, if long matches are found these will be
-    # included in the alignment, otherwise matches will be included depending
-    # on a calculated score. New search spaces spanning the spaces between
-    # matches and the search space boundaries will be cast and recursed into.
+    # these will be located and matches will be included depending on a
+    # calculated score. New search spaces spanning the spaces between
+    # matches and the search space boundaries will be cast and recursed
+    # into.
     
     # Usage: align_two_seq( { Q_SEQ => \$q_seq, S_SEQ => \$s_seq }, [] );
 
@@ -417,7 +425,7 @@ sub match_redundant
 {
     # Martin A. Hansen, August 2009
     
-    my ( $new_match,       # match
+    my ( $new_match,   # match
          $redundant,   # hashref
        ) = @_;
 
@@ -512,12 +520,11 @@ sub match_score
     $score_len    = match_score_len( $match );
     $score_corner = match_score_corner( $match, $space );
     $score_diag   = match_score_diag( $match, $space );
-    $score_narrow = 0; #match_score_narrow( $match, $space );
+    $score_narrow = match_score_narrow( $match, $space );
 
     $score_total  = $score_len - $score_corner - $score_diag - $score_narrow;
 
-    # print STDERR "LEN: $score_len   CORNER: $score_corner   DIAG: $score_diag   NARROW: $score_narrow: TOTAL: $score_total\n" if $score_total > 0;
-    print STDERR "LEN: $score_len   CORNER: $score_corner   DIAG: $score_diag   NARROW: $score_narrow: TOTAL: $score_total\n";
+    printf STDERR "LEN: %d   CORNER: %d   DIAG: %d   NARROW: %d   TOTAL: %d\n", $score_len, $score_corner, $score_diag, $score_narrow, $score_total if VERBOSE;
 
     $match->{ 'SCORE' } = $score_total;
 }
@@ -534,7 +541,7 @@ sub match_score_len
 
     # Returns integer.
 
-    return $match->{ 'LEN' } * 2;
+    return $match->{ 'LEN' } * SCORE_FACTOR_LEN;
 }
 
 
@@ -557,7 +564,7 @@ sub match_score_corner
 
     $score_corner = Maasha::Calc::min( $left_dist, $right_dist );
 
-    return int $score_corner * 1.5;
+    return $score_corner * SCORE_FACTOR_CORNER;
 }
 
 
@@ -615,7 +622,7 @@ sub match_score_diag
 
     $score_diag = $min_diag_dist;
 
-    return int $score_diag;
+    return $score_diag * SCORE_FACTOR_DIAG;
 }
 
 
@@ -655,9 +662,7 @@ sub match_score_narrow
 
     $score_narrow = $max_narrow_dist;
 
-    return abs( $beg_narrow_dist - $end_narrow_dist );
-
-    return $score_narrow;
+    return $score_narrow * SCORE_FACTOR_NARROW;
 }
 
 
@@ -769,6 +774,7 @@ sub insert_indels
     }
 }
 
+1;
 
 __END__