Skip to content

Instantly share code, notes, and snippets.

@cdanielmachado
Created November 12, 2018 12:19
Show Gist options
  • Save cdanielmachado/826d8199b5e2019c4389d7295504f238 to your computer and use it in GitHub Desktop.
Save cdanielmachado/826d8199b5e2019c4389d7295504f238 to your computer and use it in GitHub Desktop.
gene - reaction - metabolite associations
from framed import load_cbmodel
import pandas as pd
model = load_cbmodel("iML1515.xml.gz", flavor="bigg")
gene2met = [(g_id, r_id, m_id) for r_id, rxn in model.reactions.items()
for g_id in rxn.get_associated_genes()
for m_id in rxn.stoichiometry]
df = pd.DataFrame(gene2met, columns=["metabolites", "reactions", "genes"])
df.to_csv("associations.tsv", sep="\t", index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment