def read_cases(db: MongoAdapter = Depends(database)): """Return counts of SNV and SV variants in database""" nr_cases_snvs = db.nr_cases(snv_cases=True, sv_cases=False) nr_cases_svs = db.nr_cases(snv_cases=False, sv_cases=True) return dict( nr_cases_snvs=nr_cases_snvs, nr_cases_svs=nr_cases_svs, )
def read_variant(variant_id: str, db: MongoAdapter = Depends(database)): variant = db.get_variant({"_id": variant_id}) if not variant: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Variant {variant_id} not found") variant["total"] = db.nr_cases(snv_cases=True, sv_cases=False) return variant
def read_sv( chrom: str, pos: int, end: int, sv_type: str, db: MongoAdapter = Depends(database), end_chrom: str = None, ): structural_variant = db.get_structural_variant({ "chrom": chrom, "end_chrom": end_chrom or chrom, "sv_type": sv_type, "pos": pos, "end": end, }) if not structural_variant: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Variant not found") structural_variant["total"] = db.nr_cases(snv_cases=False, sv_cases=True) return structural_variant