X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fgrab;h=ae5b8315bfe8de8da27412d63edb7b90ece84ea6;hb=7527c4f0b2424dc10679912ce89ad92fca83974b;hp=1fecf4303acbedefaa94b1ca18be8896fbbc5fde;hpb=b607bb9d6e4adcebd9f9e128aacc91a212010ee0;p=biopieces.git diff --git a/bp_bin/grab b/bp_bin/grab index 1fecf43..ae5b831 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; @@ -120,6 +122,8 @@ while ( $record = Maasha::Biopieces::get_record( $in ) ) } } +Maasha::Biopieces::close_stream( $in ); +Maasha::Biopieces::close_stream( $out ); # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SUBROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -145,7 +149,7 @@ sub grab_lookup if ( $keys ) { - map { return 1 if exists $lookup_hash->{ $record->{ $_ } } } @{ $keys }; + map { return 1 if $record->{ $_ } and exists $lookup_hash->{ $record->{ $_ } } } @{ $keys }; } else { @@ -154,7 +158,7 @@ sub grab_lookup } if ( not $keys_only ) { - map { return 1 if exists $lookup_hash->{ $record->{ $_ } } } keys %{ $record }; + map { return 1 if $record->{ $_ } and exists $lookup_hash->{ $record->{ $_ } } } keys %{ $record }; } } @@ -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__ -