Bio-MUST-Core
view release on metacpan or search on metacpan
lib/Bio/MUST/Core/GeneticCode/Factory.pm view on Meta::CPAN
package Bio::MUST::Core::GeneticCode::Factory;
# ABSTRACT: Genetic code factory based on NCBI gc.prt file
$Bio::MUST::Core::GeneticCode::Factory::VERSION = '0.252040';
use Moose;
use namespace::autoclean;
# AUTOGENERATED CODE! DO NOT MODIFY THIS FILE!
use autodie;
use feature qw(say);
use Carp;
use Const::Fast;
use File::Spec;
use List::AllUtils qw(uniq);
use LWP::Simple qw(get);
use Path::Class qw(file);
use Try::Tiny;
use Bio::MUST::Core::Types;
use aliased 'Bio::MUST::Core::GeneticCode';
# public path to NCBI Taxonomy dump directory
has 'tax_dir' => (
is => 'ro',
isa => 'Bio::MUST::Core::Types::Dir',
coerce => 1,
);
# private hash hosting NCBI codes
has '_code_for' => (
traits => ['Hash'],
is => 'ro',
isa => 'HashRef[Bio::MUST::Core::GeneticCode]',
init_arg => undef,
lazy => 1,
builder => '_build_code_for',
handles => {
code_for => 'get',
list_codes => 'keys',
},
);
## no critic (ProhibitUnusedPrivateSubroutines)
sub _build_code_for {
my $self = shift;
# split file content into code blocks
my @codes = $self->_get_gcprt_content =~ m/ \{ ( [^{}]+ ) \} /xmsgc;
croak "[BMC] Error: cannot parse 'gc.prt' file; aborting!" unless @codes;
# Genetic-code-table ::= {
# ...
# {
# name "Mold Mitochondrial; Protozoan Mitochondrial; Coelenterate
# Mitochondrial; Mycoplasma; Spiroplasma" ,
# name "SGC3" ,
# id 4 ,
# ncbieaa "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
# sncbieaa "--MM---------------M------------MMMM---------------M------------"
# -- Base1 TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG
( run in 0.631 second using v1.01-cache-2.11-cpan-39bf76dae61 )