The chado_insert_cvterm() methods are still available but can be buggy and are very slow. Unfortunately the replacement API service for Tripal 4 is not yet ready.
We recommend you use the following method to insert all terms your module needs. Keep in mind you will need a term for the following
each field type
each property or piece of information in your field
each content type
You will be using the new Tripal Term Collection service to insert your terms in bulk on install of your module. This is setup using two parts:
Defining the terms.
The terms are defined in a YAML file. You will create an empty file in the config/install folder in your module. If this does not exist, you can just create it. The file should have the name tripal.tripal_content_terms.ID.yml where you replace the ID token with the id for your collection. I would suggest something like mymodule_terms which would result in the full filename of tripal.tripal_content_terms.mymodule_terms.yml.
Then within the file you add the following content at the top and replace instances of mymodule and My Module with the name of your module.
id: 'mymodule_terms'
label: 'My Module Terms'
description: 'Terms for Content Types and Chado Fields for My Module.'
vocabularies:
Each entry under vocabularies defined a single vocabulary your terms are from. For example, if you are using terms in the EDAM ontology then you would add the following under vocabularies exactly as I've shown:
- name: 'EDAM'
label: 'Bioscientific data analysis ontology'
url: 'http://edamontology.org/page'
idSpaces:
- name: 'data'
description: "Bioinformatics operations, data types, formats, identifiers and topics."
urlPrefix: "http://edamontology.org/{db}_{accession}"
- name: 'format'
description: 'A defined way or layout of representing and structuring data in a computer file, blob, string, message, or elsewhere. The main focus in EDAM lies on formats as means of structuring data exchanged between different tools or resources.'
urlPrefix: "http://edamontology.org/{db}_{accession}"
- name: 'operation'
description: 'A function that processes a set of inputs and results in a set of outputs, or associates arguments (inputs) with values (outputs). Special cases are: a) An operation that consumes no input (has no input arguments).'
urlPrefix: "http://edamontology.org/{db}_{accession}"
- name: 'topic'
description: 'A category denoting a rather broad domain or field of interest, of study, application, work, data, or technology. Topics have no clearly defined borders between each other.'
urlPrefix: "http://edamontology.org/{db}_{accession}"
terms:
This structure defines the vocabulary/ontology and all the ID Spaces within it. EDAM is an interesting ontology as it has multiple ID Spaces. In most ontologies you will only have a single ID space. This is the characters before the colon in the id (e.g. ID Space is SO for the sequence ontology).
If you do not have terms from a published ontology, then you will use the local ontology. This would be added as follows:
- name: 'local'
label: 'Locally created terms'
url: 'cv/lookup/local'
idSpaces:
- name: 'local'
description: 'Terms created for this site'
urlPrefix: 'cv/lookup/{db}/{accession}'
terms:
Now for the terms! Each term is a simple element like so:
- id: 'local:property'
name: 'property'
description: 'A generic term indicating that represents an attribute, quality or characteristic of something.'
Where the id includes the idspace and the accession separated by a :, the name is the official name of the term and the description is the definition of the term. Both the id and the name are required but the definition is optional.
You can see a full example of this format and all the terms added by Tripal core in the tripal_chado/config/install/tripal.tripal_content_terms.chado_content_terms.yml. If you use and vocabulary listed in this core file, please ensure you match the details we provided exactly to ensure the vocabulary does not end up duplicated.
Calling the service in your install.
Add the following code to your mymodule.install file in the hook_install() function.
The
chado_insert_cvterm()
methods are still available but can be buggy and are very slow. Unfortunately the replacement API service for Tripal 4 is not yet ready.We recommend you use the following method to insert all terms your module needs. Keep in mind you will need a term for the following
You will be using the new Tripal Term Collection service to insert your terms in bulk on install of your module. This is setup using two parts:
The terms are defined in a YAML file. You will create an empty file in the
config/install
folder in your module. If this does not exist, you can just create it. The file should have the nametripal.tripal_content_terms.ID.yml
where you replace theID
token with the id for your collection. I would suggest something likemymodule_terms
which would result in the full filename oftripal.tripal_content_terms.mymodule_terms.yml
.Then within the file you add the following content at the top and replace instances of
mymodule
andMy Module
with the name of your module.Each entry under vocabularies defined a single vocabulary your terms are from. For example, if you are using terms in the EDAM ontology then you would add the following under
vocabularies
exactly as I've shown:This structure defines the vocabulary/ontology and all the ID Spaces within it. EDAM is an interesting ontology as it has multiple ID Spaces. In most ontologies you will only have a single ID space. This is the characters before the colon in the id (e.g. ID Space is
SO
for the sequence ontology).If you do not have terms from a published ontology, then you will use the
local
ontology. This would be added as follows:Now for the terms! Each term is a simple element like so:
Where the id includes the idspace and the accession separated by a
:
, the name is the official name of the term and the description is the definition of the term. Both the id and the name are required but the definition is optional.You can see a full example of this format and all the terms added by Tripal core in the tripal_chado/config/install/tripal.tripal_content_terms.chado_content_terms.yml. If you use and vocabulary listed in this core file, please ensure you match the details we provided exactly to ensure the vocabulary does not end up duplicated.
Add the following code to your
mymodule.install
file in thehook_install()
function.