| 1 | package Bio::WGS2NCBI::Config; | ||||||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Bio::WGS2NCBI; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Bio::WGS2NCBI::Logger; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use File::Path 'make_path'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 4 | my $SINGLETON; | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 49 | ▶ | sub _file { | ||||||||||||||||||||||||||||||
|
Subroutine
_file: called CC=4 SCAR=22.9
| |||||||||||||||||||||||||||||||||
| 13 | 49 | my ( $key, $value, $self ) = @_; | |||||||||||||||||||||||||||||||
| 14 | 49 | ▶ | if ( $key ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | if ( not $value or not -e $value ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$value and -e $value
MC/DC0%0/2
$value and -e $value
$value
-e $value
Truth table0%0/3
A and B
A= $valueB= -e $value
| |||||||||||||||||||||||||||||||||
| 16 | 0 | ERROR "Argument -$key needs an existing file, not '$value'"; | |||||||||||||||||||||||||||||||
| 17 | 0 | exit(1); | |||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||
| 19 | 0 | $self->$key( $value ); | |||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||
| 21 | 49 | return 's'; | |||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 34 | ▶ | sub _int { | ||||||||||||||||||||||||||||||
|
Subroutine
_int: called CC=4 SCAR=22.9
| |||||||||||||||||||||||||||||||||
| 25 | 34 | my ( $key, $value, $self ) = @_; | |||||||||||||||||||||||||||||||
| 26 | 34 | ▶ | if ( $key ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ( not defined $value or $value !~ /^\d+/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $value =~ /^\d+/
MC/DC0%0/2
defined $value and $value =~ /^\d+/
defined $value
$value =~ /^\d+/
Truth table0%0/3
A and B
A= defined $valueB= $value =~ /^\d+/
| |||||||||||||||||||||||||||||||||
| 28 | 0 | ERROR "Argument -$key needs an integer, not '$value'"; | |||||||||||||||||||||||||||||||
| 29 | 0 | exit(1); | |||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | 0 | $self->$key( $value ); | |||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||
| 33 | 34 | return 'i'; | |||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 21 | ▶ | sub _dir { | ||||||||||||||||||||||||||||||
|
Subroutine
_dir: called CC=4 SCAR=23.7
| |||||||||||||||||||||||||||||||||
| 37 | 21 | my ( $key, $value, $self ) = @_; | |||||||||||||||||||||||||||||||
| 38 | 21 | ▶ | if ( $key ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ( not $value ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 40 | 0 | ERROR "Argument -$key needs a name for a directory, not '$value'"; | |||||||||||||||||||||||||||||||
| 41 | 0 | exit(1); | |||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | elsif ( not -d $value ) { | ||||||||||||||||||||||||||||||||
| 44 | 0 | INFO "Will create directory $value"; | |||||||||||||||||||||||||||||||
| 45 | 0 | make_path( $value ); | |||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | else { | ||||||||||||||||||||||||||||||||
| 48 | 0 | INFO "Directory '$value' already exists, contents (if any) may be overwritten"; | |||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | 0 | $self->$key( $value ); | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | 21 | return 's'; | |||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 42 | ▶ | sub _string { | ||||||||||||||||||||||||||||||
|
Subroutine
_string: called CC=3 SCAR=16.7
| |||||||||||||||||||||||||||||||||
| 56 | 42 | my ( $key, $value, $self ) = @_; | |||||||||||||||||||||||||||||||
| 57 | 42 | ▶ | if ( $key ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ( not $value ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 59 | 0 | ERROR "Argument -$key needs a string, not '$value'"; | |||||||||||||||||||||||||||||||
| 60 | 0 | exit(1); | |||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | 0 | $self->$key( $value ); | |||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | 42 | return 's'; | |||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 7 | ▶ | sub _array { | ||||||||||||||||||||||||||||||
|
Subroutine
_array: called CC=3 SCAR=16.7
| |||||||||||||||||||||||||||||||||
| 68 | 7 | my ( $key, $value, $self ) = @_; | |||||||||||||||||||||||||||||||
| 69 | 7 | ▶ | if ( $key ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ( not $value ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 71 | 0 | ERROR "Argument -$key needs a string, not '$value'"; | |||||||||||||||||||||||||||||||
| 72 | 0 | exit(1); | |||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | 0 | $self->$key( $value ); | |||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||
| 76 | 7 | return 's@'; | |||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 4 | my %fields = ( | |||||||||||||||||||||||||||||||
| 80 | 'prefix' => \&_string, | ||||||||||||||||||||||||||||||||
| 81 | 'template' => \&_file, | ||||||||||||||||||||||||||||||||
| 82 | 'info' => \&_file, | ||||||||||||||||||||||||||||||||
| 83 | 'products' => \&_file, | ||||||||||||||||||||||||||||||||
| 84 | 'masks' => \&_file, | ||||||||||||||||||||||||||||||||
| 85 | 'authority' => \&_string, | ||||||||||||||||||||||||||||||||
| 86 | 'datadir' => \&_dir, | ||||||||||||||||||||||||||||||||
| 87 | 'datafile' => \&_file, | ||||||||||||||||||||||||||||||||
| 88 | 'gff3dir' => \&_dir, | ||||||||||||||||||||||||||||||||
| 89 | 'gff3file' => \&_file, | ||||||||||||||||||||||||||||||||
| 90 | 'validation' => \&_file, | ||||||||||||||||||||||||||||||||
| 91 | 'source' => \&_string, | ||||||||||||||||||||||||||||||||
| 92 | 'chunksize' => \&_int, | ||||||||||||||||||||||||||||||||
| 93 | 'verbosity' => \&_int, | ||||||||||||||||||||||||||||||||
| 94 | 'complexity' => \&_int, | ||||||||||||||||||||||||||||||||
| 95 | 'minlength' => \&_int, | ||||||||||||||||||||||||||||||||
| 96 | 'limit' => \&_int, | ||||||||||||||||||||||||||||||||
| 97 | 'minintron' => \&_int, | ||||||||||||||||||||||||||||||||
| 98 | 'outdir' => \&_dir, | ||||||||||||||||||||||||||||||||
| 99 | 'discrep' => \&_string, | ||||||||||||||||||||||||||||||||
| 100 | 'feature' => \&_array, | ||||||||||||||||||||||||||||||||
| 101 | 'tbl2asn' => \&_string, | ||||||||||||||||||||||||||||||||
| 102 | 'archive' => \&_string, | ||||||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub verbosity { | ||||||||||||||||||||||||||||||
|
Subroutine
verbosity: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 106 | 0 | my ( $self, $v ) = @_; | |||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ( $v and $v =~ /^[0-3]$/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$v and $v =~ /^[0-3]$/
MC/DC0%0/2
$v and $v =~ /^[0-3]$/
$v
$v =~ /^[0-3]$/
Truth table0%0/3
A and B
A= $vB= $v =~ /^[0-3]$/
| |||||||||||||||||||||||||||||||||
| 108 | 0 | $Bio::WGS2NCBI::Logger::Verbosity = $v; | |||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | 0 | return $Bio::WGS2NCBI::Logger::Verbosity; | |||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub complexity { | ||||||||||||||||||||||||||||||
|
Subroutine
complexity: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 114 | 0 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ( defined $c ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 116 | 0 | $Bio::WGS2NCBI::Logger::Complexity = $c; | |||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||
| 118 | 0 | return $Bio::WGS2NCBI::Logger::Complexity; | |||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||
| 122 | # populates the symbol table with a method to get (and | ||||||||||||||||||||||||||||||||
| 123 | # optionally set) the value for a field in %fields | ||||||||||||||||||||||||||||||||
| 124 | 4 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 125 | 4 | for my $key ( keys %fields ) { | |||||||||||||||||||||||||||||||
| 126 | 92 | ▶ | next if $key eq 'verbosity' or $key eq 'complexity'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$key eq "verbosity" or $key eq "complexity"
MC/DC100%2/2
$key eq "verbosity" or $key eq "complexity"
$key eq "verbosity"
$key eq "complexity"
Truth table100%3/3
A or B
A= $key eq "verbosity"B= $key eq "complexity"
| |||||||||||||||||||||||||||||||||
| 127 | 84 | my $type = $fields{$key}->(); | |||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||
| 129 | # method for configuration fields that are arrays | ||||||||||||||||||||||||||||||||
| 130 | 84 | ▶ | if ( $type =~ /\@/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | *$key = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 132 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | $self->{$key} = [] if not $self->{$key}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ( @_ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | push @{ $self->{$key} }, map { ref $_ eq 'ARRAY' ? @$_ : $_ } @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 136 | 0 | $self->{'_configured'}++; | |||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||
| 138 | 0 | return @{ $self->{$key} }; | |||||||||||||||||||||||||||||||
| 139 | 4 | }; | |||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | # method for configuration fields that are scalar | ||||||||||||||||||||||||||||||||
| 143 | else { | ||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | *$key = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 145 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ( @_ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 147 | 0 | $self->{$key} = shift; | |||||||||||||||||||||||||||||||
| 148 | 0 | $self->{'_configured'}++; | |||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||
| 150 | 0 | return $self->{$key}; | |||||||||||||||||||||||||||||||
| 151 | 80 | }; | |||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=12 SCAR=28.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 157 | 3 | my $class = shift; | |||||||||||||||||||||||||||||||
| 158 | 3 | ▶ | if ( $SINGLETON ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 159 | 0 | return $SINGLETON; | |||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||
| 161 | else { | ||||||||||||||||||||||||||||||||
| 162 | 3 | $SINGLETON = { '_configured' => 0 }; | |||||||||||||||||||||||||||||||
| 163 | 3 | bless $SINGLETON, $class; | |||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||
| 165 | # the location of a config ini file like wgs2ncbi.ini can be defined in an | ||||||||||||||||||||||||||||||||
| 166 | # environment variable called WGS2NCBI. This file will be read first. | ||||||||||||||||||||||||||||||||
| 167 | 3 | ▶ | if ( $ENV{'WGS2NCBI'} and -e $ENV{'WGS2NCBI'} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ENV{"WGS2NCBI"} and -e $ENV{"WGS2NCBI"}
MC/DC0%0/2
$ENV{"WGS2NCBI"} and -e $ENV{"WGS2NCBI"}
$ENV{"WGS2NCBI"}
-e $ENV{"WGS2NCBI"}
Truth table66%2/3
A and B
A= $ENV{"WGS2NCBI"}B= -e $ENV{"WGS2NCBI"}
| |||||||||||||||||||||||||||||||||
| 168 | 0 | $SINGLETON->_selfconfig($ENV{'WGS2NCBI'}); | |||||||||||||||||||||||||||||||
| 169 | 0 | INFO 'Read configuration INI file from $WGS2NCBI=' . $ENV{'WGS2NCBI'}; | |||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||
| 171 | else { | ||||||||||||||||||||||||||||||||
| 172 | 3 | ▶ | if ( not @ARGV ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 173 | 2 | WARN 'No configuration from $WGS2NCBI and no command line arguments'; | |||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||
| 177 | # the location of a config ini file can also be provided on the command line | ||||||||||||||||||||||||||||||||
| 178 | # using the -conf argument. Whether this overrides other command line arguments | ||||||||||||||||||||||||||||||||
| 179 | # or vice versa depends on the order in which the command line arguments are | ||||||||||||||||||||||||||||||||
| 180 | # given, as they are processed from left to right. | ||||||||||||||||||||||||||||||||
| 181 | 3 | my ( $verbosity, $config_ini ) = $Bio::WGS2NCBI::Logger::Verbosity; | |||||||||||||||||||||||||||||||
| 182 | my %options = ( | ||||||||||||||||||||||||||||||||
| 183 | 'conf=s' => \$config_ini, | ||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | 'help|?' => sub { Bio::WGS2NCBI->help } | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 185 | 3 | ); | |||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||
| 187 | # make the other command line arguments in Getopt::Long style | ||||||||||||||||||||||||||||||||
| 188 | 3 | for my $key ( keys %fields ) { | |||||||||||||||||||||||||||||||
| 189 | 69 | my $sub = $fields{$key}; | |||||||||||||||||||||||||||||||
| 190 | 69 | my $type = $sub->(); | |||||||||||||||||||||||||||||||
| 191 | 69 | ▶ | if ( not exists $options{"${key}=${type}"} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | $options{"${key}=${type}"} = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 193 | 0 | $sub->( @_, $SINGLETON ); | |||||||||||||||||||||||||||||||
| 194 | 0 | $SINGLETON->{'_configured'}++; | |||||||||||||||||||||||||||||||
| 195 | 69 | }; | |||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||
| 199 | # process command line arguments | ||||||||||||||||||||||||||||||||
| 200 | 3 | GetOptions(%options); | |||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | # process any config file provided on the command line | ||||||||||||||||||||||||||||||||
| 203 | 3 | ▶ | if ( $config_ini and -e $config_ini ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$config_ini and -e $config_ini
MC/DC0%0/2
$config_ini and -e $config_ini
$config_ini
-e $config_ini
Truth table66%2/3
A and B
A= $config_iniB= -e $config_ini
| |||||||||||||||||||||||||||||||||
| 204 | 0 | $SINGLETON->_selfconfig($config_ini); | |||||||||||||||||||||||||||||||
| 205 | 0 | INFO 'Read configuration INI file from -conf=' . $config_ini; | |||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||
| 207 | else { | ||||||||||||||||||||||||||||||||
| 208 | 3 | ▶ | if ( not $SINGLETON->{'_configured'} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 209 | 3 | WARN 'No configuration INI file provided as -conf=<config file>'; | |||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||
| 213 | # process any verbosity setting provided on the command line | ||||||||||||||||||||||||||||||||
| 214 | 3 | ▶ | if ( $verbosity != $Bio::WGS2NCBI::Logger::Verbosity ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 215 | 0 | $SINGLETON->verbosity($verbosity); | |||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | # check if we are configured | ||||||||||||||||||||||||||||||||
| 219 | 3 | ▶ | if ( not $SINGLETON->{'_configured'} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 220 | 3 | ERROR 'No configuration info provided anywhere, quitting.'; | |||||||||||||||||||||||||||||||
| 221 | 3 | ERROR "Try 'wgs2ncbi help' for more info."; | |||||||||||||||||||||||||||||||
| 222 | 3 | exit(1); | |||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||
| 225 | 0 | return bless $SINGLETON, $class; | |||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub _selfconfig { | ||||||||||||||||||||||||||||||
|
Subroutine
_selfconfig: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 230 | 0 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||
| 231 | 0 | my %config = $self->read_ini($file); | |||||||||||||||||||||||||||||||
| 232 | 0 | for my $key ( keys %config ) { | |||||||||||||||||||||||||||||||
| 233 | 0 | my $sub = $fields{$key}; | |||||||||||||||||||||||||||||||
| 234 | 0 | $sub->( $key, $config{$key}, $self ); | |||||||||||||||||||||||||||||||
| 235 | 0 | $self->{'_configured'}++; | |||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||
| 239 | 1 | ▶ | sub read_ini { | ||||||||||||||||||||||||||||||
|
Subroutine
read_ini: called CC=11 SCAR=44.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 240 | 1 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||
| 241 | 1 | my %result; | |||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | if ( $file and -e $file ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$file and -e $file
MC/DC0%0/2
$file and -e $file
$file
-e $file
Truth table33%1/3
A and B
A= $fileB= -e $file
| |||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | open my $fh, '<', $file or die $!; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | while(<$fh>) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 245 | 0 | chomp; | |||||||||||||||||||||||||||||||
| 246 | 0 | s/;.*$//; # strip comments | |||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if ( /^(.+?)=(.+)$/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 248 | 0 | my ( $key, $value ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ( $result{$key} and not ref $result{$key} ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$result{$key} and not ref $result{$key}
MC/DC0%0/2
$result{$key} and not ref $result{$key}
$result{$key}
not ref $result{$key}
Truth table0%0/3
A and not(B)
A= $result{$key}B= not ref $result{$key}
| |||||||||||||||||||||||||||||||||
| 250 | 0 | $result{$key} = [ $result{$key}, $value ]; | |||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||
| 252 | ▶ | elsif ( $result{$key} and ref $result{$key} eq 'ARRAY' ) { | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$result{$key} and ref $result{$key} eq "ARRAY"
MC/DC0%0/2
$result{$key} and ref $result{$key} eq "ARRAY"
$result{$key}
ref $result{$key} eq "ARRAY"
Truth table0%0/3
A and B
A= $result{$key}B= ref $result{$key} eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 253 | 0 | push @{ $result{$key} }, $value; | |||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||
| 255 | else { | ||||||||||||||||||||||||||||||||
| 256 | 0 | $result{$key} = $value; | |||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if ( /\[.*\]/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 260 | 0 | DEBUG "ini-style headings are ignored: $_"; | |||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||
| 264 | 1 | return %result; | |||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||
| 267 | 4 | 1; | |||||||||||||||||||||||||||||||