From 95f07fd1fd80a885032f0c991fdac4843633632f Mon Sep 17 00:00:00 2001 From: Simon Mitternacht Date: Sun, 9 May 2021 16:18:06 +0200 Subject: [PATCH] Add check for illegal CLI options and opposite. Add more regression tests for CIF-related CLI options. --- src/main.cc | 8 +++----- tests/test-cli.in | 6 ++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main.cc b/src/main.cc index c9ef165..9eeb2ad 100644 --- a/src/main.cc +++ b/src/main.cc @@ -712,15 +712,13 @@ parse_arg(int argc, char **argv, struct cli_state *state) if (state->output_format == FREESASA_RSA && (opt_set['C'] || opt_set['M'])) abort_msg("the RSA format can not be used with the options -C or -M, " "it does not support several results in one file"); + if (state->output_format & FREESASA_LOG) { fprintf(state->output, "## %s ##\n", PACKAGE_STRING); } - // CLI checks for the cif functionality - if (state->output_format == FREESASA_CIF && state->cif != 1) - abort_msg("The CIF format can not be used without the --cif option set. " - "Input file must be a cif in order to output a cif."); - + if (state->output_format == FREESASA_CIF && state->cif != 1) abort_msg("CIF output can not be generated from .pdb input"); + if (state->output_format == FREESASA_PDB && state->cif == 1) abort_msg("PDB output can not be generated from .cif input."); if ((state->output_format == FREESASA_CIF || state->output_format == FREESASA_PDB) && state->structure_options & FREESASA_SEPARATE_CHAINS && state->structure_options & FREESASA_SEPARATE_MODELS) diff --git a/tests/test-cli.in b/tests/test-cli.in index 00b549c..0afda29 100644 --- a/tests/test-cli.in +++ b/tests/test-cli.in @@ -234,6 +234,12 @@ assert_equal_total "$cli" "$datadir/3bkr.pdb" "$datadir/3bkr.cif --cif" assert_equal_total "$cli -w" "$datadir/3gnn.pdb" "$datadir/3gnn.cif --cif" assert_equal_total "$cli --join-models" "$datadir/2jo4.pdb" "$datadir/2jo4.cif --cif" assert_equal_total "$cli --chain-groups AB+CD -S -n 10" "$datadir/2jo4.pdb" "$datadir/2jo4.cif --cif" +assert_pass "$cli --cif --separate-chain --format=cif $datadir/1ubq.cif" +assert_pass "$cli --cif --separate-models --format=cif $datadir/1ubq.cif" +assert_pass "$cli --cif --format=cif $datadir/1ubq.cif" +assert_fail "$cli --cif --format=pdb $datadir/1ubq.cif" +assert_fail "$cli --format=cif $datadir/1ubq.pdb" +assert_fail "$cli --cif --format=cif --separate-chains --separate-models" echo echo "== Testing --separate-chains and --separate-models output are equal between cif and pdb"