Skip to content

Commit

Permalink
Add check for illegal CLI options and opposite.
Browse files Browse the repository at this point in the history
Add more regression tests for CIF-related CLI options.
  • Loading branch information
mittinatten committed May 9, 2021
1 parent 23b5e5e commit 95f07fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/main.cc
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions tests/test-cli.in
Expand Up @@ -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"
Expand Down

0 comments on commit 95f07fd

Please sign in to comment.