Custom Data Types
Fermentation Entities
For fermentation data registration, a more developed data model is desirable as variables such as plasmid ID and growth conditions are important and these are not covered by the default entities in Scifeon.
The fermentation app expands existing entities to accommodate the wanted data structures.
Custom Attributes
The new variables, such as growth condition, are made as template objects in a json file.
[
{
"eClass": "Template",
"name": "StrainAttributeGrowthConditions",
"type": "Field",
"status": "Active",
"content": {
"eClass": "CellClone",
"column": {
"name": "attributes.growthConditions",
"type": "string",
"form": {
"label": "Growth Conditions"
}
}
}
},
...
The above object defines a new field on the CellClone class. The field describes the growth conditions of the cellclone and should be a string (text) element.
Note that no new rows are made in the actual database. Instead, the data is saved as a json string in the "attributes" row.
Bootstrapping the Elements
To make sure the new elements are initialized every time Scifeon is run, a bootstrapper plugin is written.
The bootstrapper plugin requires a bootstrapper decorator.
import { PLUGIN_TYPE, scifeonPlugin } from '@scifeon/plugins';
@scifeonPlugin({
name: "bootstrapper",
type: PLUGIN_TYPE.BOOTSTRAPPER,
})
The type property establishes the script as a bootstrapper and makes sure the script is run whenever Scifeon is.
The bootstrapper also allows us to directly edit the attributes in Scifeon using the field editor.
this.pluginManager.add(KVPJsonFieldPanel, [PLUGIN_TYPE.JSON_FIELD_EDITOR], {
eClass: 'CellClone',
entityType: 'Strain',
field: 'attributes',
columns: require('../seed/attribute-fields-strain.json').map(t => {
const column = JSON.parse(JSON.stringify(t.content.column));
column.name = column.name.replace(/attributes\./ig, '');
return column;
})
});
Each attribute is parsed from the json file to individual columns of the entity. These can then be edited in the field editor or searched for in the database browser.
for (const template of require('../seed/attribute-fields-strain.json')) {
this.pluginManager.add(ListColumnOptionsPlugin, [PLUGIN_TYPE.LIST_COLUMN], {
eClass: 'CellClone',
column: template.content.column
});
}