5 use Time::HiRes qw( gettimeofday );
6 use Getopt::Long qw( :config bundling );
10 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
13 my ( $script, $t0, $t1, %options, $in, $out, $record, @vals, $i );
15 $t0 = Time::HiRes::gettimeofday();
17 $script = ( split "/", $0 )[ -1 ];
19 Maasha::Biopieces::log_biopiece();
32 $options{ "keys" } = [ split ",", $options{ "keys" } ] if defined $options{ "keys" };
33 $options{ "delimit" } = '_' if not defined $options{ "delimit" };
35 $in = Maasha::Biopieces::read_stream( $options{ "stream_in" } );
36 $out = Maasha::Biopieces::write_stream( $options{ "stream_out" } );
38 while ( $record = Maasha::Biopieces::get_record( $in ) )
40 if ( exists $options{ 'key' } and exists $record->{ $options{ 'key' } } )
42 @vals = split /$options{ 'delimit' }/, $record->{ $options{ 'key' } };
44 for ( $i = 0; $i < @vals; $i++ )
46 if ( defined $options{ "keys" } and defined $options{ "keys" }->[ $i ] ) {
47 $record->{ $options{ "keys" }->[ $i ] } = $vals[ $i ];
49 $record->{ $options{ 'key' } . "_$i" } = $vals[ $i ];
54 Maasha::Biopieces::put_record( $record, $out );
57 $t1 = Time::HiRes::gettimeofday();
59 print STDERR "Program: $script" . ( " " x ( 25 - length( $script ) ) ) . sprintf( "Run time: %.4f\n", ( $t1 - $t0 ) ) if $options{ 'verbose' };
62 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<