def variant(self, document_id, gene_panels=None, case_id=None): """Returns the specified variant. Arguments: document_id : A md5 key that represents the variant or "variant_id" gene_panels(List[GenePanel]) case_id (str): case id (will search with "variant_id") Returns: variant_object(Variant): A odm variant object """ query = {} if case_id: # search for a variant in a case query['case_id'] = case_id query['variant_id'] = document_id else: # search with a unique id query['_id'] = document_id variant_obj = self.variant_collection.find_one(query) if variant_obj: variant_obj = self.add_gene_info(variant_obj, gene_panels) if variant_obj['chromosome'] in ['X', 'Y']: ## TODO add the build here variant_obj['is_par'] = is_par(variant_obj['chromosome'], variant_obj['position']) return variant_obj
def test_is_par_wrong_chromosome(): ## GIVEN a position that is in the first par region chromosome = "1" position = 60001 build = "37" ## WHEN checking the coordinates for the positions ## THEN assert that there way a hit assert is_par(chromosome, position, build) is False
def test_is_par(): ## GIVEN a position that is in the first par region chromosome = "X" position = 60001 build = "37" ## WHEN checking the coordinates for a variant ## THEN assert that there way a hit assert is_par(chromosome, position, build)
def test_is_par_wrong_chromosome(): ## GIVEN a position that is in the first par region chromosome = '1' position = 60001 build = '37' ## WHEN checking the coordinates for the positions ## THEN assert that there way a hit assert is_par(chromosome, position, build) is False
def test_is_par(): ## GIVEN a position that is in the first par region chromosome = 'X' position = 60001 build = '37' ## WHEN checking the coordinates for a variant ## THEN assert that there way a hit assert is_par(chromosome, position, build)
def variant( self, document_id=None, gene_panels=None, case_id=None, simple_id=None, variant_type="clinical", ): """Returns the specified variant. Arguments: document_id : A md5 key that represents the variant or "variant_id" gene_panels(List[GenePanel]) case_id (str): case id (will search with "variant_id") simple_id (str): a variant simple_id (example: 1_161184089_G_GTA) variant_type(str): 'research' or 'clinical' - default 'clinical' Returns: variant_object(Variant): A odm variant object """ query = {} if case_id and document_id: # search for a variant in a case by variant_id query["case_id"] = case_id query["variant_id"] = document_id elif case_id and simple_id: # search for a variant in a case by its simple_id query["case_id"] = case_id query["simple_id"] = simple_id query["variant_type"] = variant_type else: # search with a unique id query["_id"] = document_id variant_obj = self.variant_collection.find_one(query) if not variant_obj: return variant_obj case_obj = self.case(case_id=variant_obj["case_id"]) if case_obj: variant_obj = self.add_gene_info( variant_obj=variant_obj, gene_panels=gene_panels, build=case_obj["genome_build"], ) else: variant_obj = self.add_gene_info(variant_obj=variant_obj, gene_panels=gene_panels) if variant_obj["chromosome"] in ["X", "Y"]: # TO DO add the build here variant_obj["is_par"] = is_par(variant_obj["chromosome"], variant_obj["position"]) return variant_obj