{ long => 'convert2dec', short => 'c', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
{ long => 'cutoff', short => 'C', type => 'int', mandatory => 'no', default => 20, allowed => undef, disallowed => undef },
{ long => 'soft_mask', short => 's', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'mean', short => 'm', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
]
);
check_names( $fasta, $qual );
$record = {
- SEQ_NAME => $fasta->[ 0 ],
- SEQ => $fasta->[ 1 ],
- SCORES => $qual->[ 1 ],
+ SEQ_NAME => $fasta->[ 0 ],
+ SEQ => $fasta->[ 1 ],
+ SCORES => $qual->[ 1 ],
};
+
+ $record->{ 'SCORES_MEAN' } = sprintf "%.2f", Maasha::Fastq::solexa_str_mean( $qual->[ 1 ] ) if $options->{ 'mean' };
Maasha::Fastq::softmask_solexa_str( $record->{ 'SEQ' }, $record->{ 'SCORES' }, $options->{ 'cutoff' } ) if $options->{ 'soft_mask' };
$record->{ 'SCORES' } = Maasha::Fastq::solexa_str2dec_str( $record->{ 'SCORES' } ) if $options->{ 'convert2dec' };
}
+double solexa_str_mean( char *scores )
+{
+ /* Martin A. Hansen, November 2009 */
+
+ /* Calculates the mean score as a float which is retuned. */
+
+ int len = 0;
+ int i = 0;
+ int sum = 0;
+ double mean = 0.0;
+
+ len = strlen( scores );
+
+ for ( i = 0; i < len; i++ ) {
+ sum += solexa2dec( scores[ i ] );
+ }
+
+ mean = ( double ) sum / ( double ) len;
+
+ return mean;
+}
+
+
void softmask_solexa_str( char *seq, char *scores, int threshold )
{
/* Martin A. Hansen, July 2009 */