Skip to content

Commit

Permalink
Merge pull request #136 from ssi-dk/kriskiil-unique_resistance_genes
Browse files Browse the repository at this point in the history
Update aggregation.py
  • Loading branch information
sjkp authored Jan 9, 2025
2 parents 7f4703a + ad3ce72 commit e23ce4e
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions bifrost/bifrost_listener/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,32 @@ def agg_pipeline(changed_ids=None):
"resistance_genes": {
"$reduce": {
"input": {
"$map": {
"input": {"$objectToArray": "$categories.resistance.report.phenotypes"},
"as": "phenotype",
"in": {
"$reduce": {
"input": {"$objectToArray": "$$phenotype.v.genes"},
"initialValue": "",
"in": {"$concat": ["$$value", {"$cond": [{"$eq": ["$$value", ""]}, "", ", "]}, "$$this.k"]}
"$reduce": {
"input": {
"$map": {
"input": {"$objectToArray": "$categories.resistance.report.phenotypes"},
"as": "phenotype",
"in": {
"$reduce": {
"input": {"$objectToArray": "$$phenotype.v.genes"},
"initialValue": [],
"in": {"$concatArrays": ["$$value", ["$$this.k"]]}
}
}
}
}
},
"initialValue": [],
"in": {"$setUnion": ["$$value", "$$this"]}
}
},
"initialValue": "",
"in": {"$concat": ["$$value", {"$cond": [{"$eq": ["$$value", ""]}, "", ", "]}, "$$this"]}
"in": {
"$cond": {
"if": {"$eq": ["$$value",""]},
"then": "$$this",
"else": {"$concat":["$$value", ", ", "$$this"]}
}
}
}
},
"amr_profile": "$categories.resistance.summary",
Expand Down

0 comments on commit e23ce4e

Please sign in to comment.