blib/lib/Bio/Gonzales/Project/Functions.pm

filter: Statementstmt 69.6% 55 / 79 Branchbran 36.3% 8 / 22 Conditioncond 23.5% 4 / 17 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 48.0% 12 / 25 Podpod 25.0% 3 / 12 totaltotal 49.7% 82 / 165 CC 19 SCAR 22.4
CC
19
Cov
57%
gonz_iterate
23.3
gonzlog
12.0
gonzl
12.0
CRAP 9.4
« blib/lib/Bio/Gonzales/Range/GroupedOverlap.pm ↑ Summary blib/lib/Bio/Gonzales/Domain/Group.pm »
1 package Bio::Gonzales::Project::Functions;
2  
3 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 12 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 12 ▶use File::Spec::Functions qw/catfile/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶use Bio::Gonzales::Project;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use Bio::Gonzales::Util::Cerial;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 ▶use Parallel::ForkManager;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 12 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 our ( @EXPORT, @EXPORT_OK, %EXPORT_TAGS );
17 12 our $VERSION = '0.062'; # VERSION
18  
19 @EXPORT
20 12 = qw(catfile nfi analysis_version path_to analysis_path gonzlog gonzconf iof gonzc gonzl gonz_iterate gonzsys analysis_name);
21 12 %EXPORT_TAGS = ();
22 12 @EXPORT_OK = qw();
23  
24 sub _bgp {
25 0 ▶ state $bgp = Bio::Gonzales::Project->new();
Subroutine _bgp: not called CC=1 SCAR=6.9
26 }
27  
28 0 ▶sub analysis_version { _bgp->analysis_version(@_) }
Subroutine analysis_version: not called CC=1 SCAR=6.9
Pod undocumented
29 0 ▶sub path_to { _bgp->path_to(@_) }
Subroutine path_to: not called CC=1 SCAR=6.9
Pod documented
30 0 ▶sub nfi { _bgp->nfi(@_) }
Subroutine nfi: not called CC=1 SCAR=6.9
Pod documented
31 0 ▶sub iof { _bgp->conf(@_) }
Subroutine iof: not called CC=1 SCAR=6.9
Pod documented
32 0 ▶sub gonzconf { _bgp->conf(@_) }
Subroutine gonzconf: not called CC=1 SCAR=6.9
Pod undocumented
33 0 ▶sub gonzc { _bgp->conf(@_) }
Subroutine gonzc: not called CC=1 SCAR=6.9
Pod undocumented
34 0 ▶sub analysis_path { _bgp->analysis_path(@_) }
Subroutine analysis_path: not called CC=1 SCAR=6.9
Pod undocumented
35 0 ▶sub analysis_name { _bgp->analysis_name(@_) }
Subroutine analysis_name: not called CC=1 SCAR=6.9
Pod undocumented
36  
37 0 ▶sub gonzlog { confess "deprecated call syntax, use gonzlog->info" if ( @_ > 0 && $_[0] ); _bgp->log() }
Subroutine gonzlog: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 0 and $_[0] 0 0 0
Condition0%0/3
@_ > 0 and $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@_ > 0 and $_[0]
@_ > 0 $_[0]
Truth table0%0/3
A and B
A= @_ > 0B= $_[0]
ABresult
0X0
100
111
38 0 ▶sub gonzl { confess "deprecated call syntax, use gonzl->info" if ( @_ > 0 && $_[0] ); _bgp->log() }
Subroutine gonzl: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 0 and $_[0] 0 0 0
Condition0%0/3
@_ > 0 and $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@_ > 0 and $_[0]
@_ > 0 $_[0]
Truth table0%0/3
A and B
A= @_ > 0B= $_[0]
ABresult
0X0
100
111
39  
40 sub gonzsys {
41 0 ▶ _bgp->log->info( "(exec) > " . join( " ", @_ ) . " <" );
Subroutine gonzsys: not called CC=2 SCAR=17.9
Pod undocumented
42 0 ▶ system(@_) == 0 or confess "system failed: $?";
Branch: 1 branch
BranchTrueFalseTotal
system(@_) == 0 or confess("system failed: $?") 0 0 0
43 }
44  
45 sub gonz_iterate {
46 12 ▶ my ( $src, $code, $conf ) = @_;
Subroutine gonz_iterate: called CC=12 SCAR=31.5
Pod undocumented
47 12 ▶ $conf->{processes} //= 4;
Condition50%1/2
$conf->{"processes"} //= 4
l!l
012
MC/DC0%0/1
$conf->{"processes"} //= 4
$conf->{"processes"}
Truth table50%1/2
A
A= $conf->{"processes"}
Aresult
11
00
48 12 my $data;
49 12 my $ref_type = ref($src);
50 12 ▶ if ( !$ref_type || ( $ref_type ne 'ARRAY' && $ref_type ne 'HASH' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ref_type or $ref_type ne 'ARRAY' and $ref_type ne 'HASH') { } 0 12 12
Condition33%2/6
not $ref_type or $ref_type ne "ARRAY" and $ref_type ne "HASH"
l!l&&r!l&&!r
0012
$ref_type ne "ARRAY" and $ref_type ne "HASH"
!ll&&!rl&&r
1200
MC/DC0%0/3
not $ref_type or $ref_type ne "ARRAY" and $ref_type ne "HASH"
not $ref_type $ref_type ne "ARRAY" $ref_type ne "HASH"
Truth table25%1/4
not(A) or B and C
A= not $ref_typeB= $ref_type ne "ARRAY"C= $ref_type ne "HASH"
ABCresult
1XX1
0111
00X0
0100
51 0 $data = jslurp($src);
52 } else {
53 12 $data = $src;
54 }
55  
56 12 ▶ if ( $conf->{test} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"test"}) 0 12 12
57 0 ▶ $code = sub { say jfreeze( \@_ ); return };
Subroutine __ANON__: not called CC=1 SCAR=6.9
58 }
59  
60 12 my $pm = Parallel::ForkManager->new( $conf->{processes} );
61  
62 12 my @result_all;
63 $pm->run_on_finish(
64 sub {
65 45 ▶ my ( $pid, $exit_code, $ident, $exit_signal, $core_dump, $res ) = @_;
Subroutine __ANON__: called CC=3 SCAR=12.5
66  
67 45 ▶ if ( defined($res) && @$res > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $res and @$res > 0) 45 0 45
Condition33%1/3
defined $res and @$res > 0
!ll&&!rl&&r
0045
MC/DC0%0/2
defined $res and @$res > 0
defined $res @$res > 0
Truth table33%1/3
A and B
A= defined $resB= @$res > 0
ABresult
0X0
100
111
68 45 push @result_all, $res;
69 }
70 }
71 12 );
72  
73 12 ▶ if ( ref($data) eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $data eq 'ARRAY') { } 12 0 12
elsif (ref $data eq 'HASH') { } 0 0 0
74 12 ▶ for ( my $i = 0; $i < @$data; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$data) 77 1 78
75 77 ▶ $pm->start and next; # do the fork
Branch: 1 branch
BranchTrueFalseTotal
$pm->start and next 66 11 77
76 11 my $res = $code->( $i, $data->[$i] );
77 11 $pm->finish( 0, $res ); # do the exit in the child process
78 }
79 1 $pm->wait_all_children;
80 } elsif ( ref($data) eq 'HASH' ) {
81 0 for my $k ( keys %$data ) {
82 0 ▶ $pm->start and next; # do the fork
Branch: 1 branch
BranchTrueFalseTotal
$pm->start and next 0 0 0
83 0 my $res = $code->( $k, $data->{$k} );
84 0 $pm->finish( 0, $res ); # do the exit in the child process
85 }
86 0 $pm->wait_all_children;
87  
88 }
89 1 return \@result_all;
90 }
91 12 1;
92  
93 __END__
94  
95 =head1 NAME
96  
97 Bio::Gonzales::AV - analysis project utils
98  
99 =head1 SYNOPSIS
100  
101 use Bio::Gonzales::AV qw(catfile nfi $ANALYSIS_VERSION iof path_to analysis_path msg error debug);
102  
103 =head1 SUBROUTINES
104  
105 =over 4
106  
107 =item B<< msg(@stuff) >>
108  
109 say C<@stuff> to C<STDERR>.
110  
111 =item B<< path_to($filename) >>
112  
113 Locate the root of the project and prepend it to the C<$filename>.
114  
115 =item B<< iof() >>
116  
117 get access to the IO files config file. Use like
118  
119 my $protein_files = iof()->{protein_files}
120  
121 =item B<< nfi($filename) >>
122  
123 Prepend the current analysis version diretory to the filename.
124  
125  
126 =item B<< catfile($path, $file) >>
127  
128 make them whole again...
129  
130 =back
131  
132 =head1 SEE ALSO
133  
134 =head1 AUTHOR
135  
136 jw bargsten, C<< <joachim.bargsten at wur.nl> >>
137  
138 =cut
« blib/lib/Bio/Gonzales/Range/GroupedOverlap.pm ↑ Summary blib/lib/Bio/Gonzales/Domain/Group.pm »