}
-double solexa_str_mean_window( char *scores, int window_size, double min )
+void solexa_str_mean_window( char *scores, int window_size, double min )
{
/* Martin A. Hansen, June 2010. */
/* is lower than a given minimum otherwise the smallest mean */
/* score is returned. */
- int i = 0;
- double sum = 0;
- double mean = 0.0;
+ int found = 0;
+ int i = 0;
+ int pos = -1;
+ double sum = 0;
+ double mean = 0.0;
if ( window_size > strlen( scores ) )
{
mean = sum / window_size;
- if ( mean < min ) {
- return mean;
+ if ( mean <= min ) {
+ found = 1;
+ pos = 0;
}
/* --- scan the rest of the scores ---- */
- while ( i < strlen( scores ) )
+ while ( ! found && i < strlen( scores ) )
{
sum += solexa2dec( scores[ i ] );
sum -= solexa2dec( scores[ i - window_size ] );
// printf( "char->%c score->%d sum->%f mean->%f\n", scores[i], solexa2dec(scores[i]),sum, mean);
- if ( mean < min ) {
- return mean;
- }
-
i++;
+
+ if ( mean <= min ) {
+ found = 1;
+ pos = i - window_size;
+ }
}
- return mean;
+ Inline_Stack_Vars;
+ Inline_Stack_Reset;
+
+ Inline_Stack_Push( sv_2mortal( newSViv( mean ) ) );
+ Inline_Stack_Push( sv_2mortal( newSViv( pos ) ) );
+
+ Inline_Stack_Done;
}
# Returns a string.
+ $scores =~ s/(-\d{1,2})/0/g;
$scores =~ s/(\d{1,2});?/dec2solexa( $1 )/eg;
return $scores;