def load_variants(self, case_obj, variant_type='<STR_LIT>', category='<STR_LIT>',<EOL>rank_threshold=None, chrom=None, start=None, end=None,<EOL>gene_obj=None, build='<STR_LIT>'):
<EOL>institute_id = self.institute(institute_id=case_obj['<STR_LIT>'])['<STR_LIT>']<EOL>nr_inserted = <NUM_LIT:0><EOL>variant_file = None<EOL>if variant_type == '<STR_LIT>':<EOL><INDENT>if category == '<STR_LIT>':<EOL><INDENT>variant_file = case_obj['<STR_LIT>'].get('<STR_LIT>')<EOL><DEDENT>elif category == '<STR_LIT>':<EOL><INDENT>variant_file = case_obj['<STR_LIT>'].get('<STR_LIT>')<EOL><DEDENT>elif category == '<STR_LIT:str>':<EOL><INDENT>LOG.debug('<STR_LIT>')<EOL>variant_file = case_obj['<STR_LIT>'].get('<STR_LIT>')<EOL><DEDENT>elif category == '<STR_LIT>':<EOL><INDENT>variant_file = case_obj['<STR_LIT>'].get('<STR_LIT>')<EOL><DEDENT><DEDENT>elif variant_type == '<STR_LIT>':<EOL><INDENT>if category == '<STR_LIT>':<EOL><INDENT>variant_file = case_obj['<STR_LIT>'].get('<STR_LIT>')<EOL><DEDENT>elif category == '<STR_LIT>':<EOL><INDENT>variant_file = case_obj['<STR_LIT>'].get('<STR_LIT>')<EOL><DEDENT>elif category == '<STR_LIT>':<EOL><INDENT>variant_file = case_obj['<STR_LIT>'].get('<STR_LIT>')<EOL><DEDENT><DEDENT>if not variant_file:<EOL><INDENT>raise SyntaxError("<STR_LIT>")<EOL><DEDENT>try:<EOL><INDENT>vcf_obj = VCF(variant_file)<EOL>var = next(vcf_obj)<EOL><DEDENT>except StopIteration as err:<EOL><INDENT>LOG.warning("<STR_LIT>", variant_file)<EOL>return nr_inserted<EOL><DEDENT>vcf_obj = VCF(variant_file)<EOL>rank_results_header = parse_rank_results_header(vcf_obj)<EOL>vep_header = parse_vep_header(vcf_obj)<EOL>individual_positions = {}<EOL>for i, ind in enumerate(vcf_obj.samples):<EOL><INDENT>individual_positions[ind] = i<EOL><DEDENT>sample_info = {}<EOL>if category == '<STR_LIT>':<EOL><INDENT>for ind in case_obj['<STR_LIT>']:<EOL><INDENT>if ind['<STR_LIT>'] == <NUM_LIT:2>:<EOL><INDENT>sample_info[ind['<STR_LIT>']] = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>sample_info[ind['<STR_LIT>']] = '<STR_LIT>'<EOL><DEDENT><DEDENT><DEDENT>region = "<STR_LIT>"<EOL>if gene_obj:<EOL><INDENT>chrom = gene_obj['<STR_LIT>']<EOL>start = max(gene_obj['<STR_LIT:start>'] - <NUM_LIT>, <NUM_LIT:0>)<EOL>end = gene_obj['<STR_LIT:end>'] + <NUM_LIT><EOL><DEDENT>if chrom:<EOL><INDENT>rank_threshold = rank_threshold or -<NUM_LIT:1000><EOL>if not (start and end):<EOL><INDENT>raise SyntaxError("<STR_LIT>")<EOL><DEDENT>region = "<STR_LIT>".format(chrom, start, end)<EOL><DEDENT>else:<EOL><INDENT>rank_threshold = rank_threshold or <NUM_LIT:0><EOL><DEDENT>variants = vcf_obj(region)<EOL>try:<EOL><INDENT>nr_inserted = self._load_variants(<EOL>variants=variants,<EOL>variant_type=variant_type,<EOL>case_obj=case_obj,<EOL>individual_positions=individual_positions,<EOL>rank_threshold=rank_threshold,<EOL>institute_id=institute_id,<EOL>build=build,<EOL>rank_results_header=rank_results_header,<EOL>vep_header=vep_header,<EOL>category=category,<EOL>sample_info = sample_info<EOL>)<EOL><DEDENT>except Exception as error:<EOL><INDENT>LOG.exception('<STR_LIT>')<EOL>LOG.warning("<STR_LIT>")<EOL>self.delete_variants(case_obj['<STR_LIT>'], variant_type)<EOL>raise error<EOL><DEDENT>self.update_variant_rank(case_obj, variant_type, category=category)<EOL>return nr_inserted<EOL>
Load variants for a case into scout.

        Load the variants for a specific analysis type and category into scout.
        If no region is specified, load all variants above rank score threshold
        If region or gene is specified, load all variants from that region
        disregarding variant rank(if not specified)

        Args:
            case_obj(dict): A case from the scout database
            variant_type(str): 'clinical' or 'research'. Default: 'clinical'
            category(str): 'snv', 'str' or 'sv'. Default: 'snv'
            rank_threshold(float): Only load variants above this score. Default: 0
            chrom(str): Load variants from a certain chromosome
            start(int): Specify the start position
            end(int): Specify the end position
            gene_obj(dict): A gene object from the database

        Returns:
            nr_inserted(int)