| 1 | package Convert::Pheno::Operations; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 136 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 136 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 136 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 136 | ▶ | use File::ShareDir::ProjectDistDir qw(dist_dir); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 136 | ▶ | use File::Spec::Functions qw(catfile); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 136 | ▶ | use JSON::XS qw(decode_json); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 136 | ▶ | use Path::Tiny qw(path); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 136 | ▶ | use Storable qw(dclone); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 136 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | conversion_spec | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | http_request_fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | is_http_conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | is_public_conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | public_conversions | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | registry_metadata | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 136 | my $registry_file = | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | catfile( dist_dir('Convert-Pheno'), 'schema', 'public-conversions.json' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 136 | my $registry = decode_json( path($registry_file)->slurp_raw ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 136 | ▶ | die "Public conversion registry <$registry_file> must contain an object\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | unless ref($registry) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | die "Public conversion registry <$registry_file> has an unsupported schema version\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 136 | ▶ | unless $registry->{schema_version} && $registry->{schema_version} == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$registry->{"schema_version"} and $registry->{"schema_version"} == 1
MC/DC0%0/2
$registry->{"schema_version"} and $registry->{"schema_version"} == 1
$registry->{"schema_version"}
$registry->{"schema_version"} == 1
Truth table33%1/3
A and B
A= $registry->{"schema_version"}B= $registry->{"schema_version"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | die "Public conversion registry <$registry_file> must define conversions\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 136 | ▶ | unless ref( $registry->{conversions} ) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | die "Public conversion registry <$registry_file> must define HTTP request fields\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 136 | ▶ | unless ref( $registry->{http_request_fields} ) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 136 | my %PUBLIC_CONVERSION = %{ $registry->{conversions} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 136 | for my $name ( keys %PUBLIC_CONVERSION ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 5984 | my $spec = $PUBLIC_CONVERSION{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 5984 | ▶ | die "Conversion <$name> must contain an object specification\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | unless ref($spec) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 5984 | for my $field (qw(source target operation pipeline resources entities streaming http_enabled)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | die "Conversion <$name> is missing registry field <$field>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 47872 | ▶ | unless exists $spec->{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | die "Conversion <$name> has an invalid operation type\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 5984 | ▶ | unless $spec->{operation} =~ /\A(?:bundle|direct|pipeline)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | die "Conversion <$name> must define a non-empty pipeline\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 5984 | ▶ | unless ref( $spec->{pipeline} ) eq 'ARRAY' && @{ $spec->{pipeline} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $spec->{"pipeline"} eq "ARRAY" and @{$spec->{"pipeline"};}
MC/DC0%0/2
ref $spec->{"pipeline"} eq "ARRAY" and @{$spec->{"pipeline"};}
ref $spec->{"pipeline"} eq "ARRAY"
@{$spec->{"pipeline"};}
Truth table33%1/3
A and B
A= ref $spec->{"pipeline"} eq "ARRAY"B= @{$spec->{"pipeline"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | die "Conversion <$name> must define SQLite resource requirements\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | unless ref( $spec->{resources} ) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 5984 | ▶ | && exists $spec->{resources}{sqlite}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $spec->{"resources"} eq "HASH" and exists $spec->{"resources"}{"sqlite"}
MC/DC0%0/2
ref $spec->{"resources"} eq "HASH" and exists $spec->{"resources"}{"sqlite"}
ref $spec->{"resources"} eq "HASH"
exists $spec->{"resources"}{"sqlite"}
Truth table33%1/3
A and B
A= ref $spec->{"resources"} eq "HASH"B= exists $spec->{"resources"}{"sqlite"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | die "Conversion <$name> must define entity capabilities\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | unless ref( $spec->{entities} ) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | && ref( $spec->{entities}{default} ) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 5984 | ▶ | && ref( $spec->{entities}{supported} ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $spec->{"entities"} eq "HASH" and ref $spec->{"entities"}{"default"} eq "ARRAY" and ref $spec->{"entities"}{"supported"} eq "ARRAY"
ref $spec->{"entities"} eq "HASH" and ref $spec->{"entities"}{"default"} eq "ARRAY"
MC/DC0%0/3
ref $spec->{"entities"} eq "HASH" and ref $spec->{"entities"}{"default"} eq "ARRAY" and ref $spec->{"entities"}{"supported"} eq "ARRAY"
ref $spec->{"entities"} eq "HASH"
ref $spec->{"entities"}{"default"} eq "ARRAY"
ref $spec->{"entities"}{"supported"} eq "ARRAY"
Truth table25%1/4
A and B and C
A= ref $spec->{"entities"} eq "HASH"B= ref $spec->{"entities"}{"default"} eq "ARRAY"C= ref $spec->{"entities"}{"supported"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 136 | for my $section (qw(input output options)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | die "HTTP request registry section <$section> must contain an array\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 408 | ▶ | unless ref( $registry->{http_request_fields}{$section} ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 136 | for my $name ( keys %PUBLIC_CONVERSION ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 5984 | for my $stage ( @{ $PUBLIC_CONVERSION{$name}{pipeline} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | die "Conversion <$name> references unknown pipeline stage <$stage>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 9112 | ▶ | unless exists $PUBLIC_CONVERSION{$stage}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | die "Conversion <$name> references compound pipeline stage <$stage>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 9112 | ▶ | if $PUBLIC_CONVERSION{$stage}{operation} eq 'pipeline'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 6009 | ▶ | sub is_public_conversion { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_public_conversion: called CC=4 SCAR=14.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 6009 | my ($conversion) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 6009 | ▶ | return 0 unless defined $conversion && !ref($conversion); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $conversion and not ref $conversion
MC/DC0%0/2
defined $conversion and not ref $conversion
defined $conversion
not ref $conversion
Truth table33%1/3
A and not(B)
A= defined $conversionB= not ref $conversion
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 6009 | ▶ | return exists $PUBLIC_CONVERSION{$conversion} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 38 | ▶ | sub public_conversions { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
public_conversions: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 38 | return [ sort keys %PUBLIC_CONVERSION ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 4174 | ▶ | sub conversion_spec { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conversion_spec: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4174 | my ($conversion) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 4174 | ▶ | return unless is_public_conversion($conversion); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 4173 | my $spec = dclone( $PUBLIC_CONVERSION{$conversion} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 4173 | $spec->{name} = $conversion; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 4173 | return $spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1663 | ▶ | sub is_http_conversion { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_http_conversion: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1663 | my ($conversion) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1663 | ▶ | return 0 unless is_public_conversion($conversion); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1663 | ▶ | return $PUBLIC_CONVERSION{$conversion}{http_enabled} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | ▶ | sub http_request_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
http_request_fields: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | return dclone( $registry->{http_request_fields} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 106 | ▶ | sub registry_metadata { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
registry_metadata: called CC=6 SCAR=22.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | return dclone( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | formats => $registry->{formats} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | input_definitions => $registry->{input_definitions} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | option_definitions => $registry->{option_definitions} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | resources => $registry->{resources} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | http_profiles => $registry->{http_profiles} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 106 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%5/10
$registry->{'formats'} || {}
$registry->{'input_definitions'} || {}
$registry->{'option_definitions'} || {}
$registry->{'resources'} || {}
$registry->{'http_profiles'} || {}
MC/DC0%0/1
$registry->{'formats'} || {}
$registry->{'formats'}
MC/DC0%0/1
$registry->{'input_definitions'} || {}
$registry->{'input_definitions'}
MC/DC0%0/1
$registry->{'option_definitions'} || {}
$registry->{'option_definitions'}
MC/DC0%0/1
$registry->{'resources'} || {}
$registry->{'resources'}
MC/DC0%0/1
$registry->{'http_profiles'} || {}
$registry->{'http_profiles'}
Truth table50%1/2
A
A= $registry->{'formats'}
Truth table50%1/2
A
A= $registry->{'input_definitions'}
Truth table50%1/2
A
A= $registry->{'option_definitions'}
Truth table50%1/2
A
A= $registry->{'resources'}
Truth table50%1/2
A
A= $registry->{'http_profiles'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 136 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||