--- PickFeatureSet.pm 2009/03/27 18:32:48 1.1 +++ PickFeatureSet.pm 2009/03/27 23:45:01 1.2 @@ -133,16 +133,46 @@ } -# Calculate score for following +# Calculate spacer score + sub spacer_score { my ( \$fr1, \$r1, \$fr2, \$l2, \$max_sp_scr, \$max_overlap, \$sp_decay ) = @_; - my \$ideal = \$fr1 > 0 ? ( \$fr2 > 0 ? 5 : 100 ) # same : converge - : ( \$fr2 > 0 ? 100 : 5 ); # diverge : same - my \$x = \$r1 - \$l2 + 1 + \$ideal; # amount less than ideal space - \$max_sp_scr * ( ( \$x >= 0 ) ? 1 - \$x / ( \$max_overlap + \$ideal ) - : exp( \$x / \$sp_decay ) - ); + + my \$space = ( \$l2 - \$r1 ) - 1; + my ( \$min_opt, \$max_opt ); # Range of optimal gene spacings + + # Convergent + if ( \$fr1 > 0 && \$fr2 < 0 ) + { + \$min_opt = 20; + \$max_opt = 120; + } + # Divergent + elsif ( \$fr1 < 0 && \$fr2 > 0 ) + { + \$min_opt = 50; + \$max_opt = 150; + } + # Same direction + else + { + \$min_opt = -4; + \$max_opt = 150; + } + + if ( \$space < \$min_opt ) + { + return \$max_sp_scr * ( 1 - ( \$min_opt - \$space ) / \$max_overlap ); + } + elsif ( \$space > \$max_opt ) + { + return \$max_sp_scr * exp( ( \$max_opt - \$space ) / \$sp_decay ); + } + else + { + return \$max_sp_scr; + } } 1;