| 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.058'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | @EXPORT | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 12 | = qw(catfile nfi analysis_version path_to analysis_path gonzlog gonzconf iof $GONZLOG gonzc gonzl gonz_iterate gonzsys); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 12 | %EXPORT_TAGS = (); | |||||||||||||||||||||||||||||||||||||||||
| 22 | 12 | @EXPORT_OK = qw(); | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 12 | my $bgp = Bio::Gonzales::Project->new(); | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 12 | our $GONZLOG = $bgp->log; | |||||||||||||||||||||||||||||||||||||||||
| 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 gonzlog { confess "deprecated call syntax, use gonzl->info" if(@_ > 0 && $_[0]); $bgp->log() } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gonzlog: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 1 branch
Condition0%0/3
@_ > 0 and $_[0]
MC/DC0%0/2
@_ > 0 and $_[0]
@_ > 0
$_[0]
Truth table0%0/3
A and B
A= @_ > 0B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 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
Condition0%0/3
@_ > 0 and $_[0]
MC/DC0%0/2
@_ > 0 and $_[0]
@_ > 0
$_[0]
Truth table0%0/3
A and B
A= @_ > 0B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub nfi { $bgp->nfi(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nfi: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub iof { $bgp->conf(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iof: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub gonzconf { $bgp->conf(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gonzconf: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub gonzc { $bgp->conf(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gonzc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub analysis_path { $bgp->analysis_path(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analysis_path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | sub gonzsys { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | $bgp->log->info("(exec) > " . join(" ", @_ ). " <"); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gonzsys: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | system(@_) == 0 or confess "system failed: $?"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | sub gonz_iterate { | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 12 | ▶ | my ( $src, $code, $conf ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gonz_iterate: called CC=12 SCAR=31.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 12 | ▶ | $conf->{processes} //= 4; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{"processes"} //= 4
MC/DC0%0/1
$conf->{"processes"} //= 4
$conf->{"processes"}
Truth table50%1/2
A
A= $conf->{"processes"}
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 12 | my $data; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 12 | my $ref_type = ref($src); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 12 | ▶ | if ( !$ref_type || ( $ref_type ne 'ARRAY' && $ref_type ne 'HASH' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $ref_type or $ref_type ne "ARRAY" and $ref_type ne "HASH"
$ref_type ne "ARRAY" and $ref_type ne "HASH"
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"
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $data = jslurp($src); | |||||||||||||||||||||||||||||||||||||||||
| 50 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 12 | $data = $src; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 12 | ▶ | if ( $conf->{test} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | $code = sub { say jfreeze( \@_ ); return }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 12 | my $pm = Parallel::ForkManager->new( $conf->{processes} ); | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 12 | my @result_all; | |||||||||||||||||||||||||||||||||||||||||
| 61 | $pm->run_on_finish( | ||||||||||||||||||||||||||||||||||||||||||
| 62 | sub { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 45 | ▶ | my ( $pid, $exit_code, $ident, $exit_signal, $core_dump, $res ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 45 | ▶ | if ( defined($res) && @$res > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $res and @$res > 0
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
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 45 | push @result_all, $res; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 12 | ); | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 12 | ▶ | if ( ref($data) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 12 | ▶ | for ( my $i = 0; $i < @$data; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 77 | ▶ | $pm->start and next; # do the fork | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 11 | my $res = $code->( $i, $data->[$i] ); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 11 | $pm->finish( 0, $res ); # do the exit in the child process | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | $pm->wait_all_children; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } elsif ( ref($data) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | for my $k ( keys %$data ) { | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | $pm->start and next; # do the fork | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $res = $code->( $k, $data->{$k} ); | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $pm->finish( 0, $res ); # do the exit in the child process | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $pm->wait_all_children; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | return \@result_all; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | Bio::Gonzales::AV - analysis project utils | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | use Bio::Gonzales::AV qw(catfile nfi $ANALYSIS_VERSION iof path_to analysis_path msg error debug); | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | =head1 SUBROUTINES | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | =item B<< msg(@stuff) >> | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | say C<@stuff> to C<STDERR>. | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | =item B<< path_to($filename) >> | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | Locate the root of the project and prepend it to the C<$filename>. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | =item B<< iof() >> | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | get access to the IO files config file. Use like | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | my $protein_files = iof()->{protein_files} | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | =item B<< nfi($filename) >> | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | Prepend the current analysis version diretory to the filename. | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | =item B<< catfile($path, $file) >> | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | make them whole again... | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | jw bargsten, C<< <joachim.bargsten at wur.nl> >> | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | =cut | ||||||||||||||||||||||||||||||||||||||||||