03. Modeling
How to create a disease model.
What is a Jinko Model?
A Jinko 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. Jinko supports several formats for models, such as SBML (XML), JSON (internal representation), and XLSX (SimBiology-compliant spreadsheets).
For more information on Jinko models, check out the guide.
Creating a Computational Model
To create a computational disease model in Jinko, you can post your model in one of three supported formats:
- JSON (Jinko's internal model representation)
- SBML (XML)
- XLSX (following SimBiology standards)
The route for posting a model is described in the Jinko 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 Jinko API.
1. Posting a JSON Model (Internal Jinko Model Representation)
create_model_from_json accepts Jinko'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 Jinko, 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() # Jinko'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 Jinko 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.