def test_delete_case_and_variants(vcf_path, ped_path, real_mongo_adapter, case_id, case_obj): mongo_adapter = real_mongo_adapter db = mongo_adapter.db load_database( adapter=mongo_adapter, variant_file=vcf_path, family_file=ped_path, family_type='ped', ) mongo_case = db.case.find_one() assert mongo_case['case_id'] == case_id delete( adapter=mongo_adapter, case_obj=case_obj, ) mongo_case = db.case.find_one() assert mongo_case == None mongo_variant = db.case.find_one() assert mongo_variant == None
def test_load_database_wrong_ped(vcf_path, funny_ped_path, real_mongo_adapter): mongo_adapter = real_mongo_adapter ## GIVEN a vcf and ped file with wrong individuals ## WHEN loading the information ## THEN Error should be raised since individuals is not in vcf with pytest.raises(CaseError): load_database( adapter=mongo_adapter, variant_file=vcf_path, family_file=funny_ped_path, family_type="ped", )
def test_load_database(vcf_path, ped_path, real_mongo_adapter, case_id): mongo_adapter = real_mongo_adapter db = mongo_adapter.db load_database( adapter=mongo_adapter, variant_file=vcf_path, family_file=ped_path, family_type="ped", ) mongo_case = db.case.find_one() assert mongo_case["case_id"] == case_id
def test_load_database_alternative_ped(vcf_path, ped_path, real_mongo_adapter, case_id): mongo_adapter = real_mongo_adapter db = mongo_adapter.db load_database(adapter=mongo_adapter, variant_file=vcf_path, family_file=ped_path, family_type='ped', case_id='alternative') mongo_case = db.case.find_one() mongo_variant = db.variant.find_one() assert mongo_case['case_id'] == 'alternative' assert mongo_variant['families'] == ['alternative']
def load(ctx, variant_file, sv_variants, family_file, family_type, skip_case_id, gq_treshold, case_id, ensure_index, max_window, check_profile, hard_threshold, soft_threshold): """Load the variants of a case A variant is loaded if it is observed in any individual of a case If no family file is provided all individuals in vcf file will be considered. """ if not (family_file or case_id): LOG.warning("Please provide a family file or a case id") ctx.abort() if not (variant_file or sv_variants): LOG.warning("Please provide a VCF file") ctx.abort() variant_path = None if variant_file: variant_path = os.path.abspath(variant_file) variant_sv_path = None if sv_variants: variant_sv_path = os.path.abspath(sv_variants) variant_profile_path = None if check_profile: variant_profile_path = os.path.abspath(check_profile) adapter = ctx.obj['adapter'] genome_build = ctx.obj['genome_build'] start_inserting = datetime.now() try: nr_inserted = load_database(adapter=adapter, variant_file=variant_path, sv_file=variant_sv_path, family_file=family_file, family_type=family_type, skip_case_id=skip_case_id, case_id=case_id, gq_treshold=gq_treshold, max_window=max_window, profile_file=variant_profile_path, hard_threshold=hard_threshold, soft_threshold=soft_threshold, genome_build=genome_build) except (SyntaxError, CaseError, IOError) as error: LOG.warning(error) ctx.abort() LOG.info("Nr variants inserted: %s", nr_inserted) LOG.info("Time to insert variants: {0}".format(datetime.now() - start_inserting)) if ensure_index: adapter.ensure_indexes() else: adapter.check_indexes()
def test_load_database_alternative_ped(vcf_path, ped_path, real_mongo_adapter, case_id): mongo_adapter = real_mongo_adapter db = mongo_adapter.db load_database( adapter=mongo_adapter, variant_file=vcf_path, family_file=ped_path, family_type="ped", case_id="alternative", ) mongo_case = db.case.find_one() mongo_variant = db.variant.find_one() assert mongo_case["case_id"] == "alternative" assert mongo_variant["families"] == ["alternative"]
def test_delete_structural_variants(vcf_path, ped_path, real_mongo_adapter, case_id, sv_case_obj): # GIVEN a mongo adapter with an inserted case with SVs mongo_adapter = real_mongo_adapter db = mongo_adapter.db load_database( adapter=mongo_adapter, variant_file=sv_case_obj['vcf_path'], family_file=ped_path, family_type='ped', sv_file=sv_case_obj['vcf_sv_path'] ) mongo_svs = db.structural_variant.find() assert len(list(mongo_svs)) == 19 # WHEN deleteing the case delete(adapter=mongo_adapter, case_obj=sv_case_obj) # All structural variants should be deleted. mongo_svs = db.structural_variant.find() assert len(list(mongo_svs)) == 0