<jupyter_start><jupyter_text>IntroductionJust for general purposes, it would be good to add SBO annotations to the metabolites, reactions and genes.THis notebook will shortly cover that. For transport reactions, add the SBO annotation: SBO:0000185For all metabolic reactions, add the SBO annotation:SBO:0000176Biomass reaction should be annotated with: SBO:0000629For all 'simple chemical' metabolites, the SBO:0000247 term should be annotated.for all genes, SBO:0000243 should be added. NOTE: here this should be repeated when all the proper genes are added to the model.<jupyter_code>import cobra
import pandas as pd
import cameo
model = cobra.io.read_sbml_model("../model/p-thermo.xml")
#now for all transport reactions
#first filter for all transport reactions
transport_reactions = []
for reaction in model.reactions:
    if reaction.id[:2] == "T_":
        transport_reactions.append(reaction)
    else: 
        continue
len(transport_reactions)
#then add the sbo annotation to all transport reactions
for reaction in transport_reactions:
    reaction.annotation["sbo"] = "SBO:0000185"
#Save & commit
cobra.io.write_sbml_model(model,"../model/p-thermo.xml")
#Annotating all metabolic reactions
for reaction in model.reactions:
    if reaction in transport_reactions:
        continue
    elif reaction.id[:3] == "EX_":
        continue
    else: 
        reaction.annotation["sbo"] = "SBO:0000176"
#Save & commit
cobra.io.write_sbml_model(model,"../model/p-thermo.xml")
# do the biomass reaction, this is straightforward
model.reactions.biomass.annotation["sbo"] = "SBO:0000629" 
#Save & commit
cobra.io.write_sbml_model(model,"../model/p-thermo.xml")
# adding SBO term for all simple chemicals
for met in model.metabolites:
    met.annotation["sbo"] = "SBO:0000247"
# then add sbo term for all genes
for genes in model.genes:
    genes.annotation["sbo"] = "SBO:0000243"
cobra.io.write_sbml_model(model,"..\model\p-thermo.xml")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09979633401221996, 'fraction_numerical': 0.03665987780040733, 'mean_word_length': 4.813609467455621, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '392617', 'license': 'Apache-2.0', 'n_tokens_mistral': 674, 'n_tokens_neox': 600, 'n_words': 188, 'path': 'notebooks/6. Adding SBO annotations to metabolites & reactions.ipynb', 'repo_name': 'biosustain/p-thermo', 'size': '1964'}