Skip to main content

03. Modeling

How to create a disease model.

What is a Jinkō Model?

A Jinkō model is a computational representation of a disease or biological process used to simulate different scenarios and predict outcomes. Models can be used to simulate drug treatments, disease progression, and other conditions in a virtual population. Jinkō supports several formats for models, such as SBML (XML), JSON (internal representation), and XLSX (SimBiology-compliant spreadsheets).

For more information on Jinkō models, check out the guide.


Creating a Computational Model

To create a computational disease model in Jinkō, you can post your model in one of three supported formats:

  • JSON (Jinkō's internal model representation)
  • SBML (XML)
  • XLSX (following SimBiology standards)

The route for posting a model is described in the Jinkō API documentation.

Example request to post a model

You can post a model in the following formats. Below are examples of how to upload each type of model to the Jinkō API.

1. Posting a JSON model (internal Jinkō model representation)

create_model_from_json accepts Jinkō's internal JSON model representation.

import json
from jinko import JinkoClient

client = JinkoClient()

# Load the model
with open("model.json", "r") as f:
model = json.load(f)

created_model = client.create_model_from_json({"model": model}, name="JSON Disease Model")
print(created_model)

2. Posting an SBML model (XML format)

For binary/text formats such as SBML and XLSX, use client.raw_request(...) with the appropriate content type. This is the documented escape hatch for operations the typed client doesn't wrap yet.

Since raw_request returns the raw response body rather than a typed object, look the created model up afterwards (for example with client.iter_models(...)) if you need to rename it or read its sid.

from jinko import JinkoClient

client = JinkoClient()

with open("sbml_model.xml", "rb") as f:
sbml_model = f.read()

client.raw_request(
"POST",
"/core/v2/model_manager/jinko_model",
data=sbml_model,
content_type="application/sbml+xml",
)

For more details on SBML support in Jinkō, refer to the guide.

3. Posting an XLSX model (SimBiology standard)

from jinko import JinkoClient

client = JinkoClient()

with open("simbiology_model.xlsx", "rb") as f:
xlsx_model = f.read()

client.raw_request(
"POST",
"/core/v2/model_manager/jinko_model",
data=xlsx_model,
content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
)

Getting the Computational Model content

Once you have a Model object, either returned from create_model_from_json(...) or fetched with client.get_model(sid), you can read back its content directly:

from jinko import JinkoClient

client = JinkoClient()

model = client.get_model("cm-abc123def456")

model_content = model.content() # Jinkō's internal JSON model representation
solving_options = model.get_solving_options()

These examples show how to create and load a model by posting it to the Jinkō API in different formats. Once you have a Model object, use model.move_to_folder(folder) to place it in a specific folder in your project workspace.

For more details on model creation and editing, refer to the guide on Computational Models.