Skip to content

Commit

Permalink
Initial modifications to address #130. Now the metric should be consi…
Browse files Browse the repository at this point in the history
…dered correctly and the configuration file should be parsed and checked appropriately
  • Loading branch information
lucventurini committed Oct 3, 2018
1 parent 9794cbc commit acbb2e5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Mikado/configuration/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ def check_scoring(json_conf):
elif json_conf["scoring"][parameter]["use_raw"] is True:
invalid_raw.add(parameter)

if "filter" in json_conf["scoring"][parameter] and "metric" in json_conf["scoring"][parameter]["filter"]:
if json_conf["scoring"][parameter]["filter"]["metric"] not in available_metrics:
parameters_not_found.append(json_conf["scoring"][parameter]["filter"]["metric"])

if len(parameters_not_found) > 0 or len(double_parameters) > 0 or len(invalid_filter) > 0 or len(invalid_raw) > 0:
err_message = ''
if len(parameters_not_found) > 0:
Expand Down
9 changes: 7 additions & 2 deletions Mikado/configuration/scoring_blueprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
"oneOf": [
{
"operator": { "oneOf": ["gt", "ge", "lt", "le"], "optional": false},
"value": {"type": "number", "optional": false}
"value": {"type": "number", "optional": false},
"metric": {"type": "string", "optional": true}
},
{
"operator": { "oneOf": ["ne", "eq"], "optional": false},
"metric": {"type": "string", "optional": true},
"value": {
"oneOf": [{"type": "number"}, {"type": "boolean"}],
"optional": false}
Expand All @@ -28,7 +30,8 @@
],
"optional": false
},
"value": {"type": "array"}
"metric": {"type": "string", "optional": true},
"value": {"type": "array", "optional": false}
},
{
"operator": {
Expand All @@ -38,7 +41,9 @@
],
"optional": false
},
"metric": {"type": "string", "optional": true},
"value": {
"optional": false,
"type": "array",
"items": {
"type": "number"
Expand Down
9 changes: 8 additions & 1 deletion Mikado/loci/abstractlocus.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,14 @@ def _calculate_score(self, param):
check = True
if ("filter" in self.json_conf["scoring"][param] and
self.json_conf["scoring"][param]["filter"] != {}):
check = self.evaluate(tid_metric, self.json_conf["scoring"][param]["filter"])
if "metric" not in self.json_conf["scoring"][param]["filter"]:
metric_to_evaluate = tid_metric
else:
metric_key = self.json_conf["scoring"][param]["filter"]["metric"]
if not hasattr(self.transcripts[tid], metric_key):
raise KeyError("Asked for an invalid metric in filter: {}".format(metric_key))
metric_to_evaluate = getattr(self.transcripts[tid], metric_key)
check = self.evaluate(metric_to_evaluate, self.json_conf["scoring"][param]["filter"])

if check is True:
if use_raw is True:
Expand Down

0 comments on commit acbb2e5

Please sign in to comment.