]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/analyze_gc
adding bzip2 support in ruby
[biopieces.git] / bp_bin / analyze_gc
index 491112459f7f8829f45edd0cbc7f4ebdc6bcd6f2..8c0790f80db27e32dfc1df7095142f5e56682cbd 100755 (executable)
@@ -36,7 +36,7 @@ use Maasha::Biopieces;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $options, $in, $out, $record, $gc );
+my ( $options, $in, $out, $record, $gc_count, $gc_percent );
 
 $options = Maasha::Biopieces::parse_options();
 
@@ -45,7 +45,13 @@ $out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
 
 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 );
 }