From f6351b381ad5d3bff282ab724a3432f0a642b792 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Tue, 28 Sep 2010 13:12:35 +0000 Subject: [PATCH] AlignTwoSeq.pm briefly revisited git-svn-id: http://biopieces.googlecode.com/svn/trunk@1104 74ccb610-7750-0410-82ae-013aeee3265d --- code_perl/Maasha/AlignTwoSeq.pm | 34 +++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/code_perl/Maasha/AlignTwoSeq.pm b/code_perl/Maasha/AlignTwoSeq.pm index 50d75c7..cebd6ed 100644 --- a/code_perl/Maasha/AlignTwoSeq.pm +++ b/code_perl/Maasha/AlignTwoSeq.pm @@ -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__ -- 2.39.2