lib/Bio/MUST/Apps/OmpaPa/Parameters.pm

filter: Statementstmt 77.0% 47 / 61 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 90.9% 20 / 22 Podpod 0.0% 0 / 2 totaltotal 71.2% 67 / 94 CC 4 SCAR 14.1
CC
4
Cov
69%
load_bounds
20.0
store_bounds
2.0
BEGIN
1.0
CRAP 4.1
« lib/Bio/MUST/Apps/OmpaPa/Roles/Parsable.pm ↑ Summary lib/Bio/MUST/Apps/OmpaPa/Hmmer.pm »
1 package Bio::MUST::Apps::OmpaPa::Parameters;
2 # ABSTRACT: Internal class for serializing user-selected parameters
3 # CONTRIBUTOR: Amandine BERTRAND <amandine.bertrand@doct.uliege.be>
4 1 $Bio::MUST::Apps::OmpaPa::Parameters::VERSION = '0.260260';
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use feature qw(say);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Path::Class qw(file);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Bio::MUST::Core;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Bio::MUST::Core::Utils qw(change_suffix);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Smart::Comments '###';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use MooseX::SemiAffordanceAccessor;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use MooseX::Storage;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 with Storage('format' => 'JSON', 'io' => 'File');
20  
21 1 has bb_file => (
22 traits => ['DoNotSerialize'],
23 is => 'ro',
24 isa => 'File::Temp',
25 builder => '_build_bb_file',
26 );
27  
28 has 'min_' . $_ => (
29 is => 'rw',
30 isa => 'Num',
31 builder => '_build_min_' . $_,
32 1 ) for qw(len eval cov copy);
33  
34 has 'max_' . $_ => (
35 is => 'rw',
36 isa => 'Num',
37 builder => '_build_max_' . $_,
38 1 ) for qw(hits len eval cov copy);
39  
40  
41 ## no critic (ProhibitUnusedPrivateSubroutines)
42  
43 6 ▶sub _build_bb_file {
Subroutine _build_bb_file: called CC=1 SCAR=0.0
44 6 return File::Temp->new( UNLINK => 0, SUFFIX => '.bb' );
45 }
46  
47 # TODO: improve handling of default values (DRY principle; same issue as in 42)
48 4 ▶sub _build_max_hits {
Subroutine _build_max_hits: called CC=1 SCAR=0.0
49 4 return 200000;
50 }
51  
52 3 ▶sub _build_min_copy {
Subroutine _build_min_copy: called CC=1 SCAR=0.0
53 3 return 1;
54 }
55  
56 3 ▶sub _build_max_copy {
Subroutine _build_max_copy: called CC=1 SCAR=0.0
57 3 return 3;
58 }
59  
60 3 ▶sub _build_min_cov {
Subroutine _build_min_cov: called CC=1 SCAR=0.0
61 3 return 0.7;
62 }
63  
64 3 ▶sub _build_max_cov {
Subroutine _build_max_cov: called CC=1 SCAR=0.0
65 3 return 1;
66 }
67  
68 3 ▶sub _build_min_eval {
Subroutine _build_min_eval: called CC=1 SCAR=0.0
69 3 return 0;
70 }
71  
72 3 ▶sub _build_max_eval {
Subroutine _build_max_eval: called CC=1 SCAR=0.0
73 3 return 308; # TODO: improve this
74 }
75  
76 3 ▶sub _build_min_len {
Subroutine _build_min_len: called CC=1 SCAR=0.0
77 3 return 0;
78 }
79  
80 3 ▶sub _build_max_len {
Subroutine _build_max_len: called CC=1 SCAR=0.0
81 3 return 10000000; # TODO: improve this
82 }
83  
84 ## use critic
85  
86  
87 0 ▶sub store_bounds {
Subroutine store_bounds: not called CC=1 SCAR=6.9
Pod undocumented
88 0 my $self = shift;
89  
90 0 my $bb_file = $self->bb_file;
91  
92 0 return << "EOT";
93 set print "$bb_file"
94 print "min_eval=" . int(GPVAL_X_MIN)
95 print "max_eval=" . int(GPVAL_X_MAX)
96 print "min_len=" . int(GPVAL_Y_MIN)
97 print "max_len=" . int(GPVAL_Y_MAX)
98 EOT
99 }
100  
101 0 ▶sub load_bounds {
Subroutine load_bounds: not called CC=4 SCAR=30.0
Pod undocumented
102 0 my $self = shift;
103  
104 # horrible hack to wait for the bb_file to be complete
105 # TODO: improve robustness and portability!
106 0 my $shell_cmd = 'wc -l ' . $self->bb_file;
107 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
-e $self->bb_file and `$shell_cmd` =~ /^\s*4\b/msx or do { do { sleep "0.2" } } 0 0 0
Condition0%0/3
-e $self->bb_file and `$shell_cmd` =~ /^\s*4\b/msx
!ll&&!rl&&r
000
MC/DC0%0/2
-e $self->bb_file and `$shell_cmd` =~ /^\s*4\b/msx
-e $self->bb_file `$shell_cmd` =~ /^\s*4\b/msx
Truth table0%0/3
A and B
A= -e $self->bb_fileB= `$shell_cmd` =~ /^\s*4\b/msx
ABresult
0X0
100
111
108 0 sleep(0.2)
109 } until (-e $self->bb_file && qx{$shell_cmd} =~ m/^\s*4\b/xms);
110  
111 0 open my $in, '<', $self->bb_file;
112  
113 0 ▶ while (my $line = <$in>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $in)) 0 0 0
114 0 chomp $line;
115 0 my ($var, $val) = $line =~ m/^ (\w+) = (\-?\d+) $/xmsg;
116 0 my $method = "set_$var";
117 0 $self->$method($val);
118 }
119  
120 0 return;
121 }
122  
123 1 __PACKAGE__->meta->make_immutable;
124 1 1;
125  
126 __END__
« lib/Bio/MUST/Apps/OmpaPa/Roles/Parsable.pm ↑ Summary lib/Bio/MUST/Apps/OmpaPa/Hmmer.pm »