Skip to content

Instantly share code, notes, and snippets.

@max-l
Last active February 12, 2021 12:14
Show Gist options
  • Save max-l/4b4e62950818ec08c11ca746e4cc3192 to your computer and use it in GitHub Desktop.
Save max-l/4b4e62950818ec08c11ca746e4cc3192 to your computer and use it in GitHub Desktop.
def group_snp():
for gene, grp in itt.groupby(gene_snps_grp, key=lambda x: x['gene']):
if gene in gene_lenghts:
yield gene, len(list(grp)) * 1000 / gene_lenghts[gene]
# possibilité 1: création de dictinnaire à partir d'un générateur de tuple2
gene_snp_rate = dict(group_snp())
# possibilité 1: bouclage avec for sur le générateur
for gene, cnt in group_snp():
print("{} --> {}".format(gene, cnt))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment