<jupyter_start><jupyter_text>Accessing Models from the databaseThis example describes how to access models from BioModels and JWS. Further databases could be easily added later on.   BioModels<jupyter_code>import sys
if '../..' not in sys.path:
    sys.path.append('../..')
    
import basico.biomodels as biomodels<jupyter_output><empty_output><jupyter_text>the BioModels REST API allows searching for models, just as one would do in the web interface on http://biomodels.net. So one can search by pathway, species or reactions or submitter / author by just entering them.<jupyter_code>glycolysis_models = biomodels.search_for_model('glycolysis')
for model in glycolysis_models: 
    print ('Id: %s' % model['id'])
    print ('Name: %s' % model['name'])
    print ('Format: %s' % model['format'])
    print ('')<jupyter_output>Id: BIOMD0000000042
Name: Nielsen1998_Glycolysis
Format: SBML

Id: BIOMD0000000051
Name: Chassagnole2002_Carbon_Metabolism
Format: SBML

Id: BIOMD0000000054
Name: Ataullahkhanov1996_Adenylate
Format: SBML

Id: BIOMD0000000061
Name: Hynne2001_Glycolysis
Format: SBML

Id: BIOMD0000000064
Name: Teusink2000_Glycolysis
Format: SBML

Id: BIOMD0000000071
Name: Bakker2001_Glycolysis
Format: SBML

Id: BIOMD0000000172
Name: Pritchard2002_glycolysis
Format: SBML

Id: BIOMD0000000176
Name: Conant2007_WGD_glycolysis_2A3AB
Format: SBML

Id: BIOMD0000000177
Name: Conant2007_glycolysis_2C
Format: SBML

Id: BIOMD0000000206
Name: Wolf2000_Glycolytic_Oscillations
Format: SBML<jupyter_text>to get more information about a particular model, the `get_model_info` function provides basic information. As all the runctions in this module they take either an integer or string biomodels id as parameter<jupyter_code>info = biomodels.get_model_info(206)
print (info['name'])
print (info['description'])<jupyter_output>Wolf2000_Glycolytic_Oscillations
<notes xmlns="http://www.sbml.org/sbml/level2/version3">
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>Model reproduces the dynamics of ATP and NADH as depicted in Fig 4 of the paper.  Model successfully tested on Jarnac and MathSBML.</p>
        <br />
        <p>To the extent possible under law, all copyright and related or neighbouring rights to this encoded model have been dedicated to the public domain worldwide. Please refer to      <a href="http://creativecommons.org/publicdomain/zero/1.0/" title="Creative Commons CC0">CC0 Public Domain Dedication</a>
          for more information.      </p>
      <p>In summary, you are entitled to use this encoded model in absolutely any manner you deem suitable, verbatim, or with modification, alone or embedded it in a larger context, redistribute it, commercially or not, in a restricted way or not.</p>
      <br />
      <p>To cite BioModels Database, please use:      <a href="http://ww[...]<jupyter_text>the model information object also contains the list of file names associated with the entry. To just get that list the convenience function `get_files_for_model` exists. The main document is contained in a sublist called `main`. So the main entry can be retrieved using<jupyter_code>first_entry = info['files']['main'][0]
print ("Main FileName is: '{0}' and has size {1} kb".format(first_entry['name'], first_entry['fileSize']))<jupyter_output>Main FileName is: 'BIOMD0000000206_url.xml' and has size 27693 kb<jupyter_text>to actually get hold of the model itself, you can use the `get_content_for_model` function, that takes a model id, as well as an optional filename. If the filename is not given, the first main content will be chosen automatically. So to download the model of biomodel 206, once could simply call:<jupyter_code>sbml = biomodels.get_content_for_model(206)
print(sbml[:1000])  # just printing the first couple of lines<jupyter_output><?xml version='1.0' encoding='UTF-8' standalone='no'?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version3" level="2" metaid="metaid_0000001" version="3">
  <model id="Wolf2000_Glycolytic_Oscillations" metaid="metaid_0000002" name="Wolf2000_Glycolytic_Oscillations">
    <notes>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>Model reproduces the dynamics of ATP and NADH as depicted in Fig 4 of the paper.  Model successfully tested on Jarnac and MathSBML.</p>
        <br/>
        <p>To the extent possible under law, all copyright and related or neighbouring rights to this encoded model have been dedicated to the public domain worldwide. Please refer to      <a href="http://creativecommons.org/publicdomain/zero/1.0/" title="Creative Commons CC0">CC0 Public Domain Dedication</a>
          for more information.      </p>
      <p>In summary, you are entitled to use this encoded model in absolutely any manner you deem suitable, verbatim, or with modification, alone or embedd[...]<jupyter_text>of course you can simply call `load_biomodel(206)` to load a biomodel into basico.<jupyter_code>biomodels.search_for_model('kummer2000')<jupyter_output><empty_output><jupyter_text>JWS Onlinewe also provide access to models from JWS online.<jupyter_code>import basico.jws_online as jws<jupyter_output><empty_output><jupyter_text>with `get_all_models` you would get a list of all the models in JWS online. To search for models, you have 2 options. One is to search for models by species. For example to search for all models involving 'atp'<jupyter_code>atp_models = jws.get_models_for_species('atp')
