| 1 | package Convert::Pheno::Source::Tabular; | ||||||||||||||||||||||||||||
| 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 Convert::Pheno::BFF::DerivedEntities qw(mapping_entity_overrides); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 136 | ▶ | use Convert::Pheno::IO::CSVHandler qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | get_headers | ||||||||||||||||||||||||||||
| 9 | read_csv | ||||||||||||||||||||||||||||
| 10 | read_mapping_file | ||||||||||||||||||||||||||||
| 11 | read_redcap_dict_file | ||||||||||||||||||||||||||||
| 12 | 136 | ); | |||||||||||||||||||||||||||
| 13 | 136 | ▶ | use Convert::Pheno::Mapping::Compiler qw(compile_mapping); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 136 | ▶ | use Convert::Pheno::Mapping::Shared qw(get_info get_metaData); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 136 | ▶ | use Convert::Pheno::Source::Result; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 25 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 25 | my ( $class, $converter, %arg ) = @_; | |||||||||||||||||||||||||||
| 19 | return bless { | ||||||||||||||||||||||||||||
| 20 | converter => $converter, | ||||||||||||||||||||||||||||
| 21 | 25 | ▶ | kind => $arg{kind} || 'csv', | ||||||||||||||||||||||||||
|
Condition50%1/2
$arg{'kind'} || 'csv'
MC/DC0%0/1
$arg{'kind'} || 'csv'
$arg{'kind'}
Truth table50%1/2
A
A= $arg{'kind'}
| |||||||||||||||||||||||||||||
| 22 | }, $class; | ||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 25 | ▶ | sub load { | ||||||||||||||||||||||||||
|
Subroutine
load: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | 25 | my ($self) = @_; | |||||||||||||||||||||||||||
| 27 | 25 | my $converter = $self->{converter}; | |||||||||||||||||||||||||||
| 28 | my $mapping = read_mapping_file( | ||||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||
| 30 | mapping_file => $converter->{mapping_file}, | ||||||||||||||||||||||||||||
| 31 | self_validate_schema => $converter->{self_validate_schema}, | ||||||||||||||||||||||||||||
| 32 | schema_file => $converter->{schema_file}, | ||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | 25 | ); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | my $data = read_csv( | ||||||||||||||||||||||||||||
| 37 | { | ||||||||||||||||||||||||||||
| 38 | in => $converter->{in_file}, | ||||||||||||||||||||||||||||
| 39 | sep => $converter->{sep}, | ||||||||||||||||||||||||||||
| 40 | 22 | coerce_numbers => 0, | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 21 | my %artifacts = ( mapping => $mapping ); | |||||||||||||||||||||||||||
| 45 | $artifacts{redcap_dictionary} = read_redcap_dict_file( | ||||||||||||||||||||||||||||
| 46 | { redcap_dictionary => $converter->{redcap_dictionary} } | ||||||||||||||||||||||||||||
| 47 | ) | ||||||||||||||||||||||||||||
| 48 | 21 | ▶ | if $self->{kind} eq 'redcap'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | $artifacts{entity_mapping} = compile_mapping( | ||||||||||||||||||||||||||||
| 51 | $mapping, | ||||||||||||||||||||||||||||
| 52 | source_profile => $self->{kind}, | ||||||||||||||||||||||||||||
| 53 | 21 | headers => get_headers($data), | |||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 21 | return Convert::Pheno::Source::Result->new( | |||||||||||||||||||||||||||
| 57 | { | ||||||||||||||||||||||||||||
| 58 | data => $data, | ||||||||||||||||||||||||||||
| 59 | owned => 1, | ||||||||||||||||||||||||||||
| 60 | artifacts => \%artifacts, | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 24 | ▶ | sub prepare { | ||||||||||||||||||||||||||
|
Subroutine
prepare: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | 24 | my ($self) = @_; | |||||||||||||||||||||||||||
| 67 | 24 | my $converter = $self->{converter}; | |||||||||||||||||||||||||||
| 68 | return 1 if exists $converter->{data} | ||||||||||||||||||||||||||||
| 69 | 24 | ▶ | && exists $converter->{data_mapping_file}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $converter->{"data"} and exists $converter->{"data_mapping_file"}
MC/DC0%0/2
exists $converter->{"data"} and exists $converter->{"data_mapping_file"}
exists $converter->{"data"}
exists $converter->{"data_mapping_file"}
Truth table33%1/3
A and B
A= exists $converter->{"data"}B= exists $converter->{"data_mapping_file"}
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 24 | my $source = $self->load; | |||||||||||||||||||||||||||
| 72 | 20 | $source->apply_to($converter); | |||||||||||||||||||||||||||
| 73 | 20 | ▶ | $converter->{data_redcap_dict} = $source->artifact('redcap_dictionary') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | if defined $source->artifact('redcap_dictionary'); | ||||||||||||||||||||||||||||
| 75 | 20 | $converter->{data_mapping_file} = $source->artifact('entity_mapping'); | |||||||||||||||||||||||||||
| 76 | 20 | $converter->{metaData} = get_metaData($converter); | |||||||||||||||||||||||||||
| 77 | 20 | $converter->{convertPheno} = get_info($converter); | |||||||||||||||||||||||||||
| 78 | $converter->{mapping_file_derived_entity_overrides} = | ||||||||||||||||||||||||||||
| 79 | 20 | mapping_entity_overrides( $source->artifact('mapping') ); | |||||||||||||||||||||||||||
| 80 | 20 | return 1; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 136 | 1; | |||||||||||||||||||||||||||