Skip to content

Commit

Permalink
Fix for Azure Cosmos MongoDB instance, which does not fully support $…
Browse files Browse the repository at this point in the history
…lookup.
  • Loading branch information
pascalaldo committed Dec 20, 2024
1 parent aee829e commit e1e699c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion gene_function/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,29 @@
class GeneInfo:
objects = database.MongoDBObjects("pankb_gene_info")

def get_gene_info_and_pangenomic_class_pipeline(gene_match):
def get_gene_info_and_pangenomic_class_pipeline(gene_match): # This is an ugly workaround to make it compatible with Azure Cosmos DB
return [
{"$match": gene_match},
{
"$unionWith": {
"coll": "pankb_gene_annotations",
"pipeline": [
{
"$match": {
"pangenome_analysis": gene_match["pangenome_analysis"]
}
},
{"$project": {"_id": 1, "gene": 1, "pangenomic_class": 1}},
],
}
},
{"$group": {"_id": "$gene", "doc": {"$mergeObjects": "$$ROOT"}}},
{"$replaceRoot": {"newRoot": "$doc"}},
{"$match": {"locus_tag": {"$exists": True}}},
{"$fill": {"output": {"pangenomic_class": {"value": "-"}}}}
]

def get_gene_info_and_pangenomic_class_pipeline_mongodb_only(gene_match):
return [
{"$match": gene_match},
{
Expand Down

0 comments on commit e1e699c

Please sign in to comment.