def _summarize_by_gene_and_sample(args, query):
    gq = GeminiQuery.GeminiQuery(args.db)
    gq.run(query, show_variant_samples=True)
    burden = defaultdict(Counter)
    for row in gq:
        gene_name = row['gene']
        if not gene_name:
            continue
        new_counts = Counter(row["het_samples"])
        # Counter can't do scalar multiplication
        new_counts = new_counts + Counter(row["hom_alt_samples"])
        new_counts = new_counts + Counter(row["hom_alt_samples"])

        del new_counts['']
        burden[gene_name] += new_counts

    df = DataFrame({})
    for gene_name, counts in burden.items():
        df = df.append(DataFrame(counts, columns=counts.keys(),
                                 index=[gene_name]))
    df = df.replace(np.NaN, 0)
    df.to_csv(sys.stdout, float_format="%d", sep="\t", index_label='gene')
dataset/ETHPy150Open arq5x/gemini/gemini/tool_burden_tests.py/_summarize_by_gene_and_sample/original