def write_ssms(variants, outfn):
    _stringify = (lambda A: ','.join([str(V) for V in A]))
    mu_r = 0.999
    cols = ('id', 'gene', 'a', 'd', 'mu_r', 'mu_v')
    with open(outfn, 'w') as outf:
        print(*cols, sep='\t', file=outf)
        for V in variants.values():
            assert (len(set(V['omega_v'])) == 1)
            variant = {'id': ('s%s' % int(V['id'][1:])), 'gene': V['name'], 'a': _stringify(V['ref_reads']), 'd': _stringify(V['total_reads']), 'mu_r': mu_r, 'mu_v': np.mean((1 - V['omega_v']))}
            print(*[variant[K] for K in cols], sep='\t', file=outf)
def write_ssms(variants, outfn):
    _stringify = (lambda A: ','.join([str(V) for V in A]))
    mu_r = 0.999
    cols = ('id', 'gene', 'a', 'd', 'mu_r', 'mu_v')
    with open(outfn, 'w') as outf:
        print(*cols, sep='\t', file=outf)
        for V in variants.values():
            assert (len(set(V['omega_v'])) == 1)
            variant = {'id': ('s%s' % int(V['id'][1:])), 'gene': V['name'], 'a': _stringify(V['ref_reads']), 'd': _stringify(V['total_reads']), 'mu_r': mu_r, 'mu_v': np.mean((1 - V['omega_v']))}
            print(*[variant[K] for K in cols], sep='\t', file=outf)