def genomic_features(store, case_obj, sample_name, genes_only):
g_features = []<EOL>build = case_obj['<STR_LIT>']<EOL>if not build in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>build = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>build = '<STR_LIT>'+build<EOL><DEDENT>individual_pinned_snvs = list(store.sample_variants( variants=case_obj.get('<STR_LIT>'),<EOL>sample_name=sample_name))<EOL>gene_set = set()<EOL>for var in individual_pinned_snvs:<EOL><INDENT>hgnc_genes = var.get('<STR_LIT>')<EOL>if not hgnc_genes:<EOL><INDENT>continue<EOL><DEDENT>for hgnc_id in hgnc_genes:<EOL><INDENT>gene_obj = store.hgnc_gene(hgnc_id)<EOL>if not gene_obj:<EOL><INDENT>continue<EOL><DEDENT>g_feature = {<EOL>'<STR_LIT>': {'<STR_LIT:id>': gene_obj.get('<STR_LIT>')}<EOL>}<EOL>if genes_only and not hgnc_id in gene_set: <EOL><INDENT>gene_set.add(hgnc_id)<EOL>g_features.append(g_feature)<EOL>continue<EOL><DEDENT>g_feature['<STR_LIT>'] = {<EOL>'<STR_LIT>' : var['<STR_LIT>'],<EOL>'<STR_LIT:start>' : var['<STR_LIT>'],<EOL>'<STR_LIT:end>' : var['<STR_LIT:end>'],<EOL>'<STR_LIT>' : build,<EOL>'<STR_LIT>' :var['<STR_LIT>'],<EOL>'<STR_LIT>' : var['<STR_LIT>'],<EOL>'<STR_LIT>' : True<EOL>}<EOL>zygosity = None<EOL>zygosities = var['<STR_LIT>'] <EOL>for zyg in zygosities:<EOL><INDENT>if zyg.get('<STR_LIT>') == sample_name: <EOL><INDENT>zygosity = zyg['<STR_LIT>'].count('<STR_LIT:1>') + zyg['<STR_LIT>'].count('<STR_LIT:2>')<EOL><DEDENT><DEDENT>g_feature['<STR_LIT>'] = zygosity<EOL>g_features.append(g_feature)<EOL><DEDENT><DEDENT>return g_features<EOL>
Extract and parse matchmaker-like genomic features from pinned variants
        of a patient
    Args:
        store(MongoAdapter) : connection to the database
        case_obj(dict): a scout case object
        sample_name(str): sample display name
        genes_only(bool): if True only gene names will be included in genomic features

    Returns:
        g_features(list): a list of genomic feature objects that looks like this:
            [
              {
                "gene": {
                  "id": "LIMS2"
                },
                "variant": {
                  "alternateBases": "C",
                  "assembly": "GRCh37",
                  "end": 128412081,
                  "referenceBases": "G",
                  "referenceName": "2",
                  "start": 128412080
                },
                "zygosity": 1
              },
              ....
            ]