| 1 | # POD documentation - main docs before the code | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | GenOO::Data::File::FASTA::Record - Object representing a record of a fasta file | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | # Object representing a record of a fasta file | ||||||||||
| 10 | |||||||||||
| 11 | # To initialize | ||||||||||
| 12 | my $record = GenOO::Data::File::FASTA::Record->new({ | ||||||||||
| 13 | HEADER => undef, | ||||||||||
| 14 | SEQUENCE => undef, | ||||||||||
| 15 | }); | ||||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||
| 19 | |||||||||||
| 20 | This object represents a record of a fasta file and offers methods for accessing the different attributes. | ||||||||||
| 21 | |||||||||||
| 22 | =head1 EXAMPLES | ||||||||||
| 23 | |||||||||||
| 24 | my $sequence = $record->sequence(); | ||||||||||
| 25 | |||||||||||
| 26 | =cut | ||||||||||
| 27 | |||||||||||
| 28 | # Let the code begin... | ||||||||||
| 29 | |||||||||||
| 30 | package GenOO::Data::File::FASTA::Record; | ||||||||||
| 31 | 1 | $GenOO::Data::File::FASTA::Record::VERSION = '1.5.0'; | |||||||||
| 32 | |||||||||||
| 33 | ####################################################################### | ||||||||||
| 34 | ####################### Load External modules ##################### | ||||||||||
| 35 | ####################################################################### | ||||||||||
| 36 | 1 | ▶ | use Modern::Perl; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 37 | 1 | ▶ | use autodie; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | ####################################################################### | ||||||||||
| 43 | ####################### Interface attributes ###################### | ||||||||||
| 44 | ####################################################################### | ||||||||||
| 45 | 1 | has 'header' => ( | |||||||||
| 46 | isa => 'Str', | ||||||||||
| 47 | is => 'ro', | ||||||||||
| 48 | required => 1 | ||||||||||
| 49 | ); | ||||||||||
| 50 | |||||||||||
| 51 | 1 | has 'sequence' => ( | |||||||||
| 52 | isa => 'Str', | ||||||||||
| 53 | is => 'ro', | ||||||||||
| 54 | required => 1 | ||||||||||
| 55 | ); | ||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | ####################################################################### | ||||||||||
| 59 | ############################## BUILD ############################## | ||||||||||
| 60 | ####################################################################### | ||||||||||
| 61 | around BUILDARGS => sub { | ||||||||||
| 62 | 32 | ▶ | my ($orig, $class) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||
| 63 | |||||||||||
| 64 | 32 | my $argv_hash_ref = $class->$orig(@_); | |||||||||
| 65 | |||||||||||
| 66 | 32 | ▶ | if (exists $argv_hash_ref->{header}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 32 | my $header = $argv_hash_ref->{header}; | |||||||||
| 68 | 32 | $header =~ s/^>//; | |||||||||
| 69 | 32 | $argv_hash_ref->{header} = $header | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 32 | return $argv_hash_ref; | |||||||||
| 73 | 1 | }; | |||||||||
| 74 | |||||||||||
| 75 | |||||||||||
| 76 | ####################################################################### | ||||||||||
| 77 | ######################## Interface Methods ######################## | ||||||||||
| 78 | ####################################################################### | ||||||||||
| 79 | sub length { | ||||||||||
| 80 | 2 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
length: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 81 | 2 | return length($self->sequence); | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | sub to_string { | ||||||||||
| 85 | 2 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
to_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 86 | |||||||||||
| 87 | 2 | return join("\n",( | |||||||||
| 88 | '>'.$self->header, | ||||||||||
| 89 | $self->sequence, | ||||||||||
| 90 | )); | ||||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | ####################################################################### | ||||||||||
| 94 | ############################ Finalize ############################# | ||||||||||
| 95 | ####################################################################### | ||||||||||
| 96 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 97 | |||||||||||
| 98 | 1 | 1; | |||||||||