X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fanalyze_vals;h=726c91c53c62f5c22560b77260f45d094340b018;hb=9ff3f4f82dedb5ccaa924fe311486bad3ed1248d;hp=91da15a1a0055e67bc451339e5436874d7c31932;hpb=9bf550c4335d8860c5f6f9c4db0f385f1b36c1dd;p=biopieces.git diff --git a/bp_bin/analyze_vals b/bp_bin/analyze_vals index 91da15a..726c91c 100755 --- a/bp_bin/analyze_vals +++ b/bp_bin/analyze_vals @@ -36,19 +36,25 @@ use Data::Dumper; # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -my ( $options, $in, $out, $record, $analysis, $key, $len, +my ( $options, $in, $out, $record, $analysis, $key, $len, %skip_hash, $data_out, %key_hash, $skip, $keys, $types, $counts, $mins, $maxs, $sums, $means ); $options = Maasha::Biopieces::parse_options( [ { long => 'no_stream', short => 'x', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef }, + { long => 'data_out', short => 'o', type => 'file', mandatory => 'no', default => undef, allowed => undef, disallowed => undef }, { long => 'keys', short => 'k', type => 'list', mandatory => 'no', default => undef, allowed => undef, disallowed => undef }, + { long => 'no_keys', short => 'K', type => 'list', mandatory => 'no', default => undef, allowed => undef, disallowed => undef }, ] ); $in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } ); $out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } ); +$data_out = Maasha::Biopieces::write_stream( $options->{ "data_out" }, $options->{ "compress" } ); +$data_out ||= \*STDOUT; + +map { $skip_hash{ $_ } = 1 } @{ $options->{ "no_keys" } }; map { $key_hash{ $_ } = 1; $skip = 1 } @{ $options->{ "keys" } }; while ( $record = Maasha::Biopieces::get_record( $in ) ) @@ -56,6 +62,7 @@ while ( $record = Maasha::Biopieces::get_record( $in ) ) foreach $key ( keys %{ $record } ) { next if $skip and not exists $key_hash{ $key }; + next if $skip_hash{ $key }; if ( Maasha::Calc::is_a_number( $record->{ $key } ) ) { @@ -108,7 +115,7 @@ $maxs = "MAX "; $sums = "SUM "; $means = "MEAN "; -foreach $key ( keys %{ $analysis } ) +foreach $key ( sort keys %{ $analysis } ) { $keys .= sprintf "% 15s", $key; $types .= sprintf "% 15s", $analysis->{ $key }->{ "TYPE" }; @@ -119,13 +126,15 @@ foreach $key ( keys %{ $analysis } ) $means .= sprintf "% 15s", $analysis->{ $key }->{ "MEAN" }; } -print "$keys\n"; -print "$types\n"; -print "$counts\n"; -print "$mins\n"; -print "$maxs\n"; -print "$sums\n"; -print "$means\n"; +print $data_out "$keys\n"; +print $data_out "$types\n"; +print $data_out "$counts\n"; +print $data_out "$mins\n"; +print $data_out "$maxs\n"; +print $data_out "$sums\n"; +print $data_out "$means\n"; + +close $data_out; Maasha::Biopieces::close_stream( $in ); Maasha::Biopieces::close_stream( $out );