<jupyter_start><jupyter_text>Prerequisites 1) cobrapyOne can install cobrapy (https://cobrapy.readthedocs.io/en/latest/)through Anaconda: conda install -c bioconda cobraORthrough pip: pip install cobraMore infor available here: https://github.com/opencobra/cobrapy 2) iML1515.jsonIt is the latest E. coli Genome scale metabolic model. This can be obtained through Bigg database http://bigg.ucsd.edu/ 3) Gurobi solverhttps://www.gurobi.com/downloads/gurobi-software/<jupyter_code>from AuxoFind import *
import os
directory = os.getcwd()
model = cobra.io.load_json_model('%s/iML1515.json'%directory) # replace with iML1515 directory<jupyter_output>Academic license - for non-commercial use only<jupyter_text>**You can get the conditionally essential genes (CEGs) for a model using**<jupyter_code>M9_medium = {'EX_h2o_e', 'EX_mn2_e', 'EX_glc__D_e', 'EX_ni2_e', 'EX_sel_e', 'EX_o2_e', 'EX_cu2_e', 'EX_pi_e', 'EX_h_e', 'EX_mobd_e', 
             'EX_tungs_e', 'EX_na1_e', 'EX_zn2_e', 'EX_ca2_e', 'EX_cl_e', 'EX_fe3_e', 'EX_so4_e', 'EX_slnt_e', 'EX_mg2_e', 'EX_co2_e',
             'EX_k_e', 'EX_nh4_e', 'EX_fe2_e', 'EX_cobalt2_e'}
CEGs = get_CEGs(model, growth_medium = M9_medium)
print('The model predicts %d conditionally essential genes in M9+glucose minimal medium.'%(len(CEGs)))<jupyter_output>The model predicts 109 conditionally essential genes in M9+glucose minimal medium.<jupyter_text>**Assuming you have a list of missing/disrupted genes which you can obtain via any method of your choice**<jupyter_code>missing_genes = {'b2677', 'b0243', 'b1262'}
auxotrophies = get_auxotrophies(model, missing_genes, method = 'single_search')

auxotrophies<jupyter_output>Number of solutions: 50<jupyter_text>**Notice the warning, one of the genes (b2677) is not a CEG. If you remove the gene from the list of missing CEGs, the warning disappears**<jupyter_code>missing_genes = {'b0243', 'b1262'}
auxotrophies = get_auxotrophies(model, missing_genes, method = 'single_search')

auxotrophies<jupyter_output>Number of solutions: 50
Number of solutions: 50<jupyter_text>**The function returns a dictionary mapping each gene to the nutrients that the model needs to simulate growth.For the single_search option, a list of all solutions is provided. When there are two nutrients that are simulatenous required, they are featured within the same list, When two solutions are equivalent, they are featured in different lists. Here's another way to present the results**<jupyter_code>auxotrophies_t = {model.genes.get_by_id(gene).name: ' OR '.join([' AND '.join([model.metabolites.get_by_id(rx.replace('EX_','')).name for rx in rx_l]) for rx_l in rxs]) for gene, rxs in auxotrophies.items()}
auxotrophies_t<jupyter_output><empty_output><jupyter_text>**What if you're only interested in getting one single solution? In that case just remove the method setting and it will return to the default (optimal_solution)**<jupyter_code>auxotrophies = get_auxotrophies(model, missing_genes)

auxotrophies<jupyter_output><empty_output><jupyter_text>**You can also add a list of nutrients that you would like to exclude from the solution. For example L-prolinylglycine might not provide sufficient resolution, and you might prefer to know whether the strain is auxotrophic for L-proline specifically or L-glycine.**<jupyter_code>auxotrophies = get_auxotrophies(model, missing_genes, method = 'single_search', force_to_zero = ['EX_progly_e'])
auxotrophies_t = {model.genes.get_by_id(gene).name: ' OR '.join([' AND '.join([model.metabolites.get_by_id(rx.replace('EX_','')).name for rx in rx_l]) for rx_l in rxs]) for gene, rxs in auxotrophies.items()}
auxotrophies_t<jupyter_output>Number of solutions: 50
Number of solutions: 50<jupyter_text>**type ?function_name to get specifics about function settings**<jupyter_code>?get_auxotrophies<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10502997133176961, 'fraction_numerical': 0.01850403961428199, 'mean_word_length': 6.722334004024145, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '518949', 'license': 'MIT', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1304, 'n_words': 377, 'path': 'example_notebook.ipynb', 'repo_name': 'yseif/AuxoFind', 'size': '3837'}