| 1 | package Bio::MUST::Apps::Roles::Configable; | ||||||||||||
| 2 | # ABSTRACT: Attributes and methods common to Leel and FortyTwo objects | ||||||||||||
| 3 | 1 | $Bio::MUST::Apps::Roles::Configable::VERSION = '0.262780'; | |||||||||||
| 4 | 1 | ▶ | use Moose::Role; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 1 | ▶ | use autodie; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use feature qw(say); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 1 | ▶ | use Smart::Comments -ENV; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 1 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | |||||||||||||
| 13 | |||||||||||||
| 14 | 1 | has 'config' => ( | |||||||||||
| 15 | traits => ['Hash'], | ||||||||||||
| 16 | is => 'ro', | ||||||||||||
| 17 | isa => 'HashRef', | ||||||||||||
| 18 | required => 1, | ||||||||||||
| 19 | handles => { | ||||||||||||
| 20 | args_for => 'get', | ||||||||||||
| 21 | }, | ||||||||||||
| 22 | ); | ||||||||||||
| 23 | |||||||||||||
| 24 | |||||||||||||
| 25 | 1 | has 'infiles' => ( | |||||||||||
| 26 | traits => ['Array'], | ||||||||||||
| 27 | is => 'ro', | ||||||||||||
| 28 | isa => 'ArrayRef[Str]', | ||||||||||||
| 29 | required => 1, | ||||||||||||
| 30 | handles => { | ||||||||||||
| 31 | all_infiles => 'elements', | ||||||||||||
| 32 | }, | ||||||||||||
| 33 | ); | ||||||||||||
| 34 | |||||||||||||
| 35 | |||||||||||||
| 36 | 0 | ▶ | sub inject_args { | ||||||||||
|
Subroutine
inject_args: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||
| 37 | 0 | my $self = shift; | |||||||||||
| 38 | 0 | ▶ | my $args = shift // {}; # HashRef (should not be empty...) | ||||||||||
|
Condition0%0/2
shift() // {}
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 39 | |||||||||||||
| 40 | # do some pre-flight QC | ||||||||||||
| 41 | # and propagate 'defaults' args as default values for all org args | ||||||||||||
| 42 | 0 | ▶ | my %def_args = %{ $self->args_for('defaults') // {} }; | ||||||||||
|
Condition0%0/2
$self->args_for("defaults") // {}
MC/DC0%0/1
$self->args_for("defaults") // {}
$self->args_for("defaults")
Truth table0%0/2
A
A= $self->args_for("defaults")
| |||||||||||||
| 43 | 0 | for my $org_args ( @{ $self->args_for('orgs') } ) { | |||||||||||
| 44 | |||||||||||||
| 45 | # check that org has no underscore between genus and species | ||||||||||||
| 46 | # to prevent app from distinguishing Genus_species and Genus species | ||||||||||||
| 47 | 0 | _check_org_format( $org_args->{org} ); | |||||||||||
| 48 | 0 | $org_args = { %def_args, %{ $org_args } }; | |||||||||||
| 49 | } | ||||||||||||
| 50 | |||||||||||||
| 51 | # same check for query_orgs (42) | ||||||||||||
| 52 | _check_org_format($_) | ||||||||||||
| 53 | 0 | ▶ | for @{ $self->args_for('query_orgs') // [] }; | ||||||||||
|
Condition0%0/2
$self->args_for("query_orgs") // []
MC/DC0%0/1
$self->args_for("query_orgs") // []
$self->args_for("query_orgs")
Truth table0%0/2
A
A= $self->args_for("query_orgs")
| |||||||||||||
| 54 | |||||||||||||
| 55 | # combine YAML and CLI parameters (e.g., debug_mode) | ||||||||||||
| 56 | # Note: CLI take precedences over YAML (in case of duplicates) | ||||||||||||
| 57 | 0 | my %args = ( %{ $self->config }, %{$args} ); | |||||||||||
| 58 | |||||||||||||
| 59 | # add infiles | ||||||||||||
| 60 | 0 | $args{infiles} = $self->infiles; | |||||||||||
| 61 | |||||||||||||
| 62 | ### [CFG] Bio::FastParsers...........: $Bio::FastParsers::VERSION | ||||||||||||
| 63 | ### [CFG] Bio::MUST::Core............: $Bio::MUST::Core::VERSION | ||||||||||||
| 64 | ### [CFG] Bio::MUST::Drivers.........: $Bio::MUST::Drivers::VERSION | ||||||||||||
| 65 | ### [CFG] Bio::MUST::Apps::FortyTwo..: $Bio::MUST::Apps::FortyTwo::VERSION | ||||||||||||
| 66 | |||||||||||||
| 67 | ### [CFG] BMD_BLAST_BINDIR...........: $ENV{BMD_BLAST_BINDIR} | ||||||||||||
| 68 | |||||||||||||
| 69 | ### [CFG] config: %args | ||||||||||||
| 70 | |||||||||||||
| 71 | 0 | return %args; | |||||||||||
| 72 | } | ||||||||||||
| 73 | |||||||||||||
| 74 | |||||||||||||
| 75 | 0 | ▶ | sub _check_org_format { | ||||||||||
|
Subroutine
_check_org_format: not called CC=2 SCAR=17.9
| |||||||||||||
| 76 | 0 | my $org = shift; | |||||||||||
| 77 | |||||||||||||
| 78 | 0 | ▶ | carp "[CFG] Warning: '$org' incorrectly written; use '$1 $2' instead!" | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 79 | if $org =~ m/^(\S+)_(.*)/xms; | ||||||||||||
| 80 | |||||||||||||
| 81 | 0 | return; | |||||||||||
| 82 | } | ||||||||||||
| 83 | |||||||||||||
| 84 | 1 | ▶ | no Moose::Role; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 85 | 1 | 1; | |||||||||||
| 86 | |||||||||||||
| 87 | __END__ | ||||||||||||