<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:  Knocking out single genes and reactions
A commonly asked question when analyzing metabolic models is what will happen if a certain reaction was not allowed to have any flux at all. This can tested using cobrapy by
Step2:  For evaluating genetic manipulation strategies, it is more interesting to examine what happens if given genes are knocked out as doing so can affect no reactions in case of redundancy, or more reactions if gene when is participating in more than one reaction.
Step3:  Single Deletions
Perform all single gene deletions on a model
Step4:  These can also be done for only a subset of genes
Step5:  This can also be done for reactions
Step6:  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.
Step7:  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 specified as well. Setting use of a single core will disable use of the multiprocessing library, which often aids debugging.
Step8:  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
print('complete model: ', cobra_model.optimize())
with cobra_model:
    cobra_model.reactions.PFK.knock_out()
    print('pfk knocked out: ', cobra_model.optimize())
Explanation: Knocking out single genes and reactions
A commonly asked question when analyzing metabolic models is what will happen if a certain reaction was not allowed to have any flux at all. This can tested using cobrapy by
End of explanation
print('complete model: ', cobra_model.optimize())
with cobra_model:
    cobra_model.genes.b1723.knock_out()
    print('pfkA knocked out: ', cobra_model.optimize())
    cobra_model.genes.b3916.knock_out()
    print('pfkB knocked out: ', cobra_model.optimize())
Explanation: For evaluating genetic manipulation strategies, it is more interesting to examine what happens if given genes are knocked out as doing so can affect no reactions in case of redundancy, or more reactions if gene when is participating in more than one reaction.
End of explanation
deletion_results = single_gene_deletion(cobra_model)
Explanation: Single Deletions
Perform all single gene deletions on a model
End of explanation
single_gene_deletion(cobra_model, cobra_model.genes[:20])
Explanation: These can also be done for only a subset of genes
End of explanation
single_reaction_deletion(cobra_model, cobra_model.reactions[:20])
Explanation: This can also be done for reactions
End of explanation
double_gene_deletion(
    cobra_model, cobra_model.genes[-5:], return_frame=True).round(4)
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[:300], 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[:300], 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 specified as well. Setting use of a single core will disable use of the multiprocessing library, which often aids debugging.
End of explanation
double_reaction_deletion(
    cobra_model, cobra_model.reactions[2:7], return_frame=True).round(4)
Explanation: Double deletions can also be run for reactions.
End of explanation
<END_TASK>