In [1]:
import pandas
from time import time
import cobra.test
cobra_model = cobra.test.create_test_model("textbook")
ecoli_model = cobra.test.create_test_model("ecoli")
Perform all single gene deletions on a model
In [2]:
growth_rates, statuses = cobra.flux_analysis.single_gene_deletion(cobra_model)
These can also be done for only a subset of genes
In [3]:
growth_rates, statuses = cobra.flux_analysis.single_gene_deletion(cobra_model, cobra_model.genes[:20])
pandas.DataFrame.from_dict({"growth_rates": growth_rates, "status": statuses})
Out[3]:
This can also be done for reactions
In [4]:
growth_rates, statuses = cobra.flux_analysis.single_reaction_deletion(cobra_model, cobra_model.reactions[:20])
pandas.DataFrame.from_dict({"growth_rates": growth_rates, "status": statuses})
Out[4]:
In [5]:
cobra.flux_analysis.double_gene_deletion(cobra_model, cobra_model.genes[-10:], return_frame=True)
Out[5]:
By default, the double deletion function will automatically use multiprocessing, splitting the task over up to 4 cores if they are available. The number of cores can be manually sepcified as well. Setting use of a single core will disable use of the multiprocessing library, which often aids debuggging.
In [6]:
start = time() # start timer()
cobra.flux_analysis.double_gene_deletion(ecoli_model, ecoli_model.genes[:100], number_of_processes=2)
t1 = time() - start
print("Double gene deletions for 100 genes completed in %.2f sec with 2 cores" % t1)
start = time() # start timer()
cobra.flux_analysis.double_gene_deletion(ecoli_model, ecoli_model.genes[:100], number_of_processes=1)
t2 = time() - start
print("Double gene deletions for 100 genes completed in %.2f sec with 1 core" % t2)
print("Speedup of %.2fx" % (t2/t1))
Double deletions can also be run for reactions
In [7]:
cobra.flux_analysis.double_reaction_deletion(cobra_model, cobra_model.reactions[:10], return_frame=True)
Out[7]: