{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Frameworks\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The _framework_ is an object that represents the transition structure of the model in Atomica. It contains a listing of all of the compartments, characteristics, and parameters, as well as the transition matrix that links parameters with transitions between compartments. It does not contain a specification of the populations, because these are entered in the databook. This page assumes familiarity with basic Atomica concepts (e.g., compartments, characteristics, parameters, populations) and is intended as technical documentation on the implementation of the framework." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import atomica as at" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A 'framework' exists in two forms:\n", "\n", "- The 'framework file' which is an `xlsx` file, such as `framework_tb.xlsx`\n", "- A Python object, `ProjectFramework`, which is stored in `Project.framework` and is constructed by parsing the framework file\n", "\n", "On the user input side, users of Atomica implementing new cascade models etc. will typically be modifying the framework file. On the development size, Python code can generally expect to interact with the `ProjectFramework` object. A key goal is to make the `ProjectFramework` as flexible as possible to accommodate changes in the Excel file, to maximize the extent to which changes in a project can be performed in the framework file without needing complex changes in the codebase." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `ProjectFramework` basics\n", "\n", "The `ProjectFramework` class stores a parsed, validated representation of the framework file. The framework file consists of a set of sheets, with content on each of the sheets. An example from the TB framework is shown below\n", "\n", "![framework-overview-example](assets/framework_overview_example.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we can see that there are a number of worksheets in the file ('Databook Pages', 'Compartments', 'Transitions',...) and there is of course content on each sheet. \n", "\n", "The `ProjectFramework` contains a member variable, `sheets`, which is an odict where the key is the sheet name and the value is a list of Pandas `DataFrames` that contains all of the tables on that sheet. A table is defined as a rectangular range of cells terminated by an empty row." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "F = at.ProjectFramework(at.LIBRARY_PATH / \"tb_framework.xlsx\")\n", "F.sheets.keys()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "