Skip to content

Commit

Permalink
Merge pull request #650 from opencobra/fix-duplicates
Browse files Browse the repository at this point in the history
fix: ignore any falsy genes attribute
  • Loading branch information
Midnighter committed Apr 11, 2019
2 parents 955b308 + ee45daa commit 1ea453b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ History

Next Release
------------
* Fix the reactions with identical genes test case to not group all reactions
without any GPR together.

0.9.8 (2019-04-01)
------------------
Expand Down
6 changes: 3 additions & 3 deletions memote/suite/reporting/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ def format_data(data):
"data": format_data(data.get(param)),
"result": res.get(param)})
else:
tests[test].setdefault("history", list())
tests[test]["history"].append({
tests[test].setdefault("history", list()).append({
"branch": branch,
"commit": commit,
"metric": metric,
"data": format_data(data),
"result": res})
"result": res
})
return base
11 changes: 6 additions & 5 deletions memote/support/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ def find_reactions_with_partially_identical_annotations(model):
for (rxn_a, ann_a), (rxn_b, ann_b) in combinations(ann_rxns, 2):
mutual_pair = tuple(ann_a & ann_b)
if len(mutual_pair) > 0:
duplicates.setdefault(mutual_pair, set())
duplicates[mutual_pair].update([rxn_a.id, rxn_b.id])
duplicates.setdefault(mutual_pair, set()).update(
[rxn_a.id, rxn_b.id])
# Transform the object for JSON compatibility
num_duplicated = set()
duplicated = {}
Expand Down Expand Up @@ -508,12 +508,13 @@ def find_reactions_with_identical_genes(model):
"""
duplicates = dict()
for rxn_a, rxn_b in combinations(model.reactions, 2):
if rxn_a.genes is None or rxn_b.genes is None:
if not (rxn_a.genes and rxn_b.genes):
continue
if rxn_a.genes == rxn_b.genes:
# This works because the `genes` are frozen sets.
identifiers = rxn_a.genes
duplicates.setdefault(identifiers, set())
duplicates[identifiers].update([rxn_a.id, rxn_b.id])
duplicates.setdefault(identifiers, set()).update(
[rxn_a.id, rxn_b.id])
# Transform the object for JSON compatibility
num_duplicated = set()
duplicated = {}
Expand Down

0 comments on commit 1ea453b

Please sign in to comment.