# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-my ( $options, $in, $out, $record, $gc );
+my ( $options, $in, $out, $record, $gc_count, $gc_percent );
$options = Maasha::Biopieces::parse_options();
while ( $record = Maasha::Biopieces::get_record( $in ) )
{
- $record->{ 'GC%' } = sprintf( "%.2f", ( $record->{ "SEQ" } =~ tr/GgCc// / length $record->{ "SEQ" } ) * 100 ) if $record->{ "SEQ" };
+ if ( $record->{ "SEQ" } )
+ {
+ $gc_count = $record->{ "SEQ" } =~ tr/GgCc//;
+ $gc_percent = ( $gc_count / length $record->{ "SEQ" } ) * 100;
+ $record->{ 'GC%' } = sprintf( "%.2f", $gc_percent );
+# $record->{ 'GC%' } = int $gc_percent;
+ }
Maasha::Biopieces::put_record( $record, $out );
}