X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fgrab;h=85063dec0234c82d30e481b15948fd55fc47ef37;hb=f47f8b7621db2e9ee98c78ca0e4f7313535052c7;hp=6d2aabff4f5d55c4014202302565d3dc404c0f47;hpb=9854397f83abe8d5a8c614b799ef3107d3f85f80;p=biopieces.git diff --git a/bp_bin/grab b/bp_bin/grab index 6d2aabf..85063de 100755 --- a/bp_bin/grab +++ b/bp_bin/grab @@ -1,4 +1,4 @@ -#!/usr/bin/env perl -w +#!/usr/bin/env perl # Copyright (C) 2007-2009 Martin A. Hansen. @@ -26,7 +26,9 @@ # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +use warnings; use strict; +use Data::Dumper; use Maasha::Biopieces; use Maasha::Common; use Maasha::Patscan; @@ -35,7 +37,7 @@ use Maasha::Patscan; # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, $keys, $vals_only, $keys_only, $invert, +my ( $options, $in, $out, $record, $keys, $vals_only, $keys_only, $invert, $patterns, $regex, %lookup_hash, $key, $op, $val, $found ); $options = Maasha::Biopieces::parse_options( @@ -120,6 +122,8 @@ while ( $record = Maasha::Biopieces::get_record( $in ) ) } } +Maasha::Biopieces::close_stream( $in ); +Maasha::Biopieces::close_stream( $out ); # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SUBROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -178,13 +182,17 @@ sub grab_patterns # Returns boolean. - my ( $pattern ); + my ( $pattern, $key ); foreach $pattern ( @{ $patterns } ) { if ( $keys ) { - map { return 1 if index( $record->{ $_ }, $pattern ) >= 0 } @{ $keys }; + foreach $key ( @{ $keys } ) + { + return 0 if not exists $record->{ $key }; + return 1 if index( $record->{ $key }, $pattern ) >= 0; + } } else { @@ -220,7 +228,7 @@ sub grab_regex if ( $keys ) { - map { return 1 if $record->{ $_ } =~ /$regex/ } @{ $keys }; + map { return 1 if exists $record->{ $_ } and $record->{ $_ } =~ /$regex/ } @{ $keys }; } else { @@ -274,20 +282,13 @@ sub grab_eval BEGIN { - $run_time_beg = Maasha::Biopieces::run_time(); - - Maasha::Biopieces::log_biopiece(); + Maasha::Biopieces::status_set(); } END { - Maasha::Biopieces::close_stream( $in ); - Maasha::Biopieces::close_stream( $out ); - - $run_time_end = Maasha::Biopieces::run_time(); - - Maasha::Biopieces::run_time_print( $run_time_beg, $run_time_end, $options ); + Maasha::Biopieces::status_log(); } @@ -295,4 +296,3 @@ END __END__ -