-#!/usr/bin/env perl -w
+#!/usr/bin/env perl
# Copyright (C) 2007-2009 Martin A. Hansen.
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+use warnings;
use strict;
use Maasha::Biopieces;
use Maasha::Calc;
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-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 ) )
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 } ) )
{
$sums = "SUM ";
$means = "MEAN ";
-foreach $key ( keys %{ $analysis } )
+foreach $key ( sort keys %{ $analysis } )
{
$keys .= sprintf "% 15s", $key;
$types .= sprintf "% 15s", $analysis->{ $key }->{ "TYPE" };
$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 );
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
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();
}