def test_check_vcf_correct(vcf_path): true_nr = 0 with open(vcf_path, 'r') as f: for line in f: if not line.startswith('#'): true_nr += 1 with open(vcf_path, 'r') as f: nr_variants = check_vcf(f) assert nr_variants == true_nr
def test_check_vcf_correct(vcf_path): true_nr = 0 with open(vcf_path, 'r') as f: for line in f: if not line.startswith('#'): true_nr += 1 vcf_obj = get_vcf(vcf_path) nr_variants = check_vcf(vcf_obj) assert nr_variants == true_nr
def load(self, family_id: str, ped_path: str, vcf_path: str) -> dict: """Add observations from a VCF.""" variant_handle = get_file_handle(vcf_path) nr_variants = check_vcf(variant_handle) load_database( adapter=self, variant_file=vcf_path, family_file=ped_path, family_type='ped', case_id=family_id, gq_treshold=20, nr_variants=nr_variants, ) self.check_indexes() return dict(variants=nr_variants)
def load(ctx, variant_file, family_file, family_type, skip_case_id, gq_treshold, case_id): """Load the variants of a case The loading is based on if the variant is seen in a ny affected individual in the family. """ if not family_file: logger.warning("Please provide a family file") ctx.abort() variant_path = os.path.abspath(variant_file) adapter = ctx.obj['adapter'] try: variant_handle = get_file_handle(variant_path) nr_variants = check_vcf(variant_handle) except VcfError as error: logger.warning(error) ctx.abort() logger.info("Vcf file looks fine") logger.info("Nr of variants in vcf: {0}".format(nr_variants)) start_inserting = datetime.now() try: nr_inserted = load_database( adapter=adapter, variant_file=variant_path, family_file=family_file, family_type=family_type, skip_case_id=skip_case_id, case_id=case_id, gq_treshold=gq_treshold, nr_variants=nr_variants, ) except (SyntaxError, CaseError, IOError) as error: logger.warning(error) ctx.abort() logger.info("Time to insert variants: {0}".format( datetime.now() - start_inserting))
def load(ctx, variant_file, family_file, family_type, skip_case_id, gq_treshold, case_id): """Load the variants of a case The loading is based on if the variant is seen in a ny affected individual in the family. """ if not family_file: logger.warning("Please provide a family file") ctx.abort() variant_path = os.path.abspath(variant_file) adapter = ctx.obj['adapter'] try: variant_handle = get_file_handle(variant_path) nr_variants = check_vcf(variant_handle) except VcfError as error: logger.warning(error) ctx.abort() logger.info("Vcf file looks fine") logger.info("Nr of variants in vcf: {0}".format(nr_variants)) start_inserting = datetime.now() try: nr_inserted = load_database( adapter=adapter, variant_file=variant_path, family_file=family_file, family_type=family_type, skip_case_id=skip_case_id, case_id=case_id, gq_treshold=gq_treshold, nr_variants=nr_variants, ) except (SyntaxError, CaseError, IOError) as error: logger.warning(error) ctx.abort() logger.info("Time to insert variants: {0}".format(datetime.now() - start_inserting)) adapter.check_indexes()
def test_check_vcf_unsorted(unsorted_vcf_path): vcf_obj = get_vcf(unsorted_vcf_path) with pytest.raises(VcfError): check_vcf(vcf_obj)
def test_check_vcf_double_variant(double_vcf_path): vcf_obj = get_vcf(double_vcf_path) with pytest.raises(VcfError): check_vcf(vcf_obj)
def test_check_vcf_unsorted(unsorted_vcf_path): with pytest.raises(VcfError): with open(unsorted_vcf_path, 'r') as f: check_vcf(f)
def test_check_vcf_double_variant(double_vcf_path): with pytest.raises(VcfError): with open(double_vcf_path, 'r') as f: check_vcf(f)