Bio-ViennaNGS
view release on metacpan or search on metacpan
lib/Bio/ViennaNGS/AnnoC.pm view on Meta::CPAN
# -*-CPerl-*-
# Last changed Time-stamp: <2017-06-10 18:18:45 michl>
package Bio::ViennaNGS::AnnoC;
use Bio::ViennaNGS;
use Bio::ViennaNGS::Util qw(sortbed);
use Bio::Tools::GFF;
use Path::Class;
use Carp;
use Moose;
use namespace::autoclean;
use version; our $VERSION = version->declare(eval($Bio::ViennaNGS::VERSION));
has 'accession' => (
is => 'rw',
isa => 'Str',
predicate => 'has_accession',
);
has 'features' => (
is => 'ro',
isa => 'HashRef',
predicate => 'has_features',
default => sub { {} },
);
has 'nr_features' => (
is => 'ro',
isa => 'Int',
builder => '_get_nr_of_features',
lazy => 1,
);
has 'featstat' => (
is => 'ro',
isa => 'HashRef',
builder => '_set_featstat',
predicate => 'has_featstat',
lazy => 1,
);
before 'featstat' => sub {
my $self = shift;
$self->_get_nr_of_features();
};
sub _set_featstat {
my $self = shift;
my $this_function = (caller(0))[3];
my %fs = ();
confess "ERROR [$this_function] \$self->features not available"
unless ($self->has_features);
$fs{total} = 0;
$fs{origin} = "$this_function ".$VERSION;
$fs{count} = $self->nr_features;
foreach my $uid ( keys %{$self->features} ){
my $gbkey = ${$self->features}{$uid}->{gbkey};
$fs{total} += 1;
unless (exists $fs{$gbkey}){
$fs{$gbkey} = 0;
}
$fs{$gbkey} += 1;
}
return \%fs;
}
sub _get_nr_of_features {
my $self = shift;
my $this_function = (caller(0))[3];
confess "ERROR [$this_function] \$self->features not available"
unless ($self->has_features);
( run in 1.230 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )