| 1 | = Adding data types = |
| 2 | Adding of data types is done by |
| 3 | * editing 'xgap_db.xml' to add the data type |
| 4 | * editing 'xgap_ui.xml' to add it the XGAP user interface. |
| 5 | * subsequently running the generator as described in [http://www.molgenis.org/wiki/MolgenisGeneratorBasics MolgenisGeneratorBasics]. |
| 6 | * and finally updating the database ( |
| 7 | |
| 8 | WARNING: don't run the MolgenisUpdateDatabase if you want to keep data in the database! Instead copy/paste relevant SQL from the /generated/sql/create_tables.sql file! |
| 9 | |
| 10 | Below two examples are shown. |
| 11 | |
| 12 | == Example 1 == |
| 13 | |
| 14 | We have sequencing data for bacterial artificial chromosome (BAC) clones. This is something measured on a bacteria, so it's a trait. Since the fragments have a genetical location, we would like to have this annotated as well. |
| 15 | |
| 16 | We add a new entity named "Clone" to xgap_db.xml with a proper description. We 'add' this to the possible traits by 'extending' the Trait datatype. Lastly, we reuse the notation of genetic location by adding 'Locus' information using 'implements'. As a result Clone will have all properties of Locus as well as Trait. |
| 17 | |
| 18 | {{{ |
| 19 | #!xml |
| 20 | <entity name="Clone" extends="Trait" implements="Locus"> |
| 21 | <description> |
| 22 | BAC clone fragment. |
| 23 | </description> |
| 24 | </entity> |
| 25 | }}} |
| 26 | |
| 27 | Then add this new entity to the user interface by adding under the 'Trait' menu: |
| 28 | {{{ |
| 29 | #!xml |
| 30 | <form name="Clones" entity="Clone"/> |
| 31 | }}} |
| 32 | |
| 33 | Finally we run the generator and update the database as described above, i.e., in /generated/sql/create_tables.sql copy the {{{create table Clone}}} and paste it into the mysql prompt. |
| 34 | == Example 2 == |
| 35 | |
| 36 | We want to 'wrap' datamatrices as a QTL dataset where we annotate a specific matrix to contain 'genotypes' and another matrix to contain 'phenotypes'. These datasets do not need names. |
| 37 | |
| 38 | We add an entity named "QTLDataSet" to xgap_db.xml with a proper description. We do want the matrix to fit into the XGAP datastructure but do not need to name it, therefore we extend 'Describable' which gives the record a unique ID, but not 'Identifiable' which would add a 'name' field. Then we add two fields with are both crossreferences to 'Data' by "id", though the label will be "name". |
| 39 | |
| 40 | {{{ |
| 41 | #!xml |
| 42 | <entity name="QTLDataSet" extends="Describable"> |
| 43 | <description>The starting point of QTL analysis.</description> |
| 44 | <field name="Genotypes" nillable="true" type="xref" xref_entity="Data" xref_field="id" xref_label="name" /> |
| 45 | <field name="Phenotypes" nillable="true" type="mref" xref_entity="Data" xref_field="id" xref_label="name" /> |
| 46 | </entity> |
| 47 | }}} |
| 48 | |
| 49 | Then we add it to the user interface by adding to xgap_ui.xml at a proper location: |
| 50 | {{{ |
| 51 | #!xml |
| 52 | <form name="QTLDataSet" entity="QTLDataSet"/> |
| 53 | }}} |
| 54 | |
| 55 | Finally we run the generator and update the database as described above, i.e., in /generated/sql/create_tables.sql copy the {{{create table QTLDataSet}}} and paste it into the mysql prompt. |