<jupyter_start><jupyter_text>Libsbml TutorialThis tutorial briefly describes how to access elements of libsbml using a python wrapper called simple_sbml.<jupyter_code>import numpy as np
import os
import sys 

# The following is needed so that python can fined code files
project_dir = os.path.dirname(os.path.dirname(
    os.path.abspath(os.getcwd())))
project_dir = os.path.join(project_dir, "kinetics_validator")
sys.path.insert(0, project_dir)

from src.common.simple_sbml import SimpleSBML
import src.common.simple_sbml as simple_sbml
import src.common.constants as cn
path = os.path.join(cn.TEST_DIR, "common")
path = os.path.join(path, "test_file.xml")
simple = SimpleSBML(path)<jupyter_output><empty_output><jupyter_text>Accessing Reactions, Species, Parameters  Reaction Details - Reactants, Products, Kinetics<jupyter_code>dir(simple)
iterator = simple_sbml.modelIterator(final=10)
for item in iterator:
    model = item.model
    for reaction in model.reactions:
        print("%s: %s" % (reaction.id, str(reaction.kinetic_law.symbols)))
type(reaction)<jupyter_output><empty_output><jupyter_text>Accessing Models in BioModels<jupyter_code>iterator = simple_sbml.modelIterator(final=10)
for item in iterator:
    print("File %s has %d reactions." % (item.filename, len(item.model.reactions)))<jupyter_output>File BIOMD0000000001.xml has 17 reactions.
File BIOMD0000000002.xml has 17 reactions.
File BIOMD0000000003.xml has 7 reactions.
File BIOMD0000000004.xml has 7 reactions.
File BIOMD0000000005.xml has 9 reactions.
File BIOMD0000000006.xml has 3 reactions.
File BIOMD0000000007.xml has 25 reactions.
File BIOMD0000000008.xml has 13 reactions.
File BIOMD0000000009.xml has 20 reactions.
File BIOMD0000000010.xml has 10 reactions.<jupyter_text>Checking for Undefined Values in Kinetics Expressions<jupyter_code>for reaction in simple.reactions:
    print(reaction.kinetic_law)
# Try a single law
law = simple.reactions[0].kinetic_law
law.symbols
# Get the parameter object for these
k0_parameter = simple.getParameter('k0')
k0_parameter.value<jupyter_output><empty_output><jupyter_text>So $k0$ has an assigned value. Now we need a test.<jupyter_code># Testing if a parameter has an assigned value.
is_valid = isinstance(k0_parameter.value, float) and (not np.isnan(k0_parameter.value))
is_valid<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09075342465753425, 'fraction_numerical': 0.0547945205479452, 'mean_word_length': 6.280373831775701, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 11}, 'pii_count': 0, 'substrings_counts': 10, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '43772', 'license': 'MIT', 'n_tokens_mistral': 883, 'n_tokens_neox': 762, 'n_words': 203, 'path': 'notebooks/Libsbml Tutorial.ipynb', 'repo_name': 'mastevb/kinetics_validator', 'size': '2336'}