def parse_variant(variant, case, variant_type='<STR_LIT>',<EOL>rank_results_header=None, vep_header=None,<EOL>individual_positions=None, category=None):
<EOL>rank_results_header = rank_results_header or []<EOL>vep_header = vep_header or []<EOL>parsed_variant = {}<EOL>case_id = case['<STR_LIT>']<EOL>if '<STR_LIT:->' in case_id:<EOL><INDENT>logger.debug('<STR_LIT>')<EOL>genmod_key = case['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>genmod_key = case['<STR_LIT>']<EOL><DEDENT>chrom_match = CHR_PATTERN.match(variant.CHROM)<EOL>chrom = chrom_match.group(<NUM_LIT:2>)<EOL>if variant.ALT:<EOL><INDENT>alt=variant.ALT[<NUM_LIT:0>]<EOL><DEDENT>elif not variant.ALT and category == "<STR_LIT:str>":<EOL><INDENT>alt='<STR_LIT:.>'<EOL><DEDENT>parsed_variant['<STR_LIT>'] = parse_ids(<EOL>chrom=chrom,<EOL>pos=variant.POS,<EOL>ref=variant.REF,<EOL>alt=alt,<EOL>case_id=case_id,<EOL>variant_type=variant_type,<EOL>)<EOL>parsed_variant['<STR_LIT>'] = case_id<EOL>parsed_variant['<STR_LIT>'] = variant_type<EOL>if not category:<EOL><INDENT>category = variant.var_type<EOL>if category == '<STR_LIT>':<EOL><INDENT>category = '<STR_LIT>'<EOL><DEDENT>if category == '<STR_LIT>':<EOL><INDENT>category = '<STR_LIT>'<EOL><DEDENT><DEDENT>parsed_variant['<STR_LIT>'] = category<EOL>parsed_variant['<STR_LIT>'] = variant.REF<EOL>if len(variant.ALT) > <NUM_LIT:1>:<EOL><INDENT>raise VcfError("<STR_LIT>")<EOL><DEDENT>parsed_variant['<STR_LIT>'] = alt<EOL>parsed_variant['<STR_LIT>'] = variant.QUAL<EOL>if variant.FILTER:<EOL><INDENT>parsed_variant['<STR_LIT>'] = variant.FILTER.split('<STR_LIT:;>')<EOL><DEDENT>else:<EOL><INDENT>parsed_variant['<STR_LIT>'] = ['<STR_LIT>']<EOL><DEDENT>parsed_variant['<STR_LIT>'] = variant.ID<EOL>parsed_variant['<STR_LIT>'] = None<EOL>parsed_variant['<STR_LIT>'] = chrom<EOL>coordinates = parse_coordinates(variant, category)<EOL>parsed_variant['<STR_LIT>'] = coordinates['<STR_LIT>']<EOL>parsed_variant['<STR_LIT>'] = coordinates['<STR_LIT>']<EOL>parsed_variant['<STR_LIT>'] = coordinates['<STR_LIT>']<EOL>parsed_variant['<STR_LIT:end>'] = coordinates['<STR_LIT:end>']<EOL>parsed_variant['<STR_LIT>'] = coordinates['<STR_LIT>']<EOL>parsed_variant['<STR_LIT>'] = coordinates['<STR_LIT>']<EOL>parsed_variant['<STR_LIT>'] = coordinates['<STR_LIT>']<EOL>parsed_variant['<STR_LIT>'] = coordinates['<STR_LIT>']<EOL>rank_score = parse_rank_score(variant.INFO.get('<STR_LIT>', '<STR_LIT>'), genmod_key)<EOL>parsed_variant['<STR_LIT>'] = rank_score or <NUM_LIT:0><EOL>if individual_positions and case['<STR_LIT>']:<EOL><INDENT>parsed_variant['<STR_LIT>'] = parse_genotypes(variant, case['<STR_LIT>'],<EOL>individual_positions)<EOL><DEDENT>else:<EOL><INDENT>parsed_variant['<STR_LIT>'] = []<EOL><DEDENT>compounds = parse_compounds(compound_info=variant.INFO.get('<STR_LIT>'),<EOL>case_id=genmod_key,<EOL>variant_type=variant_type)<EOL>if compounds:<EOL><INDENT>parsed_variant['<STR_LIT>'] = compounds<EOL><DEDENT>genetic_models = parse_genetic_models(variant.INFO.get('<STR_LIT>'), genmod_key)<EOL>if genetic_models:<EOL><INDENT>parsed_variant['<STR_LIT>'] = genetic_models<EOL><DEDENT>azlength = variant.INFO.get('<STR_LIT>')<EOL>if azlength:<EOL><INDENT>parsed_variant['<STR_LIT>'] = int(azlength)<EOL><DEDENT>azqual = variant.INFO.get('<STR_LIT>')<EOL>if azqual:<EOL><INDENT>parsed_variant['<STR_LIT>'] = float(azqual)<EOL><DEDENT>repeat_id = variant.INFO.get('<STR_LIT>')<EOL>if repeat_id:<EOL><INDENT>parsed_variant['<STR_LIT>'] = str(repeat_id)<EOL><DEDENT>repeat_unit = variant.INFO.get('<STR_LIT>')<EOL>if repeat_unit:<EOL><INDENT>parsed_variant['<STR_LIT>'] = str(repeat_unit)<EOL><DEDENT>repeat_ref = variant.INFO.get('<STR_LIT>')<EOL>if repeat_ref:<EOL><INDENT>parsed_variant['<STR_LIT>'] = int(repeat_ref)<EOL><DEDENT>repeat_len = variant.INFO.get('<STR_LIT>')<EOL>if repeat_len:<EOL><INDENT>parsed_variant['<STR_LIT>'] = int(repeat_len)<EOL><DEDENT>str_status = variant.INFO.get('<STR_LIT>')<EOL>if str_status:<EOL><INDENT>parsed_variant['<STR_LIT>'] = str(str_status)<EOL><DEDENT>raw_transcripts = []<EOL>if vep_header:<EOL><INDENT>vep_info = variant.INFO.get('<STR_LIT>')<EOL>if vep_info:<EOL><INDENT>raw_transcripts = (dict(zip(vep_header, transcript_info.split('<STR_LIT:|>')))<EOL>for transcript_info in vep_info.split('<STR_LIT:U+002C>'))<EOL><DEDENT><DEDENT>parsed_transcripts = []<EOL>dbsnp_ids = set()<EOL>cosmic_ids = set()<EOL>for parsed_transcript in parse_transcripts(raw_transcripts, parsed_variant['<STR_LIT>']):<EOL><INDENT>parsed_transcripts.append(parsed_transcript)<EOL>for dbsnp in parsed_transcript.get('<STR_LIT>', []):<EOL><INDENT>dbsnp_ids.add(dbsnp)<EOL><DEDENT>for cosmic in parsed_transcript.get('<STR_LIT>', []):<EOL><INDENT>cosmic_ids.add(cosmic)<EOL><DEDENT><DEDENT>cosmic_tag = variant.INFO.get('<STR_LIT>')<EOL>if cosmic_tag:<EOL><INDENT>cosmic_ids.add(cosmic_tag[<NUM_LIT:4>:])<EOL><DEDENT>if (dbsnp_ids and not parsed_variant['<STR_LIT>']):<EOL><INDENT>parsed_variant['<STR_LIT>'] = '<STR_LIT:;>'.join(dbsnp_ids)<EOL><DEDENT>if cosmic_ids:<EOL><INDENT>parsed_variant['<STR_LIT>'] = list(cosmic_ids)<EOL><DEDENT>gene_info = parse_genes(parsed_transcripts)<EOL>parsed_variant['<STR_LIT>'] = gene_info<EOL>hgnc_ids = set([])<EOL>for gene in parsed_variant['<STR_LIT>']:<EOL><INDENT>hgnc_ids.add(gene['<STR_LIT>'])<EOL><DEDENT>parsed_variant['<STR_LIT>'] = list(hgnc_ids)<EOL>if variant.INFO.get('<STR_LIT>'):<EOL><INDENT>acc = variant.INFO.get('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>acc = variant.INFO.get('<STR_LIT>')<EOL><DEDENT>clnsig_predictions = parse_clnsig(<EOL>acc=acc,<EOL>sig=variant.INFO.get('<STR_LIT>'),<EOL>revstat=variant.INFO.get('<STR_LIT>'),<EOL>transcripts=parsed_transcripts<EOL>)<EOL>if clnsig_predictions:<EOL><INDENT>parsed_variant['<STR_LIT>'] = clnsig_predictions<EOL><DEDENT>frequencies = parse_frequencies(variant, parsed_transcripts)<EOL>parsed_variant['<STR_LIT>'] = frequencies<EOL>local_obs_old = variant.INFO.get('<STR_LIT>')<EOL>if local_obs_old:<EOL><INDENT>parsed_variant['<STR_LIT>'] = int(local_obs_old)<EOL><DEDENT>local_obs_hom_old = variant.INFO.get('<STR_LIT>')<EOL>if local_obs_hom_old:<EOL><INDENT>parsed_variant['<STR_LIT>'] = int(local_obs_hom_old)<EOL><DEDENT>cadd = parse_cadd(variant, parsed_transcripts)<EOL>if cadd:<EOL><INDENT>parsed_variant['<STR_LIT>'] = cadd<EOL><DEDENT>spidex = variant.INFO.get('<STR_LIT>')<EOL>if spidex:<EOL><INDENT>parsed_variant['<STR_LIT>'] = float(spidex)<EOL><DEDENT>parsed_variant['<STR_LIT>'] = parse_conservations(variant)<EOL>parsed_variant['<STR_LIT>'] = parse_callers(variant, category=category)<EOL>rank_result = variant.INFO.get('<STR_LIT>')<EOL>if rank_result:<EOL><INDENT>results = [int(i) for i in rank_result.split('<STR_LIT:|>')]<EOL>parsed_variant['<STR_LIT>'] = dict(zip(rank_results_header, results))<EOL><DEDENT>sv_frequencies = parse_sv_frequencies(variant)<EOL>for key in sv_frequencies:<EOL><INDENT>parsed_variant['<STR_LIT>'][key] = sv_frequencies[key]<EOL><DEDENT>mvl_tag = variant.INFO.get('<STR_LIT>')<EOL>if mvl_tag:<EOL><INDENT>parsed_variant['<STR_LIT>'] = True<EOL><DEDENT>return parsed_variant<EOL>
Return a parsed variant

        Get all the necessary information to build a variant object

    Args:
        variant(cyvcf2.Variant)
        case(dict)
        variant_type(str): 'clinical' or 'research'
        rank_results_header(list)
        vep_header(list)
        individual_positions(dict): Explain what position each individual has
                                    in vcf
        category(str): 'snv', 'sv', 'str' or 'cancer'

    Returns:
        parsed_variant(dict): Parsed variant