| 1 | package Convert::Pheno::Source::OMOP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | 136 | ▶ | use autodie; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 136 | ▶ | use File::Basename qw(basename); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 136 | ▶ | use File::Find qw(find); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 136 | ▶ | use File::Spec::Functions qw(catfile); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 136 | ▶ | use File::Temp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 136 | ▶ | use IO::Uncompress::Unzip qw($UnzipError); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 136 | ▶ | use List::Util qw(any); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 136 | ▶ | use Storable qw(dclone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 136 | ▶ | use Convert::Pheno::IO::CSVHandler qw(read_csv read_sqldump sqldump2csv); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 136 | ▶ | use Convert::Pheno::OMOP::Definitions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 136 | ▶ | use Convert::Pheno::OMOP::ParticipantStream qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | omop_init_caches_and_metadata | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | omop_prepare_data_shape | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | omop_require_core_tables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 136 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 136 | ▶ | use Convert::Pheno::Source::Result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 46 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 46 | my ( $class, $converter ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 46 | return bless { converter => $converter }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 46 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 46 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 46 | my $collected = _collect_omop_input( $self->{converter} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | return Convert::Pheno::Source::Result->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | data => $collected->{data}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | owned => $collected->{owned}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | artifacts => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | kind => $collected->{kind}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | filepath_sql => $collected->{filepath_sql}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | filepaths_csv => $collected->{filepaths_csv}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | cleanup_guards => $collected->{cleanup_guards}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 42 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 44 | ▶ | sub prepare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare: called CC=12 SCAR=25.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 44 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 44 | my $converter = $self->{converter}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | return 1 if $converter->{omop_input_prepared} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 44 | ▶ | && exists $converter->{data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$converter->{"omop_input_prepared"} and exists $converter->{"data"}
MC/DC0%0/2
$converter->{"omop_input_prepared"} and exists $converter->{"data"}
$converter->{"omop_input_prepared"}
exists $converter->{"data"}
Truth table33%1/3
A and B
A= $converter->{"omop_input_prepared"}B= exists $converter->{"data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | $converter->{_omop_source_data} = $converter->{data} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | if exists $converter->{data} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 44 | ▶ | && !exists $converter->{_omop_source_data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $converter->{"data"} and not exists $converter->{"_omop_source_data"}
MC/DC50%1/2
exists $converter->{"data"} and not exists $converter->{"_omop_source_data"}
exists $converter->{"data"}
not exists $converter->{"_omop_source_data"}
Truth table66%2/3
A and not(B)
A= exists $converter->{"data"}B= not exists $converter->{"_omop_source_data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | $converter->{data} = $converter->{_omop_source_data} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | if !exists $converter->{data} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 44 | ▶ | && exists $converter->{_omop_source_data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not exists $converter->{"data"} and exists $converter->{"_omop_source_data"}
MC/DC0%0/2
not exists $converter->{"data"} and exists $converter->{"_omop_source_data"}
not exists $converter->{"data"}
exists $converter->{"_omop_source_data"}
Truth table66%2/3
not(A) and B
A= not exists $converter->{"data"}B= exists $converter->{"_omop_source_data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | $converter->{method_ori} = 'omop2bff' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 44 | ▶ | unless exists $converter->{method_ori}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 44 | _ensure_specimen_table_for_biosamples($converter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 44 | $converter->{prev_omop_tables} = [ @{ $converter->{omop_tables} } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 44 | my $source = $self->load; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 40 | my $data = $source->data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 40 | omop_require_core_tables( $converter, $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 40 | _require_specimen_for_biosamples( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | $converter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | filepath_sql => $source->artifact('filepath_sql'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | filepaths_csv => $source->artifact('filepaths_csv'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 39 | omop_init_caches_and_metadata( $converter, $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 39 | omop_prepare_data_shape( $converter, $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 39 | ▶ | $converter->{_owns_prepared_data} = 1 if $source->owned; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 39 | delete $converter->{mapping_file_derived_entity_overrides}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 39 | ▶ | $converter->{filepath_sql} = $source->artifact('filepath_sql') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | if defined $source->artifact('filepath_sql'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 39 | ▶ | $converter->{filepaths_csv} = $source->artifact('filepaths_csv') || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$source->artifact('filepaths_csv') || []
MC/DC0%0/1
$source->artifact('filepaths_csv') || []
$source->artifact('filepaths_csv')
Truth table50%1/2
A
A= $source->artifact('filepaths_csv')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 39 | push @{ $converter->{_source_cleanup_guards} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 39 | ▶ | @{ $source->artifact('cleanup_guards') || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$source->artifact('cleanup_guards') || []
MC/DC100%1/1
$source->artifact('cleanup_guards') || []
$source->artifact('cleanup_guards')
Truth table100%2/2
A
A= $source->artifact('cleanup_guards')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 39 | $converter->{omop_input_prepared} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 39 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 84 | ▶ | sub _requests_biosamples { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_requests_biosamples: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 84 | my ($converter) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 104 | return scalar grep { $_ eq 'biosamples' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 84 | ▶ | @{ $converter->{entities} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$converter->{'entities'} || []
MC/DC0%0/1
$converter->{'entities'} || []
$converter->{'entities'}
Truth table50%1/2
A
A= $converter->{'entities'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 44 | ▶ | sub _ensure_specimen_table_for_biosamples { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ensure_specimen_table_for_biosamples: called CC=5 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 44 | my ($converter) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 44 | ▶ | return 1 unless _requests_biosamples($converter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 90 | return 1 if grep { $_ eq 'SPECIMEN' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 10 | ▶ | @{ $converter->{omop_tables} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$converter->{'omop_tables'} || []
MC/DC0%0/1
$converter->{'omop_tables'} || []
$converter->{'omop_tables'}
Truth table50%1/2
A
A= $converter->{'omop_tables'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | $converter->{omop_tables} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | @{ $converter->{omop_tables} || [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$converter->{'omop_tables'} || []
MC/DC0%0/1
$converter->{'omop_tables'} || []
$converter->{'omop_tables'}
Truth table0%0/2
A
A= $converter->{'omop_tables'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 'SPECIMEN', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 40 | ▶ | sub _require_specimen_for_biosamples { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_require_specimen_for_biosamples: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 40 | my ( $converter, $data, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 40 | ▶ | return 1 unless _requests_biosamples($converter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 10 | ▶ | return 1 if exists $data->{SPECIMEN}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 4 | ▶ | return 1 if _stream_source_has_specimen( $converter, $context ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | die "The entity <biosamples> requires the OMOP table <SPECIMEN>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | ▶ | sub _stream_source_has_specimen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stream_source_has_specimen: called CC=9 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | my ( $converter, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 4 | ▶ | return 0 unless $converter->{stream}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | ▶ | return 0 unless ref($context) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | ▶ | if ( defined $context->{filepath_sql} && length $context->{filepath_sql} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $context->{"filepath_sql"} and length $context->{"filepath_sql"}
MC/DC0%0/2
defined $context->{"filepath_sql"} and length $context->{"filepath_sql"}
defined $context->{"filepath_sql"}
length $context->{"filepath_sql"}
Truth table33%1/3
A and B
A= defined $context->{"filepath_sql"}B= length $context->{"filepath_sql"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | return scalar grep { $_ eq 'SPECIMEN' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | @{ $converter->{prev_omop_tables} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$converter->{'prev_omop_tables'} || []
MC/DC0%0/1
$converter->{'prev_omop_tables'} || []
$converter->{'prev_omop_tables'}
Truth table0%0/2
A
A= $converter->{'prev_omop_tables'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | ▶ | for my $file ( @{ $context->{filepaths_csv} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$context->{'filepaths_csv'} || []
MC/DC0%0/1
$context->{'filepaths_csv'} || []
$context->{'filepaths_csv'}
Truth table50%1/2
A
A= $context->{'filepaths_csv'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | ▶ | return 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | if $file =~ m{(?:^|/|\\)SPECIMEN\.(?:csv|tsv)(?:\.gz)?$}i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 46 | ▶ | sub _collect_omop_input { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_collect_omop_input: called CC=26 SCAR=33.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 46 | my ($converter) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 46 | ▶ | if ( exists $converter->{data} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 9 | $converter->{omop_cli} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 9 | my $data = $converter->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 9 | ▶ | die "OMOP in-memory input must be an object keyed by table name\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | unless ref($data) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 9 | my %supported = map { $_ => 1 } @omop_supported_tables; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 9 | my $normalized = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 9 | for my $input_table ( keys %{$data} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 38 | my $table = uc($input_table); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | die "<$input_table> is not a valid table in OMOP-CDM\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 38 | ▶ | unless $supported{$table}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | die "OMOP input contains table <$table> more than once\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 38 | ▶ | if exists $normalized->{$table}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 38 | my $rows = $data->{$input_table}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 38 | ▶ | die "OMOP table <$table> must contain an array of row objects\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | unless ref($rows) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 38 | for my $row ( @{$rows} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 7922 | ▶ | die "OMOP table <$table> must contain only row objects\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | unless ref($row) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # OMOP cache construction drains owned arrays. Clone module/API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # input so callers retain their original table package. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 38 | $normalized->{$table} = dclone($rows); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 9 | kind => 'memory', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | data => $normalized, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | owned => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | filepath_sql => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | filepaths_csv => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 37 | $converter->{omop_cli} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 37 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 37 | my $filepath_sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | my @filepaths_csv_stream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 37 | my ( $input_files, $cleanup_guards ) = _resolve_file_inputs($converter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 33 | for my $file ( @{$input_files} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 80 | my ( $table_name, $ext ) = _input_file_parts($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 80 | ▶ | if ( $ext =~ m/\.sql/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | print "> Param: --max-lines-sql = $converter->{max_lines_sql}\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 9 | ▶ | if $converter->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 9 | ▶ | if ( !$converter->{stream} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 7 | ▶ | print "> Mode : --no-stream\n\n" if $converter->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 7 | my $sql_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 7 | ( $data, $sql_headers ) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | read_sqldump( { in => $file, self => $converter } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | sqldump2csv( $data, $converter->{out_dir}, $sql_headers ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 7 | ▶ | if $converter->{sql2csv}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 2 | ▶ | print "> Mode : --stream\n\n" if $converter->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | _with_temp_field( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | $converter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 'omop_tables', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | [@stream_ram_memory_tables], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ( $data, undef ) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | read_sqldump( { in => $file, self => $converter } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | print "> Parameter --max-lines-sql set to: $converter->{max_lines_sql}\n\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 9 | ▶ | if $converter->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 9 | $filepath_sql = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 9 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | warn "<$table_name> is not a valid table in OMOP-CDM\n" and next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 71 | ▶ | unless any { $_ eq $table_name } @omop_supported_tables; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Branch: 1 branch
Condition60%3/5
&any(sub {
$_ eq $table_name;
}
, @Convert::Pheno::Source::OMOP::omop_supported_tables) || warn("<$table_name> is not a valid table in OMOP-CDM\n") && (next)
warn "<$table_name> is not a valid table in OMOP-CDM\n" and next
MC/DC0%0/2
&any(sub {
$_ eq $table_name;
}
, @Convert::Pheno::Source::OMOP::omop_supported_tables) || warn("<$table_name> is not a valid table in OMOP-CDM\n") && (next)
&any(sub {
$_ eq $table_name;
}
, @Convert::Pheno::Source::OMOP::omop_supported_tables)
warn "<$table_name> is not a valid table in OMOP-CDM\n"
Truth table66%2/3
A || B
A= &any(sub {
$_ eq $table_name;
}
, @Convert::Pheno::Source::OMOP::omop_supported_tables)B= warn "<$table_name> is not a valid table in OMOP-CDM\n"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 70 | my $message = "Reading <$table_name> and storing it in RAM memory..."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 70 | ▶ | if ( !$converter->{stream} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | print "$message\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 52 | ▶ | if $converter->{verbose} || $converter->{debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$converter->{"verbose"} or $converter->{"debug"}
MC/DC0%0/2
$converter->{"verbose"} or $converter->{"debug"}
$converter->{"verbose"}
$converter->{"debug"}
Truth table33%1/3
A or B
A= $converter->{"verbose"}B= $converter->{"debug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | $data->{$table_name} = read_csv( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 52 | { in => $file, sep => $converter->{sep}, self => $converter } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 36 | ▶ | elsif ( any { $_ eq $table_name } @stream_ram_memory_tables ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | print "$message\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 12 | ▶ | if $converter->{verbose} || $converter->{debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$converter->{"verbose"} or $converter->{"debug"}
MC/DC0%0/2
$converter->{"verbose"} or $converter->{"debug"}
$converter->{"verbose"}
$converter->{"debug"}
Truth table33%1/3
A or B
A= $converter->{"verbose"}B= $converter->{"debug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | $data->{$table_name} = read_csv( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 12 | { in => $file, sep => $converter->{sep}, self => $converter } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 6 | push @filepaths_csv_stream, $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 33 | ▶ | kind => ( $filepath_sql ? 'sql' : 'csv' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | owned => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | filepath_sql => $filepath_sql, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | filepaths_csv => \@filepaths_csv_stream, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | cleanup_guards => $cleanup_guards, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 37 | ▶ | sub _resolve_file_inputs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_file_inputs: called CC=18 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 37 | my ($converter) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 37 | my ( @files, @guards ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 37 | ▶ | my @inputs = @{ $converter->{in_files} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$converter->{'in_files'} || []
MC/DC0%0/1
$converter->{'in_files'} || []
$converter->{'in_files'}
Truth table50%1/2
A
A= $converter->{'in_files'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | my @packages = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 37 | ▶ | defined $_ && !ref($_) && ( -d $_ || ( -f $_ && /\.zip\z/i ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%9/12
defined $_ && !ref($_) && (-d $_ || -f $_ && /\.zip\z/i)
defined $_ and not ref $_
-d $_ or -f $_ and /\.zip\z/i
-f $_ and /\.zip\z/i
MC/DC60%3/5
defined $_ && !ref($_) && (-d $_ || -f $_ && /\.zip\z/i)
defined $_
not ref $_
-d $_
-f $_
/\.zip\z/i
Truth table66%4/6
A and not(B) && C or D and E
A= defined $_B= not ref $_C= -d $_D= -f $_E= /\.zip\z/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } @inputs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 37 | ▶ | die "An OMOP directory or ZIP package must be supplied as the only input path\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@packages and @inputs > 1
MC/DC100%2/2
@packages and @inputs > 1
@packages
@inputs > 1
Truth table100%3/3
A and B
A= @packagesB= @inputs > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | if @packages && @inputs > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 36 | for my $input (@inputs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 73 | ▶ | die "OMOP input path is missing\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $input and not ref $input and length $input
defined $input and not ref $input
MC/DC0%0/3
defined $input and not ref $input and length $input
defined $input
not ref $input
length $input
Truth table25%1/4
A and not(B) and C
A= defined $inputB= not ref $inputC= length $input
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | unless defined $input && !ref($input) && length $input; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 73 | ▶ | if ( -d $input ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | my @directory_files = _directory_table_files($input); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | ▶ | die "OMOP input directory <$input> does not contain CSV or TSV table files\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | unless @directory_files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | push @files, @directory_files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 72 | ▶ | if ( -f $input && $input =~ /\.zip\z/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
-f $input and $input =~ /\.zip\z/i
MC/DC100%2/2
-f $input and $input =~ /\.zip\z/i
-f $input
$input =~ /\.zip\z/i
Truth table100%3/3
A and B
A= -f $inputB= $input =~ /\.zip\z/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 7 | my ( $archive_files, $guard ) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | _extract_zip_tables( $converter, $input ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 4 | push @files, @{$archive_files}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 4 | push @guards, $guard; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 65 | ▶ | if ( _is_supported_input_file($input) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 65 | push @files, $input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 65 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | die "OMOP input <$input> must be a CSV/TSV table, SQL dump, directory, or ZIP package\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 33 | ▶ | die "OMOP input requires table files, a directory, a ZIP package, or an SQL dump\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | unless @files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 33 | _reject_duplicate_tables(\@files); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 33 | return ( \@files, \@guards ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | ▶ | sub _directory_table_files { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_directory_table_files: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | my ($directory) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | my @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | find( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | no_chdir => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 4 | ▶ | wanted => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 4 | ▶ | push @files, $File::Find::name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
-f $File::Find::name and _is_table_file($File::Find::name)
MC/DC50%1/2
-f $File::Find::name and _is_table_file($File::Find::name)
-f $File::Find::name
_is_table_file($File::Find::name)
Truth table66%2/3
A and B
A= -f $File::Find::nameB= _is_table_file($File::Find::name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | if -f $File::Find::name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | && _is_table_file($File::Find::name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | $directory, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | return sort @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 7 | ▶ | sub _extract_zip_tables { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_zip_tables: called CC=15 SCAR=27.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 7 | my ( $converter, $archive ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 7 | my $guard = File::Temp->newdir( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 'convert-pheno-omop-XXXXXX', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | TMPDIR => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | CLEANUP => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 7 | my $directory = "$guard"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 7 | ▶ | my $zip = IO::Uncompress::Unzip->new($archive) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | or die "Cannot open OMOP ZIP package <$archive>: $UnzipError\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 7 | my ( @files, %seen_names ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 7 | my $total_bytes = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 7 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 16 | my $header = $zip->getHeaderInfo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 16 | my $entry = $header->{Name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 16 | ▶ | if ( defined $entry && $entry !~ m{[\\/]\z} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $entry and not $entry =~ m[[\\/]\z]
MC/DC0%0/2
defined $entry and not $entry =~ m[[\\/]\z]
defined $entry
not $entry =~ m[[\\/]\z]
Truth table33%1/3
A and not(B)
A= defined $entryB= not $entry =~ m[[\\/]\z]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 16 | _validate_zip_entry_name( $archive, $entry ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 15 | ▶ | if ( _is_table_file($entry) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 15 | my $name = $entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 15 | $name =~ tr{\\}{/}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 15 | $name =~ s{.*/}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 15 | my $key = lc $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | die "OMOP ZIP package <$archive> contains duplicate table filename <$name>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 15 | ▶ | if $seen_names{$key}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 14 | my $destination = catfile( $directory, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 14 | ▶ | open my $fh, '>:raw', $destination | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | or die "Cannot extract OMOP ZIP entry <$entry>: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 14 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 14 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 164 | my $read = $zip->read($buffer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 164 | ▶ | die "Cannot read OMOP ZIP entry <$entry>: $UnzipError\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $read or $read < 0
MC/DC0%0/2
not defined $read or $read < 0
not defined $read
$read < 0
Truth table33%1/3
not(A) or B
A= not defined $readB= $read < 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | if !defined $read || $read < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 164 | ▶ | last if $read == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 151 | $total_bytes += $read; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 151 | ▶ | my $maximum = $converter->{max_archive_uncompressed_bytes} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$converter->{'max_archive_uncompressed_bytes'} || 0
MC/DC100%1/1
$converter->{'max_archive_uncompressed_bytes'} || 0
$converter->{'max_archive_uncompressed_bytes'}
Truth table100%2/2
A
A= $converter->{'max_archive_uncompressed_bytes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 151 | ▶ | die "OMOP ZIP package <$archive> exceeds the allowed uncompressed size\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$maximum and $total_bytes > $maximum
MC/DC100%2/2
$maximum and $total_bytes > $maximum
$maximum
$total_bytes > $maximum
Truth table100%3/3
A and B
A= $maximumB= $total_bytes > $maximum
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | if $maximum && $total_bytes > $maximum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 150 | print {$fh} $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 13 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 13 | push @files, $destination; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 13 | ▶ | last unless $zip->nextStream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | close $zip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 4 | ▶ | die "OMOP ZIP package <$archive> does not contain CSV or TSV table files\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | unless @files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 4 | return ( \@files, $guard ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 16 | ▶ | sub _validate_zip_entry_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_zip_entry_name: called CC=4 SCAR=14.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 16 | my ( $archive, $entry ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 16 | my $normalized = $entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 16 | $normalized =~ tr{\\}{/}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 16 | ▶ | die "OMOP ZIP package <$archive> contains an unsafe entry <$entry>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$normalized =~ m[\A/] or $normalized =~ m[\A[A-Za-z]:/] or $normalized =~ m[(?:\A|/)\.\.(?:/|\z)]
$normalized =~ m[\A/] or $normalized =~ m[\A[A-Za-z]:/]
MC/DC33%1/3
$normalized =~ m[\A/] or $normalized =~ m[\A[A-Za-z]:/] or $normalized =~ m[(?:\A|/)\.\.(?:/|\z)]
$normalized =~ m[\A/]
$normalized =~ m[\A[A-Za-z]:/]
$normalized =~ m[(?:\A|/)\.\.(?:/|\z)]
Truth table50%2/4
A or B or C
A= $normalized =~ m[\A/]B= $normalized =~ m[\A[A-Za-z]:/]C= $normalized =~ m[(?:\A|/)\.\.(?:/|\z)]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | if $normalized =~ m{\A/} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | || $normalized =~ m{\A[A-Za-z]:/} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | || $normalized =~ m{(?:\A|/)\.\.(?:/|\z)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 15 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 33 | ▶ | sub _reject_duplicate_tables { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reject_duplicate_tables: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 33 | my ($files) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 33 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 33 | for my $file ( @{$files} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 80 | my $table = _table_name($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 80 | ▶ | next unless defined $table; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | die "OMOP input contains table <$table> more than once\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 71 | ▶ | if $seen{$table}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 33 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 80 | ▶ | sub _table_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_name: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 80 | my ($file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 80 | my $name = basename($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 80 | ▶ | return uc($1) if $name =~ /\A(.+)\.(?:csv|tsv)(?:\.gz)?\z/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 80 | ▶ | sub _input_file_parts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_input_file_parts: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 80 | my ($file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 80 | my $name = basename($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 80 | ▶ | return ( uc($1), lc($2) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | if $name =~ /\A(.+?)(\.(?:csv|tsv|sql)(?:\.gz)?)\z/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | return ( uc($name), q{} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 18 | ▶ | sub _is_table_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_table_file: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 18 | my ($file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 18 | ▶ | return defined $file && $file =~ /\.(?:csv|tsv)(?:\.gz)?\z/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $file && $file =~ /\.(?:csv|tsv)(?:\.gz)?\z/i
MC/DC0%0/2
defined $file && $file =~ /\.(?:csv|tsv)(?:\.gz)?\z/i
defined $file
$file =~ /\.(?:csv|tsv)(?:\.gz)?\z/i
Truth table33%1/3
A && B
A= defined $fileB= $file =~ /\.(?:csv|tsv)(?:\.gz)?\z/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 65 | ▶ | sub _is_supported_input_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_supported_input_file: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 65 | my ($file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 65 | ▶ | return defined $file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $file && $file =~ /\.(?:csv|tsv|sql)(?:\.gz)?\z/i
MC/DC0%0/2
defined $file && $file =~ /\.(?:csv|tsv|sql)(?:\.gz)?\z/i
defined $file
$file =~ /\.(?:csv|tsv|sql)(?:\.gz)?\z/i
Truth table33%1/3
A && B
A= defined $fileB= $file =~ /\.(?:csv|tsv|sql)(?:\.gz)?\z/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | && $file =~ /\.(?:csv|tsv|sql)(?:\.gz)?\z/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 2 | ▶ | sub _with_temp_field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_with_temp_field: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 2 | my ( $converter, $field, $value, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | my $had = exists $converter->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 2 | ▶ | my $old = $had ? $converter->{$field} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 2 | $converter->{$field} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 2 | my ( $ok, $result ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 2 | $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 2 | $result = $code->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 2 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 2 | ▶ | if ($had) { $converter->{$field} = $old } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | else { delete $converter->{$field} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 2 | ▶ | die $error unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 2 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 136 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||