lib/Convert/Pheno/BFF/DerivedEntities.pm

filter: Statementstmt 98.6% 142 / 144 Branchbran 89.1% 66 / 74 Conditioncond 64.2% 54 / 84 MC/DCmcdc 38.6% 17 / 44 Subroutinesub 100% 16 / 16 Podpod 0.0% 0 / 4 totaltotal 80.6% 295 / 366 CC 69 SCAR 22.0
CC
69
Cov
87%
_entity_overrides
15.3
compatibility_dataset_id
14.3
mapping_entity_overrides
11.3
CRAP 9.0
« lib/Convert/Pheno/Source/CDISC/DatasetJSON.pm ↑ Summary lib/Convert/Pheno/DB/SQLite.pm »
1 package Convert::Pheno::BFF::DerivedEntities;
2  
3 138 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 138 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 138 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 138 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 138 ▶use Convert::Pheno::Mapping::Compiler qw(load_mapping_document);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 138 our @EXPORT_OK = qw(
11 execution_entities
12 mapping_entity_overrides
13 compatibility_dataset_id
14 synthesize_bundle_entities
15 );
16  
17 206 ▶sub compatibility_dataset_id {
Subroutine compatibility_dataset_id: called CC=13 SCAR=26.6
Pod undocumented
18 206 my ($self) = @_;
19 206 ▶ return unless $self->{include_dataset_id};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"include_dataset_id"} 197 9 206
20  
21 9 my $error =
22 "--include-dataset-id requires a dataset ID at <beacon.datasets.defaults.id> in the mapping file\n";
23 die $error
24 9 ▶ unless defined $self->{mapping_file} && length $self->{mapping_file};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"mapping_file"} and length $self->{"mapping_file"} 1 8 9
Condition66%2/3
defined $self->{"mapping_file"} and length $self->{"mapping_file"}
!ll&&!rl&&r
108
MC/DC50%1/2
defined $self->{"mapping_file"} and length $self->{"mapping_file"}
defined $self->{"mapping_file"} length $self->{"mapping_file"}
Truth table66%2/3
A and B
A= defined $self->{"mapping_file"}B= length $self->{"mapping_file"}
ABresult
0X0
100
111
25 8 my $mapping = load_mapping_document( $self->{mapping_file} );
26 my $id =
27 ref( $mapping->{beacon} ) eq 'HASH'
28 && ref( $mapping->{beacon}{datasets} ) eq 'HASH'
29 && ref( $mapping->{beacon}{datasets}{defaults} ) eq 'HASH'
30 ? $mapping->{beacon}{datasets}{defaults}{id}
31 8 ▶ : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $mapping->{'beacon'} eq 'HASH' && ref $mapping->{'beacon'}{'datasets'} eq 'HASH' && ref $mapping->{'beacon'}{'datasets'}{'defaults'} eq 'HASH' ? : 7 1 8
Condition66%4/6
ref $mapping->{"beacon"} eq "HASH" and ref $mapping->{"beacon"}{"datasets"} eq "HASH" and ref $mapping->{"beacon"}{"datasets"}{"defaults"} eq "HASH"
!ll&&!rl&&r
107
ref $mapping->{"beacon"} eq "HASH" and ref $mapping->{"beacon"}{"datasets"} eq "HASH"
!ll&&!rl&&r
107
MC/DC33%1/3
ref $mapping->{"beacon"} eq "HASH" and ref $mapping->{"beacon"}{"datasets"} eq "HASH" and ref $mapping->{"beacon"}{"datasets"}{"defaults"} eq "HASH"
ref $mapping->{"beacon"} eq "HASH" ref $mapping->{"beacon"}{"datasets"} eq "HASH" ref $mapping->{"beacon"}{"datasets"}{"defaults"} eq "HASH"
Truth table50%2/4
A and B and C
A= ref $mapping->{"beacon"} eq "HASH"B= ref $mapping->{"beacon"}{"datasets"} eq "HASH"C= ref $mapping->{"beacon"}{"datasets"}{"defaults"} eq "HASH"
ABCresult
0XX0
10X0
1100
1111
32 8 ▶ die $error
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id and not ref $id and $id =~ /\S/ 1 7 8
Condition66%4/6
defined $id and not ref $id and $id =~ /\S/
!ll&&!rl&&r
107
defined $id and not ref $id
!ll&&!rl&&r
107
MC/DC33%1/3
defined $id and not ref $id and $id =~ /\S/
defined $id not ref $id $id =~ /\S/
Truth table50%2/4
A and not(B) and C
A= defined $idB= not ref $idC= $id =~ /\S/
ABCresult
0XX0
10X0
1100
1111
33 unless defined($id) && !ref($id) && $id =~ /\S/;
34 7 my $effective = _entity_overrides($self, 'datasets')->{id};
35 7 ▶ die "--include-dataset-id: the dataset ID override conflicts with the mapping file\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $effective and not ref $effective and "$effective" eq "$id" 1 6 7
Condition50%3/6
defined $effective and not ref $effective and "$effective" eq "$id"
!ll&&!rl&&r
016
defined $effective and not ref $effective
!ll&&!rl&&r
007
MC/DC33%1/3
defined $effective and not ref $effective and "$effective" eq "$id"
defined $effective not ref $effective "$effective" eq "$id"
Truth table50%2/4
A and not(B) and C
A= defined $effectiveB= not ref $effectiveC= "$effective" eq "$id"
ABCresult
0XX0
10X0
1100
1111
36 unless defined($effective) && !ref($effective) && "$effective" eq "$id";
37 6 return "$id";
38 }
39  
40 47 ▶sub mapping_entity_overrides {
Subroutine mapping_entity_overrides: called CC=11 SCAR=24.2
Pod undocumented
41 47 my ($mapping) = @_;
42 47 ▶ return {} unless ref($mapping) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $mapping eq "HASH" 9 38 47
43 38 ▶ return {} unless ref( $mapping->{project} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $mapping->{"project"} eq "HASH" 0 38 38
44  
45 38 my $project = $mapping->{project};
46 38 my %overrides;
47 38 ▶ if ( defined $project->{id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $project->{"id"}) 38 0 38
48 38 $overrides{datasets}{id} = $project->{id};
49 38 $overrides{datasets}{name} = $project->{id};
50 38 $overrides{cohorts}{id} = $project->{id} . '-cohort';
51 38 $overrides{cohorts}{name} = $project->{id};
52 }
53 $overrides{datasets}{description} = $project->{description}
54 38 ▶ if defined $project->{description};
Branch: 1 branch
BranchTrueFalseTotal
if defined $project->{"description"} 26 12 38
55 $overrides{datasets}{version} = $project->{version}
56 38 ▶ if defined $project->{version};
Branch: 1 branch
BranchTrueFalseTotal
if defined $project->{"version"} 38 0 38
57  
58 38 ▶ if ( ref( $mapping->{beacon} ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $mapping->{"beacon"} eq "HASH") 37 1 38
59 37 for my $entity (qw(datasets cohorts)) {
60 74 ▶ next unless ref( $mapping->{beacon}{$entity} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $mapping->{"beacon"}{$entity} eq "HASH" 60 14 74
61 14 ▶ next unless ref( $mapping->{beacon}{$entity}{defaults} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $mapping->{"beacon"}{$entity}{"defaults"} eq "HASH" 0 14 14
62 14 ▶ $overrides{$entity} ||= {};
Condition50%1/2
$overrides{$entity} ||= {}
l!l
140
MC/DC0%0/1
$overrides{$entity} ||= {}
$overrides{$entity}
Truth table50%1/2
A
A= $overrides{$entity}
Aresult
11
00
63 _merge_hash_into(
64 $overrides{$entity},
65 $mapping->{beacon}{$entity}{defaults},
66 14 );
67 }
68 }
69  
70 38 return \%overrides;
71 }
72  
73 126 ▶sub execution_entities {
Subroutine execution_entities: called CC=6 SCAR=18.0
Pod undocumented
74 126 my ($entities) = @_;
75 126 ▶ my @requested = @{ $entities || [] };
Condition50%1/2
$entities || []
l!l
1260
MC/DC0%0/1
$entities || []
$entities
Truth table50%1/2
A
A= $entities
Aresult
11
00
76 126 ▶ @requested = ('individuals') unless @requested;
Branch: 1 branch
BranchTrueFalseTotal
unless @requested 0 126 126
77  
78 126 my %seen;
79 126 my @execution = grep { !$seen{$_}++ } @requested;
80  
81 # Datasets and cohorts are synthesized from the normalized individuals
82 # collection, so keep individuals in the internal bundle even if the user
83 # only requested the derived entities for output.
84 126 ▶ if ( grep { $_ eq 'datasets' || $_ eq 'cohorts' } @execution ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "datasets" or $_ eq "cohorts";} @execution) 31 95 126
Condition100%3/3
$_ eq 'datasets' || $_ eq 'cohorts'
l!l&&r!l&&!r
2931180
MC/DC100%2/2
$_ eq 'datasets' || $_ eq 'cohorts'
$_ eq 'datasets' $_ eq 'cohorts'
Truth table100%3/3
A || B
A= $_ eq 'datasets'B= $_ eq 'cohorts'
ABresult
1X1
011
000
85 unshift @execution, 'individuals'
86 31 ▶ unless grep { $_ eq 'individuals' } @execution;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq "individuals";} @execution 6 25 31
87 }
88  
89 126 return \@execution;
90 }
91  
92 62 ▶sub synthesize_bundle_entities {
Subroutine synthesize_bundle_entities: called CC=6 SCAR=17.9
Pod undocumented
93 62 my ( $self, $bundle, $context ) = @_;
94  
95 62 my %requested = map { $_ => 1 } @{ execution_entities( $context->entities ) };
96 62 my $individuals = $bundle->entities('individuals');
97  
98 62 ▶ return $bundle unless @{$individuals};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$individuals;} 8 54 62
99  
100 54 ▶ if ( $requested{datasets} && !@{ $bundle->entities('datasets') } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($requested{"datasets"} and not @{$bundle->entities("datasets");}) 12 42 54
Condition100%3/3
$requested{"datasets"} and not @{$bundle->entities("datasets");}
!ll&&!rl&&r
40212
MC/DC100%2/2
$requested{"datasets"} and not @{$bundle->entities("datasets");}
$requested{"datasets"} not @{$bundle->entities("datasets");}
Truth table100%3/3
A and not(B)
A= $requested{"datasets"}B= not @{$bundle->entities("datasets");}
ABresult
0X0
100
111
101 12 $bundle->add_entity(
102 datasets => _synthesizeDataset( $self, $bundle, $individuals )
103 );
104 }
105  
106 54 ▶ if ( $requested{cohorts} && !@{ $bundle->entities('cohorts') } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($requested{"cohorts"} and not @{$bundle->entities("cohorts");}) 12 42 54
Condition100%3/3
$requested{"cohorts"} and not @{$bundle->entities("cohorts");}
!ll&&!rl&&r
39312
MC/DC100%2/2
$requested{"cohorts"} and not @{$bundle->entities("cohorts");}
$requested{"cohorts"} not @{$bundle->entities("cohorts");}
Truth table100%3/3
A and not(B)
A= $requested{"cohorts"}B= not @{$bundle->entities("cohorts");}
ABresult
0X0
100
111
107 12 $bundle->add_entity(
108 cohorts => _synthesizeCohort( $self, $individuals )
109 );
110 }
111  
112 54 return $bundle;
113 }
114  
115 12 ▶sub _synthesizeDataset {
Subroutine _synthesizeDataset: called CC=5 SCAR=16.1
116 12 my ( $self, $bundle, $individuals ) = @_;
117  
118 my $dataset = {
119 id => 'dataset-1',
120 name => 'Converted dataset',
121 description => sprintf(
122 'Dataset synthesized from %d individual%s by convert-pheno.',
123 12 ▶ scalar @{$individuals},
Branch: 1 branch
BranchTrueFalseTotal
scalar @{$individuals;} == 1 ? : 5 7 12
124 12 scalar( @{$individuals} ) == 1 ? q{} : 's'
125 ),
126 info => {
127 sourceEntity => 'individuals',
128 12 individualCount => scalar @{$individuals},
129 },
130 };
131  
132 12 my $biosamples = $bundle->entities('biosamples');
133 5 $dataset->{info}{biosampleCount} = scalar @{$biosamples}
134 12 ▶ if @{$biosamples};
Branch: 1 branch
BranchTrueFalseTotal
if @{$biosamples;} 5 7 12
135  
136 12 _merge_hash_into( $dataset, _entity_overrides( $self, 'datasets' ) );
137  
138 12 ▶ unless ( $self->{test} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"test"}) 1 11 12
139 $dataset->{info}{convertPheno} = $self->{convertPheno}
140 1 ▶ if defined $self->{convertPheno};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"convertPheno"} 0 1 1
141 }
142  
143 12 return $dataset;
144 }
145  
146 12 ▶sub _synthesizeCohort {
Subroutine _synthesizeCohort: called CC=4 SCAR=13.9
147 12 my ( $self, $individuals ) = @_;
148  
149 my $cohort = {
150 id => 'cohort-1',
151 name => 'All individuals',
152 cohortType => 'study-defined',
153 12 cohortSize => scalar @{$individuals},
154 };
155  
156 12 my @cohortDataTypes;
157  
158 12 ▶ if ( grep { _hasClinicalContent($_) } @{$individuals} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {_hasClinicalContent($_);} @{$individuals;}) 8 4 12
159 8 push @cohortDataTypes,
160 {
161 id => 'OGMS:0000015',
162 label => 'clinical history',
163 };
164 }
165  
166 12 ▶ if ( grep { _hasGenomicContent($_) } @{$individuals} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {_hasGenomicContent($_);} @{$individuals;}) 0 12 12
167 0 push @cohortDataTypes,
168 {
169 id => 'OBI:0000070',
170 label => 'genotyping assay',
171 };
172 }
173  
174 12 ▶ $cohort->{cohortDataTypes} = \@cohortDataTypes if @cohortDataTypes;
Branch: 1 branch
BranchTrueFalseTotal
if @cohortDataTypes 8 4 12
175 12 _merge_hash_into( $cohort, _entity_overrides( $self, 'cohorts' ) );
176  
177 12 return $cohort;
178 }
179  
180 31 ▶sub _entity_overrides {
Subroutine _entity_overrides: called CC=13 SCAR=27.3
181 31 my ( $self, $entity ) = @_;
182  
183 31 my $overrides = {};
184  
185 31 ▶ if ( exists $self->{source_derived_entity_overrides}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"source_derived_entity_overrides"} and ref $self->{"source_derived_entity_overrides"} eq "HASH" and exists $self->{"source_derived_entity_overrides"}{$entity} and ref $self->{"source_derived_entity_overrides"}{$entity} eq "HASH") 8 23 31
Condition66%6/9
exists $self->{"source_derived_entity_overrides"} and ref $self->{"source_derived_entity_overrides"} eq "HASH" and exists $self->{"source_derived_entity_overrides"}{$entity} and ref $self->{"source_derived_entity_overrides"}{$entity} eq "HASH"
!ll&&!rl&&r
2308
exists $self->{"source_derived_entity_overrides"} and ref $self->{"source_derived_entity_overrides"} eq "HASH" and exists $self->{"source_derived_entity_overrides"}{$entity}
!ll&&!rl&&r
2308
exists $self->{"source_derived_entity_overrides"} and ref $self->{"source_derived_entity_overrides"} eq "HASH"
!ll&&!rl&&r
2308
MC/DC25%1/4
exists $self->{"source_derived_entity_overrides"} and ref $self->{"source_derived_entity_overrides"} eq "HASH" and exists $self->{"source_derived_entity_overrides"}{$entity} and ref $self->{"source_derived_entity_overrides"}{$entity} eq "HASH"
exists $self->{"source_derived_entity_overrides"} ref $self->{"source_derived_entity_overrides"} eq "HASH" exists $self->{"source_derived_entity_overrides"}{$entity} ref $self->{"source_derived_entity_overrides"}{$entity} eq "HASH"
Truth table40%2/5
A and B and C and D
A= exists $self->{"source_derived_entity_overrides"}B= ref $self->{"source_derived_entity_overrides"} eq "HASH"C= exists $self->{"source_derived_entity_overrides"}{$entity}D= ref $self->{"source_derived_entity_overrides"}{$entity} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
186 && ref( $self->{source_derived_entity_overrides} ) eq 'HASH'
187 && exists $self->{source_derived_entity_overrides}{$entity}
188 && ref( $self->{source_derived_entity_overrides}{$entity} ) eq 'HASH' )
189 {
190 _merge_hash_into(
191 $overrides,
192 8 _clone_data( $self->{source_derived_entity_overrides}{$entity} )
193 );
194 }
195  
196 31 ▶ if ( exists $self->{mapping_file_derived_entity_overrides}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"mapping_file_derived_entity_overrides"} and ref $self->{"mapping_file_derived_entity_overrides"} eq "HASH" and exists $self->{"mapping_file_derived_entity_overrides"}{$entity} and ref $self->{"mapping_file_derived_entity_overrides"}{$entity} eq "HASH") 17 14 31
Condition66%6/9
exists $self->{"mapping_file_derived_entity_overrides"} and ref $self->{"mapping_file_derived_entity_overrides"} eq "HASH" and exists $self->{"mapping_file_derived_entity_overrides"}{$entity} and ref $self->{"mapping_file_derived_entity_overrides"}{$entity} eq "HASH"
!ll&&!rl&&r
14017
exists $self->{"mapping_file_derived_entity_overrides"} and ref $self->{"mapping_file_derived_entity_overrides"} eq "HASH" and exists $self->{"mapping_file_derived_entity_overrides"}{$entity}
!ll&&!rl&&r
14017
exists $self->{"mapping_file_derived_entity_overrides"} and ref $self->{"mapping_file_derived_entity_overrides"} eq "HASH"
!ll&&!rl&&r
14017
MC/DC25%1/4
exists $self->{"mapping_file_derived_entity_overrides"} and ref $self->{"mapping_file_derived_entity_overrides"} eq "HASH" and exists $self->{"mapping_file_derived_entity_overrides"}{$entity} and ref $self->{"mapping_file_derived_entity_overrides"}{$entity} eq "HASH"
exists $self->{"mapping_file_derived_entity_overrides"} ref $self->{"mapping_file_derived_entity_overrides"} eq "HASH" exists $self->{"mapping_file_derived_entity_overrides"}{$entity} ref $self->{"mapping_file_derived_entity_overrides"}{$entity} eq "HASH"
Truth table40%2/5
A and B and C and D
A= exists $self->{"mapping_file_derived_entity_overrides"}B= ref $self->{"mapping_file_derived_entity_overrides"} eq "HASH"C= exists $self->{"mapping_file_derived_entity_overrides"}{$entity}D= ref $self->{"mapping_file_derived_entity_overrides"}{$entity} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
197 && ref( $self->{mapping_file_derived_entity_overrides} ) eq 'HASH'
198 && exists $self->{mapping_file_derived_entity_overrides}{$entity}
199 && ref( $self->{mapping_file_derived_entity_overrides}{$entity} ) eq 'HASH' )
200 {
201 _merge_hash_into(
202 $overrides,
203 17 _clone_data( $self->{mapping_file_derived_entity_overrides}{$entity} )
204 );
205 }
206  
207 31 ▶ if ( exists $self->{derived_entity_overrides}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"derived_entity_overrides"} and ref $self->{"derived_entity_overrides"} eq "HASH" and exists $self->{"derived_entity_overrides"}{$entity} and ref $self->{"derived_entity_overrides"}{$entity} eq "HASH") 3 28 31
Condition55%5/9
exists $self->{"derived_entity_overrides"} and ref $self->{"derived_entity_overrides"} eq "HASH" and exists $self->{"derived_entity_overrides"}{$entity} and ref $self->{"derived_entity_overrides"}{$entity} eq "HASH"
!ll&&!rl&&r
2803
exists $self->{"derived_entity_overrides"} and ref $self->{"derived_entity_overrides"} eq "HASH" and exists $self->{"derived_entity_overrides"}{$entity}
!ll&&!rl&&r
0283
exists $self->{"derived_entity_overrides"} and ref $self->{"derived_entity_overrides"} eq "HASH"
!ll&&!rl&&r
0031
MC/DC25%1/4
exists $self->{"derived_entity_overrides"} and ref $self->{"derived_entity_overrides"} eq "HASH" and exists $self->{"derived_entity_overrides"}{$entity} and ref $self->{"derived_entity_overrides"}{$entity} eq "HASH"
exists $self->{"derived_entity_overrides"} ref $self->{"derived_entity_overrides"} eq "HASH" exists $self->{"derived_entity_overrides"}{$entity} ref $self->{"derived_entity_overrides"}{$entity} eq "HASH"
Truth table40%2/5
A and B and C and D
A= exists $self->{"derived_entity_overrides"}B= ref $self->{"derived_entity_overrides"} eq "HASH"C= exists $self->{"derived_entity_overrides"}{$entity}D= ref $self->{"derived_entity_overrides"}{$entity} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
208 && ref( $self->{derived_entity_overrides} ) eq 'HASH'
209 && exists $self->{derived_entity_overrides}{$entity}
210 && ref( $self->{derived_entity_overrides}{$entity} ) eq 'HASH' )
211 {
212 _merge_hash_into(
213 $overrides,
214 3 _clone_data( $self->{derived_entity_overrides}{$entity} )
215 );
216 }
217  
218 31 return $overrides;
219 }
220  
221 718 ▶sub _clone_data {
Subroutine _clone_data: called CC=4 SCAR=13.9
222 718 my ($data) = @_;
223  
224 718 ▶ return $data unless ref($data);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data 538 180 718
225 180 ▶ return { map { $_ => _clone_data( $data->{$_} ) } keys %{$data} }
Branch: 1 branch
BranchTrueFalseTotal
if ref $data eq "HASH" 153 27 180
226 if ref($data) eq 'HASH';
227 27 ▶ return [ map { _clone_data($_) } @{$data} ]
Branch: 1 branch
BranchTrueFalseTotal
if ref $data eq "ARRAY" 25 2 27
228 if ref($data) eq 'ARRAY';
229  
230 2 return $data;
231 }
232  
233 93 ▶sub _merge_hash_into {
Subroutine _merge_hash_into: called CC=7 SCAR=19.6
234 93 my ( $target, $source ) = @_;
235 93 ▶ return $target unless defined $source && ref($source) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $source and ref $source eq "HASH" 0 93 93
Condition33%1/3
defined $source and ref $source eq "HASH"
!ll&&!rl&&r
0093
MC/DC0%0/2
defined $source and ref $source eq "HASH"
defined $source ref $source eq "HASH"
Truth table33%1/3
A and B
A= defined $sourceB= ref $source eq "HASH"
ABresult
0X0
100
111
236  
237 93 for my $key ( keys %{$source} ) {
238 255 my $value = $source->{$key};
239  
240 255 ▶ if ( ref($value) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "HASH") 27 228 255
241 27 ▶ $target->{$key} ||= {};
Condition100%2/2
$target->{$key} ||= {}
l!l
522
MC/DC100%1/1
$target->{$key} ||= {}
$target->{$key}
Truth table100%2/2
A
A= $target->{$key}
Aresult
11
00
242 27 _merge_hash_into( $target->{$key}, $value );
243 27 next;
244 }
245  
246 228 ▶ if ( ref($value) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "ARRAY") 19 209 228
247 19 $target->{$key} = [ @{$value} ];
248 19 next;
249 }
250  
251 209 $target->{$key} = $value;
252 }
253  
254 93 return $target;
255 }
256  
257 1035 ▶sub _hasClinicalContent {
Subroutine _hasClinicalContent: called CC=3 SCAR=11.2
258 1035 my ($individual) = @_;
259 return scalar grep {
260 1035 exists $individual->{$_}
261 && ref( $individual->{$_} ) eq 'ARRAY'
262 6210 ▶ && @{ $individual->{$_} }
Condition66%4/6
exists $individual->{$_} && ref $individual->{$_} eq 'ARRAY' && @{$individual->{$_};}
!ll&&!rl&&r
60280182
exists $individual->{$_} and ref $individual->{$_} eq "ARRAY"
!ll&&!rl&&r
60280182
MC/DC33%1/3
exists $individual->{$_} && ref $individual->{$_} eq 'ARRAY' && @{$individual->{$_};}
exists $individual->{$_} ref $individual->{$_} eq "ARRAY" @{$individual->{$_};}
Truth table50%2/4
A and B && C
A= exists $individual->{$_}B= ref $individual->{$_} eq "ARRAY"C= @{$individual->{$_};}
ABCresult
0XX0
10X0
1100
1111
263 } qw(diseases exposures phenotypicFeatures interventionsOrProcedures measures treatments);
264 }
265  
266 1035 ▶sub _hasGenomicContent {
Subroutine _hasGenomicContent: called CC=7 SCAR=21.3
267 1035 my ($individual) = @_;
268  
269 1035 ▶ return 0 unless exists $individual->{info} && ref( $individual->{info} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless exists $individual->{"info"} and ref $individual->{"info"} eq "HASH" 2 1033 1035
Condition66%2/3
exists $individual->{"info"} and ref $individual->{"info"} eq "HASH"
!ll&&!rl&&r
201033
MC/DC50%1/2
exists $individual->{"info"} and ref $individual->{"info"} eq "HASH"
exists $individual->{"info"} ref $individual->{"info"} eq "HASH"
Truth table66%2/3
A and B
A= exists $individual->{"info"}B= ref $individual->{"info"} eq "HASH"
ABresult
0X0
100
111
270 return 0
271 unless exists $individual->{info}{phenopacket}
272 1033 ▶ && ref( $individual->{info}{phenopacket} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless exists $individual->{"info"}{"phenopacket"} and ref $individual->{"info"}{"phenopacket"} eq "HASH" 1024 9 1033
Condition66%2/3
exists $individual->{"info"}{"phenopacket"} and ref $individual->{"info"}{"phenopacket"} eq "HASH"
!ll&&!rl&&r
102409
MC/DC50%1/2
exists $individual->{"info"}{"phenopacket"} and ref $individual->{"info"}{"phenopacket"} eq "HASH"
exists $individual->{"info"}{"phenopacket"} ref $individual->{"info"}{"phenopacket"} eq "HASH"
Truth table66%2/3
A and B
A= exists $individual->{"info"}{"phenopacket"}B= ref $individual->{"info"}{"phenopacket"} eq "HASH"
ABresult
0X0
100
111
273  
274 9 my $phenopacket = $individual->{info}{phenopacket};
275  
276 return scalar grep {
277 9 exists $phenopacket->{$_}
278 && ref( $phenopacket->{$_} ) eq 'ARRAY'
279 0 ▶ && @{ $phenopacket->{$_} }
Condition33%2/6
exists $phenopacket->{$_} && ref $phenopacket->{$_} eq 'ARRAY' && @{$phenopacket->{$_};}
!ll&&!rl&&r
3600
exists $phenopacket->{$_} and ref $phenopacket->{$_} eq "ARRAY"
!ll&&!rl&&r
3600
MC/DC0%0/3
exists $phenopacket->{$_} && ref $phenopacket->{$_} eq 'ARRAY' && @{$phenopacket->{$_};}
exists $phenopacket->{$_} ref $phenopacket->{$_} eq "ARRAY" @{$phenopacket->{$_};}
Truth table25%1/4
A and B && C
A= exists $phenopacket->{$_}B= ref $phenopacket->{$_} eq "ARRAY"C= @{$phenopacket->{$_};}
ABCresult
0XX0
10X0
1100
1111
280 } qw(genes interpretations variants files);
281 }
282  
283 138 1;
« lib/Convert/Pheno/Source/CDISC/DatasetJSON.pm ↑ Summary lib/Convert/Pheno/DB/SQLite.pm »