for model in atp_models: 
    print(model['slug'])<jupyter_output>achcar1
achcar10
achcar11
achcar12
achcar13
achcar14
achcar2
achcar3
achcar4
achcar5
achcar6
achcar7
achcar8
achcar9
albert1
arnold10
arnold10-2
arnold11
arnold6
arnold7
arnold8
arnold9
assmus
bali
bier2
bradshaw
bray2
bruggeman1
bulik1
bulik2
bulik3
chance1
chassagnole1
chassagnole3
conant1
conant2
curto1
dano1
dano2
dano3
dupreez1
dupreez2
dupreez3
dupreez4
dupreez5
dupreez6
dupreez7
fribourg1
fribourg2
fridlyand1
galazzo1
gustavsson1
gustavsson2
gustavsson3
gustavsson4
gustavsson5
hald
heinrich
hoefnagel1
hoefnagel2
hoefnagel_mixedacid
holzhutter
hynne
jamshidi
jiang1
kerkhovena
kerkhovenc
kolmeisky1
kongas1
kouril2
kouril3
kouril4
kouril6
kouril7
kouril8
kouril9
lambeth
levering1
levering2
maher1
marinhernandez1
marinhernandez2
marinhernandez3
mayya1
mosca1
mulquiney
mulquiney1
mulquiney2
nazaret1
neves1
nielsen
nishio1
olah
orth1
penkler1
penkler2
penkler2aa
poolman
pritchard1
proctor1
rohwer1
rovers1
saavedra
sengupta1
smallbone0
smallbone1
smallbone10
smallbone11
smallbone12
sma[...]<jupyter_text>or you could get the models for a specific reaction for example, all models involving 'pfk' would be:<jupyter_code>pfk_models = jws.get_models_for_reaction('pfk')
for model in pfk_models:
    print(model['slug'])<jupyter_output>achcar1
achcar10
achcar11
achcar12
achcar13
achcar14
achcar2
achcar3
achcar4
achcar5
achcar6
achcar7
achcar8
achcar9
albert1
chassagnole2
conant1
conant2
dupreez1
dupreez2
dupreez3
dupreez4
dupreez5
dupreez6
dupreez7
gustavsson1
gustavsson2
gustavsson3
gustavsson4
gustavsson5
hald
kerkhovena
kerkhovenc
levering1
levering2
machado1
marinhernandez1
marinhernandez2
marinhernandez3
mosca1
mulquiney
mulquiney1
mulquiney2
orth1
penkler1
penkler2
penkler2aa
pritchard1
ralser1
smallbone0
smallbone1
smallbone10
smallbone11
smallbone12
smallbone13
smallbone14
smallbone15
smallbone16
smallbone17
smallbone18
smallbone2
smallbone3
smallbone4
smallbone5
smallbone6
smallbone7
smallbone8
smallbone9
vanniekerk1<jupyter_text>for each of these ids, you can get the manuscript, to find out what the model is all about, or the sbml model itself<jupyter_code>manuscript = jws.get_manuscript('wolf')
print(manuscript['title'])
print(manuscript['abstract'])
sbml = jws.get_sbml_model('wolf')
print(sbml[:1000])<jupyter_output><?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
  <model id="wolf" name="wolf">
    <listOfCompartments>
      <compartment metaid="metaid_0" sboTerm="SBO:0000410" id="default_compartment" spatialDimensions="3" size="1" constant="true"/>
    </listOfCompartments>
    <listOfSpecies>
      <species metaid="metaid_1" id="at" name="ATP" compartment="default_compartment" initialConcentration="2" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false">
        <annotation>
          <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
            <rdf:Description rdf:about="#metaid_1">
              <bqbiol:is>
                <rdf:Bag>
       [...]
{'fraction_non_alphanumeric': 0.08548571428571429, 'fraction_numerical': 0.0528, 'mean_word_length': 5.52572706935123, 'pattern_counts': {'":': 0, '<': 74, '<?xml version=': 2, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 7, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 11, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '356390', 'license': 'Artistic-2.0', 'n_tokens_mistral': 3375, 'n_tokens_neox': 3046, 'n_words': 860, 'path': 'docs/notebooks/Accessing_Models_from_Databases.ipynb', 'repo_name': 'thepritam/basico', 'size': '8750'}