Convert-Pheno
view release on metacpan or search on metacpan
t/23-cli-help.t view on Meta::CPAN
'--mapping-file', 't/redcap2bff/in/redcap_mapping.yaml' ] ],
[ 'accepts CSV tabular input', 'csv2bff',
[ '-i', 'csv', 't/csv2bff/in/csv_data.csv',
'-o', 'bff', 'individuals.json',
'--mapping-file', 't/csv2bff/in/csv_mapping.yaml' ] ],
);
for my $case (@generic_route_cases) {
my ( $description, $method, $argv ) = @{$case};
is( parse_cli_request( @{$argv} )->{data}{method}, $method,
"generic CLI syntax $description" );
}
for my $output_type (qw(csv jsonf jsonld)) {
my $parsed = parse_cli_request(
'-i', 'pxf', 't/pxf2bff/in/pxf.json',
'-o', $output_type, "output.$output_type",
);
is(
$parsed->{data}{method},
"pxf2$output_type",
"generic CLI syntax accepts $output_type output",
);
}
my @cli_error_cases = (
[ 'rejects --default-vital-status without PXF output',
qr/--default-vital-status> is only valid with PXF output/,
'-ipxf', 't/pxf2bff/in/pxf.json', '-obff', 'individuals.json',
'--default-vital-status', 'DECEASED' ],
[ 'reports the removed -oomop PREFIX form', qr/no longer accepts a prefix/,
'-ibff', 't/bff2pxf/in/individuals.json', '-oomop', 'old-prefix',
'--out-dir', $tmpdir, '--ohdsi-db' ],
[ 'rejects unsupported same-format routes', qr/Unsupported conversion <bff2bff>/,
'-ibff', 't/bff2pxf/in/individuals.json', '-obff', 'individuals.json' ],
[ 'reports the cBioPortal package requirement',
qr/valid cBioPortal study directory or ZIP file/,
'-icbioportal', 'missing-study.zip', '-opxf', 'phenopackets.json' ],
[ 'requires Define-XML with Dataset-XML input',
qr/accompanying Define-XML file with --define-xml/,
'-idataset-xml', @datasetxml_files, '-obff', 'individuals.json' ],
[ 'rejects an unsupported generic input type', qr/Unsupported input type <unknown>/,
'-i', 'unknown', 'input.json', '-o', 'bff', 'output.json' ],
[ 'rejects an unsupported generic output type', qr/Unsupported output type <unknown>/,
'-i', 'pxf', 't/pxf2bff/in/pxf.json', '-o', 'unknown', 'output.json' ],
[ 'rejects mixed generic and compact input syntax',
qr/either the generic <-i\/-o> syntax or the compact/,
'-i', 'pxf', '-ipxf', 't/pxf2bff/in/pxf.json',
'-o', 'bff', 't/pxf2bff/in/pxf.json', 'output.json' ],
[ 'rejects generic output without generic input', qr/<-o> requires <-i>/,
'-o', 'pxf', 'output.json' ],
[ 'rejects comma-separated entities', qr/space-separated list/,
'-ipxf', 't/pxf2bff/in/pxf.json', '-obff',
'--entities', 'individuals,biosamples' ],
[ 'rejects unknown BFF entities', qr/Unsupported entity <unknown>/,
'-ipxf', 't/pxf2bff/in/pxf.json', '-obff', '--entities', 'unknown' ],
[ 'rejects entity selection for non-BFF output',
qr/<--entities> is only valid with BFF output/,
'-ipxf', 't/pxf2bff/in/pxf.json', '-opxf', 'output.json',
'--entities', 'individuals' ],
[ 'rejects streaming for non-OMOP input',
qr/<--stream> is only valid with <-iomop> and <-obff>/,
'-ipxf', 't/pxf2bff/in/pxf.json', '-obff', 'output.json', '--stream' ],
[ 'rejects unsupported openEHR to OMOP output',
qr/openEHR input path currently supports only BFF or PXF output/,
'-i', 'openehr', 't/openehr2bff/in/gecco_personendaten_patient.json',
'-o', 'omop', '--ohdsi-db' ],
[ 'rejects invalid default vital status values', qr/Unsupported value <MISSING>/,
'-ibff', 't/bff2pxf/in/individuals.json', '-opxf', 'output.json',
'--default-vital-status', 'MISSING' ],
[ 'rejects malformed output-name overrides', qr/Invalid <--out-name> value/,
'-ipxf', 't/pxf2bff/in/pxf.json', '-obff', '--entities', 'individuals',
'--out-name', 'individuals.json' ],
[ 'requires an output-name entity to be requested',
qr/entity <biosamples> must also be requested/,
'-ipxf', 't/pxf2bff/in/pxf.json', '-obff', '--entities', 'individuals',
'--out-name', 'biosamples=samples.json' ],
[ 'rejects unsupported terminology audit extensions',
qr/\.tsv, \.tsv\.gz, or \.xlsx/,
'-icsv', 't/csv2bff/in/csv_data.csv',
'--mapping-file', 't/csv2bff/in/csv_mapping.yaml',
'-obff', 'output.json', '--term-audit', 'audit.csv' ],
[ 'rejects Define-XML outside Dataset input', qr/<--define-xml> is only valid/,
'-ipxf', 't/pxf2bff/in/pxf.json', '-obff', 'output.json',
'--define-xml', 't/datasetxml2bff/in/define.xml' ],
[ 'requires an OHDSI database for OMOP output', qr/Please use --ohdsi-db/,
'-ibff', 't/bff2pxf/in/individuals.json', '-oomop' ],
[ 'requires the REDCap dictionary', qr/valid REDCap data dictionary/,
'-iredcap', 't/redcap2bff/in/redcap_data.csv',
'--mapping-file', 't/redcap2bff/in/redcap_mapping.yaml',
'-obff', 'output.json' ],
[ 'requires a mapping file for CSV input', qr/valid mapping file/,
'-icsv', 't/csv2bff/in/csv_data.csv', '-obff', 'output.json' ],
[ 'rejects OMOP table selection for other inputs',
qr/<--omop-tables> is only valid with <-iomop>/,
'-ipxf', 't/pxf2bff/in/pxf.json', '-obff', 'output.json',
'--omop-tables', 'PERSON' ],
);
for my $case (@cli_error_cases) {
my ( $description, $match, @argv ) = @{$case};
like( parse_cli_error(@argv), $match, "CLI parser $description" );
}
my $cli = cli_script_path();
plan skip_all => "convert-pheno CLI not found at $cli" unless -f $cli;
my $help = qx{$^X $cli --help 2>&1};
is( $? >> 8, 0, 'CLI help exits successfully' );
my @help_contract = (
[ like => qr/--search <type>/, 'CLI help documents --search' ],
[ like => qr/--min-text-similarity-score <s>/, 'CLI help documents --min-text-similarity-score' ],
[ like => qr/--text-similarity-method <m>/, 'CLI help documents --text-similarity-method' ],
[ like => qr/--levenshtein-weight <w>/, 'CLI help documents --levenshtein-weight' ],
[ like => qr/--term-audit <file>/, 'CLI help documents --term-audit' ],
[ like => qr/\.tsv\|\.tsv\.gz\|\.xlsx/, 'CLI help documents terminology audit formats' ],
[ unlike => qr/--term-audit-tsv/, 'CLI help omits the superseded --term-audit-tsv option' ],
[ unlike => qr/--search-audit-tsv/, 'CLI help omits the replaced --search-audit-tsv option' ],
[ unlike => qr/--print-hidden-labels/, 'CLI help omits the removed hidden-label option' ],
[ like => qr/--username\|-u <name>/, 'CLI help documents the restored username alias' ],
[ like => qr/--default-vital-status <s>/, 'CLI help documents --default-vital-status' ],
( run in 1.343 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )