GenOO
view release on metacpan or search on metacpan
lib/GenOO/Data/File/FASTA.pm view on Meta::CPAN
# POD documentation - main docs before the code
=head1 NAME
GenOO::Data::File::FASTA - Object implementing methods for accessing fasta formatted files (http://genome.ucsc.edu/FAQ/FAQformat#format1)
=head1 SYNOPSIS
# Object that manages a fasta file.
# To initialize
my $fasta_parser = GenOO::Data::File::FASTA->new(
file => undef,
);
=head1 DESCRIPTION
This object offers methods to read a fasta file line by line.
=head1 EXAMPLES
# Create object
my $fasta_parser = GenOO::Data::File::FASTA->new(
file => 't/sample_data/sample.fasta.gz'
);
# Read one record at a time
my $record = $fasta_parser->next_record;
# Get the number of records read
my $count = $fasta_parser->records_read_count;
=cut
# Let the code begin...
package GenOO::Data::File::FASTA;
$GenOO::Data::File::FASTA::VERSION = '1.5.2';
#######################################################################
####################### Load External modules #####################
#######################################################################
use Modern::Perl;
use autodie;
use Moose;
use namespace::autoclean;
#######################################################################
######################### Load GenOO modules ######################
#######################################################################
use GenOO::Data::File::FASTA::Record;
#######################################################################
####################### Interface attributes ######################
#######################################################################
has 'file' => (
isa => 'Maybe[Str]',
is => 'rw',
required => 1
);
has 'records_read_count' => (
is => 'rw',
default => 0,
init_arg => undef,
);
has '_filehandle' => (
is => 'ro',
builder => '_open_filehandle',
init_arg => undef,
lazy => 1,
);
has '_stored_record_header' => (
is => 'rw',
clearer => '_clear_stored_record_header',
predicate => '_has_stored_record_header',
init_arg => undef,
);
has '_stored_record_sequence_parts' => (
traits => ['Array'],
is => 'rw',
isa => 'ArrayRef[Str]',
default => sub { [] },
handles => {
_all_record_sequence_parts => 'elements',
_add_record_sequence_part => 'push',
_join_record_sequence_parts => 'join',
_clear_record_sequence_parts => 'clear',
},
);
has '_eof' => (
is => 'rw',
predicate => '_reached_eof',
init_arg => undef
);
( run in 0.996 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )