Bio-Community

 view release on metacpan or  search on metacpan

lib/Bio/Community/Role/Table.pm  view on Meta::CPAN

  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;

=head1 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
L<APPENDIX>.

=head1 AUTHOR

Florent Angly L<florent.angly@gmail.com>

=head1 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, 
L<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:
L<https://redmine.open-bio.org/projects/bioperl/>

=head1 COPYRIGHT

Copyright 2011-2014 by Florent Angly <florent.angly@gmail.com>

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.

=head1 APPENDIX

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

=cut


package Bio::Community::Role::Table;

use Moose::Role;
use Method::Signatures;
use namespace::autoclean;
use Fcntl;


# Consuming class has to inherit from Bio::Root::IO
requires '_fh',
         '_readline',
         '_print';


=head2 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

=cut

has 'delim' => (
   is => 'rw',
   isa => 'Str',
   required => 0,
   init_arg => '-delim',
   lazy => 1,
   default => "\t",
);


# New lines can be: \n, \r\n, ... Record number of newline chars here
has '_num_eol_chars' => (
   is => 'rw',
   #isa => 'PositiveInt',
   required => 0,
   lazy => 1,
   default => 0,
);


=head2 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

=cut

has 'start_line' => (
   is => 'ro',
   isa => 'StrictlyPositiveInt',
   required => 0,
   init_arg => '-start_line',
   lazy => 1,
   default => 1,
);



( run in 0.511 second using v1.01-cache-2.11-cpan-39bf76dae61 )