Florent Angly > Bio-Community-0.001000 > Bio::Community::Role::Table

Download:
Bio-Community-0.001000.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Source   Latest Release: Bio-Community-0.001007

NAME ^

Bio::Community::Role::Table - Role to read/write data tables and provide random access to their cells

SYNOPSIS ^

  package My::Package;

  use Moose;
  extends 'Bio::Root::IO';
  with 'Bio::Community::Role::Table';

  # Use the new(), _read_table(), _get_value(), _set_value(), _insert_line(),
  # _delete_col() and _write_table()
  # methods as needed
  # ...

  1;

DESCRIPTION ^

This role implements methods to read and write file structured as a table containing rows and columns. When reading a table from a file, an index is kept to provide random-access to any cell of the table. When writing a table to a file, cell data can also be given in any order. It is kept in memory until the file is written to disk.

Objects are constructed with the new() method. Since Table-consuming classes must inherit from Bio::Root::IO, all Bio::Root::IO options are accepted, e.g. -file, -fh, -string, -flush, etc. Other constructors are detailed in the APPENDIX.

AUTHOR ^

Florent Angly florent.angly@gmail.com

SUPPORT AND BUGS ^

User feedback is an integral part of the evolution of this and other Bioperl modules. Please direct usage questions or support issues to the mailing list, bioperl-l@bioperl.org, rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.

If you have found a bug, please report it on the BioPerl bug tracking system to help us keep track the bugs and their resolution: https://redmine.open-bio.org/projects/bioperl/

COPYRIGHT ^

Copyright 2011,2012,2013 by the BioPerl Team bioperl-l@bioperl.org

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.

APPENDIX ^

The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _

delim

 Usage   : my $delim = $in->delim;
 Function: When reading or writing a table, get or set the delimiter, i.e. the
           characters that delimit the columns of the table. The default is the
           tab character "\t".
 Args    : A string
 Returns : A string

start_line

 Usage   : my $line_num = $in->start_line;
 Function: When reading a table, get or set the line number at which the table
           starts. The default is 1, i.e. the table starts at the first line of
           the file. This option is not used when writing a table, but see
           _write_table() for details.
 Args    : A strictly positive number
 Returns : A strictly positive number

end_line

 Usage   : my $line_num = $in->end_line;
 Function: When reading a table, get or set the line number at which the table
           ends. If undef (the default), the table ends at the last line of the
           file.
 Args    : A strictly positive number or undef
 Returns : A strictly positive number or undef

missing_string

 Usage   : my $missing = $out->missing_string;
 Function: When reading a table, get or set the line number at which the table
           ends. If undef (the default), the table ends at the last line of the
           file.
 Args    : A string, e.g. '', '0', 'n/a', '-'
 Returns : A string

_get_start_content

 Usage   : my $txt = $in->_get_start_content;
 Function: After the table has been parsed, this returns everything before -start_line
 Args    : A strictly positive number
 Returns : A strictly positive number

_get_max_line

 Usage   : my $num_lines = $in->_get_max_line;
 Function: Get the number of lines in the table
 Args    : None
 Returns : Positive integer

_get_max_col

 Usage   : my $num_cols = $in->_get_max_col;
 Function: Get the number of columns in the table
 Args    : None
 Returns : Positive integer

_read_table

 Usage   : $in->_read_table;
 Function: Read the table in the file and index the position of its cells.
 Args    : None
 Returns : 1 on success

_get_value

 Usage   : my $value = $in->_get_value(1, 3);
 Function: Get the value of the cell given its position in the table (line and
           column).
 Args    : A strictly positive integer for the line
           A strictly positive integer for the column
 Returns : A string for the value of the table at the given line and column
             or
           undef if line or column was out-of-bounds

_set_value

 Usage   : $out->_set_value(1, 3, $value);
 Function: Set the element at the given line and column of the table.
 Args    : A strictly positive integer for the line
           A strictly positive integer for the column
           A string for the value of the table at the given line and column
 Returns : 1 for success

_insert_line

 Usage   : $out->_insert_line(3, ['sample1', 3, 10.9, 'Mus musculus']);
 Function: Insert a line of values in the table, at the indicated line, shifting
           all other lines down. You can also append a line to the table by
           providing the maximum line number + 1.
 Args    : A strictly positive integer for the line at which to insert
           An arrayref containing the values to insert (must match table width)
 Returns : 1 for success

_delete_col

 Usage   : $out->_delete_col(3);
 Function: Delete a column of the table.
 Args    : A strictly positive integer for the column to delete.
 Returns : 1 for success

_write_table

 Usage   : $out->_write_table;
 Function: Write the content of the cells in the table to a file. It is
           generally called automatically when closing the object. However, if
           you want header lines before or after the table, you can write them
           to file using the _print() method of Bio::Root::IO prior and after
           calling _write_table().
 Args    : None
 Returns : 1 on success
syntax highlighting: