From: martinahansen Date: Thu, 16 May 2013 08:56:09 +0000 (+0000) Subject: added verbose count to grab X-Git-Url: https://git.donarmstrong.com/?p=biopieces.git;a=commitdiff_plain;h=ee4dcfda2d24e00335b5c80a3b52bf27839267a1 added verbose count to grab git-svn-id: http://biopieces.googlecode.com/svn/trunk@2170 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_bin/grab b/bp_bin/grab index 8533a4e..76e333a 100755 --- a/bp_bin/grab +++ b/bp_bin/grab @@ -38,7 +38,7 @@ use Maasha::Patscan; my ( $options, $in, $out, $record, $keys, $vals_only, $keys_only, $invert, - $patterns, $regex, %lookup_hash, $key, $op, $val, $found ); + $patterns, $regex, %lookup_hash, $key, $op, $val, $found, $total, $grabbed ); $options = Maasha::Biopieces::parse_options( [ @@ -101,6 +101,9 @@ elsif ( $options->{ 'eval' } ) } } +$total = 0; +$grabbed = 0; + while ( $record = Maasha::Biopieces::get_record( $in ) ) { $found = 0; @@ -115,16 +118,29 @@ while ( $record = Maasha::Biopieces::get_record( $in ) ) $found = grab_eval( $key, $op, $val, $record ); } - if ( $found and not $invert ) { + if ( $found and not $invert ) + { Maasha::Biopieces::put_record( $record, $out ); - } elsif ( not $found and $invert ) { + $grabbed += 1; + } + elsif ( not $found and $invert ) + { Maasha::Biopieces::put_record( $record, $out ); + $grabbed += 1; } + + $total += 1; } Maasha::Biopieces::close_stream( $in ); Maasha::Biopieces::close_stream( $out ); +if ( $options->{ 'verbose' } ) +{ + print STDERR "Records grabbed: $grabbed\n"; + print STDERR "Records missed: " . ( $total - $grabbed ) . "\n"; +} + # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SUBROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<