Bio::Gonzales::Matrix::IO - Library for simple matrix IO
use Bio::Gonzales::Matrix::IO qw(lspew mslurp lslurp mspew);
Provides functions for common matrix/list IO.
%options = ( sep => qr/\t/, header => 0, skip => -1, comment => qr/^#/, key_idx => 0, val_idx => undef, uniq => 0, record_filter => undef, concat_keys => 1, );
Setups:
Concatenate the keys by $;. If set to 0, key columns are taken in a serial fashion and are merged to one big column.
$;
If key_idx is an array, the keys columns are joined by $; to build the hash key.
Save the values in @matrix to a $filename or $filehandle. @matrix is an array of arrayrefs:
@matrix
$filename
$filehandle
@matrix = ( [ l11, l12, l13 ], [ l21, l22, l23 ], [ l31, l32, l33 ] );
Options:
Supply a header. Same as
mspew($file, [ \@header, @matrix ])
Supply row names or if not an array but true, use the header as row names
mspew( $file, $matrix, { row_names => 1 } ); #use header mspew( $file, $matrix, { row_names => [ 'row1', '...', 'rown' ] } ); #use supplied row names
If a row has less columns than the longest row of the matrix, fill it up with empty strings.
Use this value in case undefined values are found. Default is 'NA'.
Set a separator for the output file
Add empty columns to fill up to a square.
Reads in the contents of $file and puts it in a array of arrayrefs.
$file
You can set the delimiter via the configuration by supplying { sep => qr/\t/ } as config hash.
{ sep => qr/\t/ }
Further options with defaults:
%config = ( sep => qr/\t/, # set column separator header => 0, # parse header skip => 0, # skip the first N lines (without header) row_names => 0, # parse row names comment => qr/^#/ # the comment character record_filter => undef # set a function to filter records );
spews out a list of values to a file. It can handle filenames and filehandles, but if you supply a handle, you have to close it on your own. The $list can be a
$list
results in keya avalue0 avalue1 keyb bvalue0 bvalue1 ...
results in keya valuea keyb valueb ...
results in value0 value1 ...
$config_options is a hash ref. It can take the options:
$config_options
$config_options = { delim => "\t", };
jw bargsten, <joachim.bargsten at wur.nl>
<joachim.bargsten at wur.nl>
To install Bio::Gonzales, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bio::Gonzales
CPAN shell
perl -MCPAN -e shell install Bio::Gonzales
For more information on module installation, please visit the detailed CPAN module installation guide.