<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Simulating Deletions
Step1:  Single Deletions
Perform all single gene deletions on a model
Step2:  These can also be done for only a subset of genes
Step3:  This can also be done for reactions
Step4:  Double Deletions
Double deletions run in a similar way. Passing in return_frame=True will cause them to format the results as a pandas Dataframe
Step5:  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.
Step6:  Double deletions can also be run for reactions
<ASSISTANT_TASK:>
Python Code:
import pandas
from time import time
import cobra.test
from cobra.flux_analysis import \
    single_gene_deletion, single_reaction_deletion, \
    double_gene_deletion, double_reaction_deletion
cobra_model = cobra.test.create_test_model("textbook")
ecoli_model = cobra.test.create_test_model("ecoli")
Explanation: Simulating Deletions
End of explanation
growth_rates, statuses = single_gene_deletion(cobra_model)
Explanation: Single Deletions
Perform all single gene deletions on a model
End of explanation
gr, st = single_gene_deletion(cobra_model,
                              cobra_model.genes[:20])
pandas.DataFrame.from_dict({"growth_rates": gr,
                            "status": st})
Explanation: These can also be done for only a subset of genes
End of explanation
gr, st = single_reaction_deletion(cobra_model,
                                  cobra_model.reactions[:20])
pandas.DataFrame.from_dict({"growth_rates": gr,
                            "status": st})
Explanation: This can also be done for reactions
End of explanation
double_gene_deletion(cobra_model, cobra_model.genes[-5:],
                     return_frame=True)
Explanation: Double Deletions
Double deletions run in a similar way. Passing in return_frame=True will cause them to format the results as a pandas Dataframe
End of explanation
start = time()  # start timer()
double_gene_deletion(ecoli_model, ecoli_model.genes[:200],
                     number_of_processes=2)
t1 = time() - start
print("Double gene deletions for 200 genes completed in "
      "%.2f sec with 2 cores" % t1)
start = time()  # start timer()
double_gene_deletion(ecoli_model, ecoli_model.genes[:200],
                     number_of_processes=1)
t2 = time() - start
print("Double gene deletions for 200 genes completed in "
      "%.2f sec with 1 core" % t2)
print("Speedup of %.2fx" % (t2 / t1))
Explanation: 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.
End of explanation
double_reaction_deletion(cobra_model,
                         cobra_model.reactions[2:7],
                         return_frame=True)
Explanation: Double deletions can also be run for reactions
End of explanation
<END_TASK>