{
"cells": [
{
"cell_type": "markdown",
"id": "f5927379-ee39-47c4-b92c-c19f74bded5d",
"metadata": {},
"source": [
"## Drawing CHADA tables as a plantuml json diagram from a single json or yaml file"
]
},
{
"cell_type": "markdown",
"id": "b0e67204-18a2-4a3f-a5f4-ff0b89d4c50f",
"metadata": {},
"source": [
"In this example we will see how to use convenience functions in `mochada_kit/tables` to help us draw [plantuml json diagrams](https://plantuml.com/json) showing CHADA tables from a single [json](https://en.wikipedia.org/wiki/JSON) or [yaml](https://en.wikipedia.org/wiki/YAML) file as input."
]
},
{
"cell_type": "markdown",
"id": "9b4dfbe5-e7ce-4327-a9d0-9e94cf3fccdd",
"metadata": {},
"source": [
"#### 1. Why should we do this?"
]
},
{
"cell_type": "markdown",
"id": "f8256c2a-bab4-4da5-a381-20e6f7f936bb",
"metadata": {},
"source": [
"- CHADA tables can be prepared using a word processor (*e.g.* LibreOffice Writer or Microsoft Word). Any formatting can be applied and we can export the resulting document as a pdf. We could even make a template using whatever colour scheme we choose, in order to speed up the process.\n",
"- Both the LibreOffice Open Document Text (.odt) and Microsoft Word (.docx) formats are now openly described and have ISO standards. This means that they are both machine readable. This is desirable for interaction between CHADA tables and the development of ontologies.\n",
"\n",
"**OK, so why should we draw CHADA tables with plantuml from json/yaml?**\n",
"\n",
"1. [json](https://en.wikipedia.org/wiki/JSON) and [yaml](https://en.wikipedia.org/wiki/YAML) are very simple text file formats, which are arguably easier to parse than .odt or .docx. This may simplify the interaction with ontology development. `json` is very well established for data exchange but has a slightly more complex structure than `yaml`, which is designed to be easy to read and write for humans.\n",
"2. using the functions in `mochada_kit/tables` we can:\n",
" - apply a theme to the json diagram so that the appearance of the tables is similar to our workflow diagram\n",
" - make an overview of all tables joined to a \"contents\" element\n",
" - make several diagrams in which one of the main tables is joined to the \"contents\" element and the diagram contains hyperlinks so that you can easily switch between different tables. This extra interactivity may be more attractive for data repositories rather than a static pdf or document format.\n",
" - make individual tables without a \"contents\" element to insert into a document report. There is a dedicated theme for this where the `MaximumWidth` parameter for json diagrams has been increased to fit the table better to the width of A4 paper.\n",
" \n",
"Let's have a look at these options. \n",
"\n",
"First, we import the necessary modules:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "dde4a042-f6a8-412f-a2cb-d40d41c72a57",
"metadata": {},
"outputs": [],
"source": [
"import pathlib\n",
"\n",
"import mochada_kit.running as mr\n",
"import mochada_kit.tables as mt"
]
},
{
"cell_type": "markdown",
"id": "96bf2dee-a4bb-4311-bb75-acbe611f8b1c",
"metadata": {},
"source": [
"
\n",
"\n",
"#### 2. Plotting all CHADA tables joined to a contents element"
]
},
{
"cell_type": "markdown",
"id": "bd045d29-d895-454e-962b-39d7d3e24b27",
"metadata": {},
"source": [
"**2a Templates**\n",
"\n",
"The folder `mochada_kit/templates` contains `json` and equivalent `yaml` files as templates for the CHADA tables. The files `chada_tables_template.json` and `chada_tables_template.yaml` contain all the headings in the tables but only empty strings for the content. The files `chada_tables_template_tips.json` and `chada_tables_template_tips.yaml` contain all the headings in the tables and for each heading there is some text giving tips about how to fill in the content. Whether you choose to start from a `json` file or a `yaml` file, `mochada_kit` will plot the tables into a [plantuml json diagram](https://plantuml.com/json). Let's see how to do this."
]
},
{
"cell_type": "markdown",
"id": "8c9ca3a4-8d2c-40ea-a9b8-5bf246572d95",
"metadata": {},
"source": [
"