So I noticed that there's a term I want to create under the TContact database since it does not exist. In this case the term should be named 'Position' and should allow users to put in their job position.
I came across the function chado_insert_cvterm:
http://api.tripal.info/api/tripal/tripal_chado%21api%21modules%21tripal_chado.cv.api.inc/function/chado_insert_cvterm/3.x
Which explains what needed to create such a term
Under the requirement, it needs an id which requires
DB:ACCESSION
How do I get an accession number? I'm assuming this has to be unique right? Could one of you guys explain this or perhaps point me in the right direction or let me know if this is actually the wrong approach?
Thanks!
Tagging: @bradfordcondon @shawnawsu @laceysanderson
Alternatively, is there a way to programmatically import an OBO file? That could work as well
OK. You want to use a CVterm for Position.
Step 1: Does a good term exist already? Search the EBI OLS.
Step 2: If no term exists
local:term_name as the DB:accession in Tripal when inserting into the site's local CV.In the case of position, I was able to find a pretty good match using the EBI OLS service . I'd recommend using this term.
So you would insert the term as follows:
$term = chado_insert_cvterm(array(
'id' => 'sep:00030',
'name' => 'position',
'cv_name' => 'EDAM',
'definition' => 'A position is a social role that is a formal declaration of reponsibility within an Organization. Examples of Positions include president, laboratory director, senior researcher, sales representative, etc. [ SUMO:position ]
.',
));
if on the other hand you wanted to use a local term (which i wouldnt recommend because we've got a good fit above:
$term = chado_insert_cvterm(array(
'id' => 'local:position',
'name' => 'position',
'cv_name' => 'local',
'definition' => 'position
.',
));
ps:
theres a way to programmatically load an OBO: Tripal installs the sequence ontology on install. Forgive me I can't check the code now to point you to it...
Loading an OBO programmatically is possible.
First load it into tripal and chado. In tripal_chado/api/module/tripal_chado.cv.api.inc there is chado_insert_obo($obo_name, $file); which writes the reference to the tripal_cv_obo table, that would need to be followed up with $obo_id = chado_insert_cv($name, $definition) to write it to the cv table in chado.
Then you can do this, if it requires no special handling:
module_load_include('inc', 'tripal_chado', 'includes/TripalImporter/OBOImporter');
$obo_importer = new OBOImporter();
$obo_importer->create(array('obo_id' => $obo_id));
$obo_importer->run();
$obo_importer->postRun();
If it requires special handling it would be a bit more work. So you would need to do something like this:
Parse the file and handle any special exceptions while each term would need to be inserted chado_insert_cvterm($term, $options = array()) then the cvtermpath needs to be updated chado_update_cvtermpath($cv_id, $job_id = NULL).
If it requires extensive special handling you would want to extend the OBOImporter class.
For a good example see tripal_chado/includes/TripalImporter/OBOImporter.inc
Sorry for all the updates on the previous comment. I realized it was very unclear, so I rewrote it, like 5 times. I hope it's understandable now!
An addendum to my previous comment: I wrote out how to programmatically add a new CVterm. You can alternatively use the admin interface to do so, located at admin/tripal/loaders/chado_vocabs/chado_cv/cvterm/add
You provide the same info, but using the GUI (see screenshot below)

Thanks! chado_insert_cvterm works great!