Skip to content

Commit bc7f473

Browse files
authored
Merge pull request #54 from BOINC/vko_29_make_output_parameter_optional
[boinc-autodock-vina] Make 'output.out' parameter optional.
2 parents b2b777e + 26350bd commit bc7f473

File tree

3 files changed

+37
-15
lines changed

3 files changed

+37
-15
lines changed

boinc-autodock-vina/README.md

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ This group supports next parameters:
8484

8585
This group supports next parameters:
8686

87-
- `out` - path to output model file (PDBQT). This file should not have absolute path. This is an **required** `string` parameter when: (1) `input.batch` parameter is specified, (2) `input.ligands` parameter is specified and contains only 1 file and `advanced.score_only` is not specified, otherwise it is **optional**.
87+
- `out` - path to output model file (PDBQT). This file should not have absolute path. This is an **optional** parameter.
8888
- `dir` - path to output directory when: (1) in batch mode, (2) `input.ligands` parameter is specified and contains more than 1 file and `advanced.score_only` is not specified. This directory should not have absolute path. This is an **optional** `string` parameter.
8989
- `write_maps` - output filename (directory + prefix name) for maps. Parameter `advanced.force_even_voxels` may be needed to comply with map format. This is an **optional** `string` parameter. E.g. for the folder with maps `.\maps\1iep_receptor.A.map` and `.\maps\1iep_receptor.C.map` should be provided as `maps\1iep_receptor`.
9090

@@ -149,14 +149,11 @@ More information about specified parameters could be found on the official docum
149149
"ligands": [
150150
"1iep_ligand.pdbqt"
151151
]
152-
},
153-
"output": {
154-
"out": "1iep_ligand_vina_out.pdbqt"
155152
}
156153
}
157154
```
158155

159-
### JSON file with search area and exhaustiveness specified
156+
### JSON file with search area, exhaustiveness and output specified
160157

161158
```json
162159
{
@@ -183,9 +180,9 @@ More information about specified parameters could be found on the official docum
183180
}
184181
```
185182

186-
## Example of JSON files that contains information to prepare receiptor and ligands
183+
## Example of JSON files that contains information to prepare receptor and ligands
187184

188-
### Minimal JSON file with one receiptor and one ligand
185+
### Minimal JSON file with one receptor and one ligand
189186

190187
```json
191188
{
@@ -196,14 +193,11 @@ More information about specified parameters could be found on the official docum
196193
},
197194
"prepare_ligands": {
198195
"ligand": "1iep_ligand.sdf"
199-
},
200-
"output": {
201-
"out": "1iep_ligand_vina_out.pdbqt"
202196
}
203197
}
204198
```
205199

206-
### JSON file with one receiptor and one ligand with with search area and exhaustiveness specified
200+
### JSON file with one receptor and one ligand with with search area, exhaustiveness and output specified
207201

208202
```json
209203
{
@@ -234,7 +228,7 @@ More information about specified parameters could be found on the official docum
234228

235229
From this file `work unit generator` will generate **one** work unit.
236230

237-
### JSON file with two receiptors and one ligand with with search area and exhaustiveness specified
231+
### JSON file with two receptors and one ligand with with search area and exhaustiveness specified
238232

239233
```json
240234
{
@@ -257,9 +251,6 @@ From this file `work unit generator` will generate **one** work unit.
257251
},
258252
"misc": {
259253
"exhaustiveness": 4
260-
},
261-
"output": {
262-
"out": "1iep_ligand_vina_out.pdbqt"
263254
}
264255
}
265256
```

boinc-autodock-vina/src/common/config.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,10 @@ bool config::load(const jsoncons::basic_json<char>& json, const std::filesystem:
682682
if (json.contains("misc") && !misc.load(json["misc"], working_directory)) {
683683
return false;
684684
}
685+
686+
if (output.out.empty()) {
687+
output.out = std::filesystem::path(working_directory / "result.pdbqt").string();
688+
}
685689

686690
return true;
687691
}

boinc-autodock-vina/src/unit-tests/config-tests.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,33 @@ TEST_F(Config_UnitTests, FailOnAbsolutePathInConfig_WriteMaps) {
356356
EXPECT_FALSE(config.load(dummy_json_file_path));
357357
}
358358

359+
TEST_F(Config_UnitTests, CheckForDeaultValueInConfig_Out) {
360+
const auto& dummy_json_file_path = std::filesystem::current_path() / "dummy.json";
361+
config config;
362+
363+
dummy_ofstream json;
364+
json.open(dummy_json_file_path);
365+
366+
jsoncons::json_stream_encoder jsoncons_encoder(json());
367+
const json_encoder_helper json_encoder(jsoncons_encoder);
368+
369+
json_encoder.begin_object();
370+
json_encoder.begin_object("input");
371+
json_encoder.value("receptor", "receptor_sample");
372+
json_encoder.begin_array("ligands");
373+
json_encoder.value("ligand_sample2");
374+
json_encoder.end_array();
375+
json_encoder.end_object();
376+
json_encoder.end_object();
377+
378+
jsoncons_encoder.flush();
379+
json.close();
380+
ASSERT_TRUE(config.load(dummy_json_file_path));
381+
382+
const auto out_sample = std::filesystem::current_path() /= "result.pdbqt";
383+
EXPECT_STREQ(out_sample.string().c_str(), config.output.out.c_str());
384+
}
385+
359386
TEST_F(Config_UnitTests, LoadValidator) {
360387
const auto& dummy_json_file_path = std::filesystem::current_path() / "dummy.json";
361388

0 commit comments

Comments
 (0)