Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

G1.57 Upgrade use of chado_insert_cvterm() to use the Tripal 4 terms service. #57

Closed
laceysanderson opened this issue Nov 29, 2023 · 2 comments · Fixed by #138
Closed
Assignees
Labels
Group 1 - Content Types | Ontology | Fields Any issue relating to Tripal Content including types, terms, and fields. HIGH PRIORITY

Comments

@laceysanderson
Copy link
Member

Branch

g1.57-useT4TermsService

Groups

Group 1 - Content Types | Ontology | Fields

Describe

Currently the TripalCultivatePhenotypesTermsService uses chado_insert_cvterm() to insert the terms needed by the module. However, this function is deprecated in Tripal 4 and VERY slow.

Design

My plan is to take the information on default terms in trpcultivate_phenotypes.settings.yml and format them to match the Tripal Default Terms for Content Types.

Then I can update the current loadTerms() method to use the Tripal Core ChadoTermsInit service.

@laceysanderson laceysanderson added the Group 1 - Content Types | Ontology | Fields Any issue relating to Tripal Content including types, terms, and fields. label Nov 29, 2023
@laceysanderson laceysanderson self-assigned this Nov 29, 2023
@reynoldtan
Copy link
Contributor

At 4.x, this is an outstanding issue. loadTerms() uses chado_insert_cvterm() to handle terms.

@laceysanderson
Copy link
Member Author

The ChadoBuddies have now been implemented in TripalCore which act as a direct replacement for chado_insert_cvterm()! The code for how to handle inserting a cvterm is shown in this example in the docs: https://tripaldoc.readthedocs.io/en/latest/dev_guide/biodata/buddies/buddy_values.html#chado-buddy-example-2

$buddy_service = \Drupal::service('tripal_chado.chado_buddy');
$cvterm_instance = $buddy_service->createInstance('chado_cvterm_buddy', []);

// Create the cvterm and dbxref records in chado, unless they already exist.
$values = [
  'db.name' => 'local',
  'cv.name' => 'local',
  'dbxref.accession' => 'X000002',
  'cvterm.name' => 'Example 2',
  'cvterm.definition' => 'A fake ontology term for example #2',
];
$chado_cvterm_record = $cvterm_instance->upsertCvterm($values, []);
// if for any reason insert failed, an exception is thrown, so
// you should catch exceptions as shown in example #3
$cvterm_id = $chado_cvterm_record->getValue('cvterm.cvterm_id');
print "Created or found cvterm with id=$cvterm_id\n";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group 1 - Content Types | Ontology | Fields Any issue relating to Tripal Content including types, terms, and fields. HIGH PRIORITY
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants