Go to the source code of this file.
|
| tpps_cvterms_clear_cache (TripalJob $job=NULL) |
|
| tpps_get_cvterms_v1_1 () |
|
| tpps_get_cvterms_v1_2 () |
|
| tpps_load_cv ($info) |
|
| tpps_load_cvterm ($term, array $options=array(), $version=NULL, $refresh_cache=FALSE) |
|
| tpps_local_install_term ($key, $version=NULL) |
|
| tpps_match_cvterms ($old_cvt, $new_cvt) |
|
| tpps_migrate_cvterms ($old_major=NULL, $old_minor=NULL, $new_major=TPPS_MAJOR_VERSION, $new_minor=TPPS_MINOR_VERSION) |
|
| tpps_ols_add_cv ($ontology_id) |
|
| tpps_ols_add_cvterm ($term) |
|
| tpps_ols_call ($type, array $args=array()) |
|
| tpps_ols_install_term ($info) |
|
| tpps_ols_ontology_info ($id) |
|
| tpps_ols_search ($query, $ontology=NULL, $exact=TRUE) |
|
| tpps_ols_url ($types, array $args=array()) |
|
Defines utilities for managing TPPS cvterms.
Definition in file cvterm_utils.inc.
◆ tpps_cvterms_clear_cache()
tpps_cvterms_clear_cache |
( |
TripalJob |
$job = NULL | ) |
|
Returns nothing, this is an administration function
To speed up the process cvterms and even the cv (ontologies) are cached using various methods. This will refresh the cache and update the necessary links in the cache.
- Returns
- array Array of cvterms that TPPS will be using.
Definition at line 339 of file cvterm_utils.inc.
341 $job->logMessage(
'[INFO] Initializing cvterms cache refresh...');
344 cache_set(
'tpps_cv', NULL);
346 $cvt_v = variable_get(
'tpps_cvterms_version',
'1_1');
347 $get_cvt =
'tpps_get_cvterms_v' . ($version ?? $cvt_v);
349 foreach ($terms as $term => $ontology_and_term) {
353 $job->logMessage(
'[INFO] Complete!');
tpps_load_cvterm($term, array $options=array(), $version=NULL, $refresh_cache=FALSE)
◆ tpps_get_cvterms_v1_1()
tpps_get_cvterms_v1_1 |
( |
| ) |
|
Returns an array of cvterms that TPPS version 1.1 will be using.
This function is called during installation of TPPS to add these cvterms via the Ontology Lookup Service (https://www.ebi.ac.uk/ols/). Older versions of this function are kept for the purposes of migrating cvterms that TPPS may have defined in the past.
- Returns
- array Array of cvterms that TPPS will be using.
Definition at line 627 of file cvterm_utils.inc.
629 'study_start' =>
'local:The month and year that the study began.',
630 'study_end' =>
'local:The month and year that the study ended.',
631 'experiment_location' =>
'local:Geographic location of the experiment.',
632 'assession_season' =>
'local:Season the trees were assessed.',
633 'assession_number' =>
'local:Number of times the trees were assessed, on average.',
634 'co2_control' =>
'local:Whether or not the co2 level of the environment was controlled. True or False.',
635 'co2_level' =>
'local:Must have an associated co2_control property. If co2_control is True, this term describes the co2 level the environment was kept at. If co2_control is False, this term describes the average measured co2 value in the environment.',
636 'humidity_control' =>
'local:Whether or not the air humidity level of the environment was controlled. True or False.',
637 'humidity_level' =>
'local:Must have an associated humidity_control property. If humidity_control is True, this term describes the air humidity level the environment was kept at. If humidity_control is False, this term describes the average measured air humidity value in the environment.',
638 'light_control' =>
'local:Whether or not the light intensity level of the environment was controlled. True or False.',
639 'light_level' =>
'local:Must have an associated light_control property. If light_control is True, this term describes the light intensity level the environment was kept at. If light_control is False, this term describes the average measured light intensity value in the environment.',
640 'temperature_high' =>
'local:Average high temperature of the environment.',
641 'temperature_low' =>
'local:Average low temperature of the environment.',
642 'rooting_type' =>
'local:Type of rooting. Aeroponics, Hydroponics, or Soil.',
643 'soil_type' =>
'local:Type of soil. For example: Sand, Peat, Mixed, etc.',
644 'soil_container' =>
'local:Type of soil container.',
645 'pH_control' =>
'local:Whether or not the pH level of the environment was controlled. True or False.',
646 'pH_level' =>
'local:Must have an associated pH_control property. If pH_control is True, this term describes the pH level the environment was kept at. If pH_control is False, this term describes the average measured pH value in the environment.',
647 'treatment' =>
'local:Describes the treatment of the trees during the study. For example, air or soil temperature regimes, chemical administration, fertilizer, non-mineral nutrient, or rainfall regimes, disease status, etc.',
648 'irrigation_type' =>
'local:Describes the type of irrigation. For example, drip irrigation, irrigation from the top, no irrigation, etc.',
649 'salinity_control' =>
'local:Whether or not the salinity level of the environment was controlled. True or False.',
650 'salinity_level' =>
'local:Must have an associated salinity_control property. If salinity_control is True, this term describes the salinity level the environment was kept at. If salinity_control is False, this term describes the average measured salinity value in the environment.',
651 'biotic_environment' =>
'local:Describes the biotic environment.',
652 'study_type' =>
'local:Describes the type of environment the trees were in during the study. Possible values are Natural Population (Landscape), Growth Chamber, Greenhouse, Experimental/Common Garden, Plantation.',
653 'phenotype_binary_type' =>
'local:Describes one type of a binary phenotype.',
654 'file_path' =>
'schema:url',
655 'contact photo' =>
'local:A profile photo for a contact record',
656 'gps_latitude' =>
'local:Coordinate that specifies north-south position on Earth\'s surface',
657 'gps_longitude' =>
'local:Coordinate that specifies east-west position on Earth\'s surface',
658 'association_results_type' =>
'local:The type of the association results.',
659 'county' =>
'local:A political and administrative division of a state',
660 'district' =>
'local:A distinct area of a geographic entity, such as a country or city',
661 'organism 4 letter code' =>
'local:4 letter abbreviation of species. Usually first two letters of genus + first two letters of species, may be different if that code already exists (use next letters from species if possible).',
662 'cpSSR' =>
'local:Chloroplast simple sequence repeats.',
663 'SSR' =>
'local:Simple sequence repeats. Microsatellite.',
664 'time' =>
'local:A quality in which events occur in sequence.',
665 'source_description' =>
'local:A textual description of study type and comments for a source.',
666 'location' =>
'nd_geolocation_property:Location',
667 'format' =>
'sep:format',
668 'environment' =>
'biomaterial_property:climate_environment',
669 'description' =>
'schema:description',
◆ tpps_get_cvterms_v1_2()
tpps_get_cvterms_v1_2 |
( |
| ) |
|
Returns an array of cvterms that TPPS version 1.2 will be using.
This function is called during installation of TPPS to add these cvterms via the Ontology Lookup Service (https://www.ebi.ac.uk/ols/). Older versions of this function are kept for the purposes of migrating cvterms that TPPS may have defined in the past.
- Returns
- array Array of cvterms that TPPS will be using.
Definition at line 368 of file cvterm_utils.inc.
371 'assession_number' =>
'local:Number of times the trees were assessed, on average.',
372 'temperature_high' =>
'local:Average high temperature of the environment.',
373 'temperature_low' =>
'local:Average low temperature of the environment.',
374 'rooting_type' =>
'local:Type of rooting. Aeroponics, Hydroponics, or Soil.',
375 'organism 4 letter code' =>
'local:4 letter abbreviation of species. Usually first two letters of genus + first two letters of species, may be different if that code already exists (use next letters from species if possible).',
376 'source_description' =>
'local:A textual description of study type and comments for a source.',
377 'email' =>
'local:Email address',
378 'number_samples' =>
'local:Number of samples',
379 'gps_type' =>
'local:Type of GPS coordinates. Exact, Approximate, or Site-based.',
380 'gps_precision' =>
'local:Precision of GPS coordinates.',
383 'precipitation' =>
'local:precipitation',
384 'absorbance' =>
'local:absorbance',
385 'water use efficiency' =>
'local:water use efficiency',
386 'delta' =>
'ncit:Delta',
387 'carbon-13 atom' =>
'chebi_ontology:carbon-13 atom',
388 'rate' =>
'pato:rate',
389 'chlorophyll' =>
'chebi:chlorophyll',
390 'transpiration' =>
'GO: Biological Process:transpiration',
391 'photosynthesis' =>
'GO: Biological Process:photosynthesis',
392 'degrees celsius per millimeter' =>
'local:degrees celsius per millimeter',
393 'centimeters per day' =>
'local:centimeters per day',
394 'kilograms per meter cubed' =>
'local:kilograms per meter cubed',
395 'no unit' =>
'local:no unit',
396 'log(centimeters per day)' =>
'local:log(centimeters per day)',
397 'log(centimeters cubed per day)' =>
'local:log(centimeters cubed per day)',
398 'micromoles carbon dioxide per meter squared per second' =>
'local:micromoles carbon dioxide per meter squared per second',
399 'micromoles carbon dioxide per gram per second' =>
'local:micromoles carbon dioxide per gram per second',
400 'absorbance unit' =>
'local:absorbance unit',
401 'number' =>
'local:number',
402 'milligrams per millimeter' =>
'local:milligrams per millimeter',
403 'milligrams per millimeter squared' =>
'local:milligrams per millimeter squared',
404 'milligrams per milligram' =>
'local:milligrams per milligram',
405 'micromoles carbon dioxide per gram Nitrogen per second' =>
'local:micromoles carbon dioxide per gram Nitrogen per second',
406 'micromoles carbon dioxide per millimole water' =>
'local:micromoles carbon dioxide per millimole water',
407 'moles water per meter squared per second' =>
'local:moles water per meter squared per second',
410 'article' =>
'tripal_pub:Journal Article',
411 'abstract' =>
'tripal_pub:Abstract',
412 'authors' =>
'tripal_pub:Authors',
413 'person' =>
'tripal_contact:Person',
414 'contact_part_of' =>
'tripal_contact:part of',
415 'organization' =>
'tripal_contact:Organization',
416 'country' =>
'tripal_contact:Country',
417 'state' =>
'tripal_contact:State',
418 'analysis_type' =>
'analysis_property:Analysis Type',
422 'gravity' =>
'tree_genes_to:specific gravity',
425 'experiment_location' =>
'ppeo:location',
426 'file_path' =>
'ppeo:data file',
429 'study_start' =>
'ncit:Study Start Date',
430 'district' =>
'ncit:Locality',
431 'study_end' =>
'ncit:Study Completion Date',
432 'assession_season' =>
'ncit:Season',
433 'soil_container' =>
'ncit:Container',
434 'gps_latitude' =>
'ncit:Latitude',
435 'gps_longitude' =>
'ncit:Longitude',
436 'location' =>
'ncit:Location',
437 'association_results_type' =>
'ncit:Data Type',
438 'county' =>
'ncit:County',
439 'read_depth' =>
'ncit:Read Depth',
440 'format' =>
'ncit:Format',
441 'minimum' =>
'ncit:Minimum',
442 'maximum' =>
'ncit:Maximum',
443 'indel' =>
'ncit:Indel Mutation',
444 'p_value' =>
'ncit:P-Value',
445 'lambda' =>
'ncit:Lambda',
446 'bonferroni' =>
'ncit:Adjusted Bonferroni Correction',
447 'boolean' =>
'ncit:Boolean',
451 'alive' =>
'pato:alive',
452 'amount' =>
'pato:amount',
453 'angle' =>
'pato:angle',
454 'area' =>
'pato:area',
455 'bent' =>
'pato:bent',
456 'circumference' =>
'pato:circumference',
457 'color' =>
'pato:color',
458 'composition' =>
'pato:composition',
459 'concentration_of' =>
'pato:concentration of',
460 'damage' =>
'pato:damage',
461 'description' =>
'pato:description',
462 'diameter' =>
'pato:diameter',
463 'distance' =>
'pato:distance',
464 'growth_quality_of_occurrent' =>
'pato:growth quality of occurrent',
465 'growth_rate' =>
'pato:growth rate',
466 'has_number_of' =>
'pato:has number of',
467 'height' =>
'pato:height',
468 'humidity_level' =>
'pato:humidity',
469 'intensity' =>
'pato:intensity',
470 'length' =>
'pato:length',
471 'lesioned' =>
'pato:lesioned',
472 'maturity' =>
'pato:maturity',
473 'pH_level' =>
'pato:acidity',
474 'position' =>
'pato:position',
475 'pressure' =>
'pato:pressure',
476 'proportionality_to' =>
'pato:proportionality to',
477 'qualitative' =>
'pato:qualitative',
478 'rate' =>
'pato:rate',
479 'rough' =>
'pato:rough',
480 'shape' =>
'pato:shape',
481 'size' =>
'pato:size',
482 'temperature' =>
'pato:temperature',
483 'texture' =>
'pato:texture',
484 'thickness' =>
'pato:thickness',
485 'time' =>
'pato:time',
486 'volume' =>
'pato:volume',
487 'weight' =>
'pato:weight',
488 'width' =>
'pato:width',
489 'sex' =>
'pato:phenotypic sex',
492 'whole plant' =>
'po:whole plant:plant_ontology',
493 'bark' =>
'po:bark:plant_anatomy',
494 'branch' =>
'po:branch:plant_anatomy',
495 'bud' =>
'po:bud:plant_anatomy',
496 'catkin_inflorescence' =>
'po:catkin inflorescence:plant_anatomy',
497 'endocarp' =>
'po:endocarp:plant_anatomy',
498 'floral_organ' =>
'po:floral organ:plant_anatomy',
499 'flower' =>
'po:flower:plant_anatomy',
500 'flower_bud' =>
'po:flower bud:plant_anatomy',
501 'flower_fascicle' =>
'po:flower fascicle:plant_anatomy',
502 'fruit' =>
'po:fruit:plant_anatomy',
503 'leaf' =>
'po:leaf:plant_anatomy',
504 'leaf_rachis' =>
'po:leaf rachis:plant_anatomy',
505 'leaflet' =>
'po:leaflet:plant_anatomy',
506 'nut_fruit' =>
'po:nut fruit:plant_anatomy',
507 'petal' =>
'po:petal:plant_anatomy',
508 'petiole' =>
'po:petiole:plant_anatomy',
509 'phloem' =>
'po:phloem:plant_anatomy',
510 'plant_callus' =>
'po:plant callus:plant_anatomy',
511 'primary_thickening_meristem' =>
'po:primary thickening meristem:plant_anatomy',
513 'root' =>
'plant_anatomy:root',
514 'secondary_xylem' =>
'po:secondary xylem:plant_anatomy',
515 'seed' =>
'po:seed:plant_anatomy',
516 'shoot_system' =>
'po:shoot system:plant_anatomy',
517 'stem' =>
'po:stem:plant_anatomy',
518 'stomatal_complex' =>
'po:stomatal complex:plant_anatomy',
519 'strobilus' =>
'po:strobilus:plant_anatomy',
520 'terminal_bud' =>
'po:terminal bud:plant_anatomy',
521 'vascular_leaf' =>
'po:vascular leaf:plant_anatomy',
524 'co2_control' =>
'plant_experimental_conditions_ontology:carbon dioxide exposure',
525 'humidity_control' =>
'plant_experimental_conditions_ontology:humidity exposure',
526 'light_control' =>
'plant_experimental_conditions_ontology:light intensity exposure',
527 'pH_control' =>
'plant_experimental_conditions_ontology:pH exposure',
528 'treatment' =>
'plant_experimental_conditions_ontology:plant exposure',
529 'salinity_control' =>
'plant_experimental_conditions_ontology:salt exposure',
530 'biotic_environment' =>
'plant_experimental_conditions_ontology:biotic plant exposure',
531 'study_type' =>
'plant_experimental_conditions_ontology:study type',
534 'co2_level' =>
'envo:atmospheric carbon dioxide',
535 'light_level' =>
'envo:visible spectrum radiation',
536 'soil_type' =>
'envo:soil',
537 'environment' =>
'envo:environmental system',
538 'atmosphere' =>
'envo:atmosphere',
541 'salinity_level' =>
'chebi:salt',
544 'irrigation_type' =>
'agro:irrigation process',
547 'reference_genome' =>
'sequence:reference_genome',
548 'genotype' =>
'sequence:genotype',
549 'sequence_variant' =>
'sequence:sequence_variant',
550 'snp' =>
'sequence:SNP',
551 'ssr' =>
'sequence:microsatellite',
552 'genetic_marker' =>
'sequence:genetic_marker',
553 'quality_value' =>
'sequence:quality_value',
554 'allelic_frequency' =>
'sequence:allelic_frequency',
555 'synonymous' =>
'sequence:synonymous',
556 'clone' =>
'sequence:clone',
557 'supercontig' =>
'sequence:supercontig',
558 'scaffold' =>
'sequence:chromosome',
559 'has_part' =>
'sequence:has_part',
562 'filter' =>
'edam:Sequence contamination filtering:operation',
566 'centimeter' =>
'uo:centimeter',
567 'cubic_centimeter' =>
'uo:cubic centimeter',
569 'degrees_celsius' =>
'uo:degree Celsius',
570 'degrees_fahrenheit' =>
'uo:degree Fahrenheit',
571 'grams_per_square_meter' =>
'uo:gram per square meter',
573 'luminous_intensity_unit' =>
'uo:luminous intensity unit',
574 'kilogram' =>
'uo:kilogram',
575 'kilogram_per_cubic_meter' =>
'uo:kilogram per cubic meter',
576 'liter' =>
'uo:liter',
577 'cubic_meter' =>
'uo:cubic meter',
578 'pascal' =>
'uo:pascal',
579 'meter' =>
'uo:meter',
580 'milligram' =>
'uo:milligram',
581 'milliliter' =>
'uo:milliliter',
582 'millimeter' =>
'uo:millimeter',
583 'micrometer' =>
'uo:micrometer',
584 'percent' =>
'uo:percent',
586 'square_micrometer' =>
'uo:square micrometer',
587 'square_millimeter' =>
'uo:square millimeter',
588 'watt_per_square_meter' =>
'uo:watt per square meter',
592 'phenotype' =>
'sbo:phenotype',
595 'organism' =>
'obi:organism',
596 'q_value' =>
'obi:q-value',
597 'p_adj_fwe' =>
'obi:FWER adjusted p-value',
600 'family' =>
'taxonomic_rank:family',
601 'subkingdom' =>
'taxonomic_rank:subkingdom',
602 'order' =>
'taxonomic_rank:order',
603 'speciesaggregate' =>
'taxonomic_rank:speciesaggregate',
606 'common name' =>
'ncbitaxon:common name',
609 'phenotype_binary_type' => NULL,
610 'contact photo' => NULL,
◆ tpps_load_cv()
Load a cv based on an OLS ontology id or cv_info object.
- Parameters
-
array | string | $info | Either an OLS ontology id or a cv_info object. |
- Returns
- object|null The resulting cv object or NULL on failure.
Definition at line 132 of file cvterm_utils.inc.
134 if (!is_string($info)) {
137 $id = strtolower($id);
139 $cache = cache_get(
'tpps_cv')->data ?? array();
143 $cv_id = $cache[$id] ?? NULL;
144 if (!empty($cv_id)) {
145 return chado_get_cv(array(
151 if (is_string($info)) {
154 if (empty($cv_info)) {
157 'namespace' => $info,
164 'data' => $cv_info[
'cvname'],
168 $cv = chado_generate_var(
'cv', $query);
169 if (!$cv and !empty($cv_info[
'namespace'])) {
170 $query[
'name'][
'data'] = $cv_info[
'namespace'];
171 $cv = chado_generate_var(
'cv', $query);
176 if($query[
'name'][
'data'] ==
'OBI') {
177 $query[
'name'][
'data'] = strtolower($query[
'name'][
'data']);
179 $query[
'name'][
'op'] =
'LIKE';
180 $cv = chado_generate_var(
'cv', $query);
187 $cache[$id] = $cv->cv_id;
188 cache_set(
'tpps_cv', $cache);
tpps_ols_ontology_info($id)
◆ tpps_load_cvterm()
tpps_load_cvterm |
( |
|
$term, |
|
|
array |
$options = array() , |
|
|
|
$version = NULL , |
|
|
|
$refresh_cache = FALSE |
|
) |
| |
Load a cvterm based on a key from tpps_get_cvterms_v<version>().
If the key does not appear in tpps_get_cvterms_v<version>(), then we just load the cvterm using the provided key as the name.
- Parameters
-
string | $term | The key of the cvterm we are trying to load. |
array | $options | Optional additional options to be passed to chado_get_cvterm(). |
string | $version | Optional TPPS cvterm version. |
- Returns
- object|false The resulting cvterm object, or FALSE on failure.
Definition at line 208 of file cvterm_utils.inc.
209 $check_cache = variable_get(
'tpps_load_cvterm_' . md5($term), null);
210 if($refresh_cache == TRUE) {
213 if ($_GET[
'refresh_cache'] ==
'true') {
216 if ($check_cache == null) {
217 $cvt_v = variable_get(
'tpps_cvterms_version',
'1_1');
218 $get_cvt =
'tpps_get_cvterms_v' . ($version ?? $cvt_v);
220 $info = $terms[$term] ?? NULL;
227 preg_match(
'/^([^:]*):([^:]+):?([^:]+)?$/', $info, $matches);
228 $ontology = $matches[1];
230 $alt_ontology = $matches[3] ?? NULL;
232 $identifiers = array(
237 if (!empty($ontology)) {
238 if ($ontology ==
'local') {
239 $identifiers[
'definition'] = $name;
242 $identifiers[
'name'] = $name;
246 $result = chado_get_cvterm($identifiers, $options);
250 preg_match(
'/^([\w]*):([\s]+[\w\s]*):([\s\w]*):?([\s\w]*)?$/', $info, $matches2);
251 if(count($matches2) > 0) {
253 $ontology = $matches2[1] .
":" . $matches2[2];
255 $name = $matches2[3];
256 $alt_ontology = $matches2[4] ?? NULL;
257 if (!empty($ontology)) {
258 if ($ontology ==
'local') {
259 $identifiers[
'definition'] = $name;
262 $identifiers[
'name'] = $name;
266 $result = chado_get_cvterm($identifiers, $options);
270 if(empty($result) && $ontology ==
'local') {
272 unset($identifiers[
'definition']);
273 $identifiers[
'name'] = $name;
275 $result = chado_get_cvterm($identifiers, $options);
281 if (empty($result) and $ontology !=
'local' and !empty($alt_ontology)) {
282 $identifiers[
'cv_id'] =
tpps_load_cv($alt_ontology)->cv_id;
283 $result = chado_get_cvterm($identifiers, $options);
286 if (empty($result)) {
288 $identifiers[
'cv_id'] =
tpps_load_cv(
'TreeGenes Internal Ontology')->cv_id;
289 $result = chado_get_cvterm($identifiers, $options);
292 if (empty($result)) {
294 $identifiers[
'cv_id'] =
tpps_load_cv(
'TreeGenes Internal Ontology')->cv_id;
295 $result = chado_get_cvterm($identifiers, $options);
298 if (empty($result)) {
299 if (!empty($options[
'job'])) {
300 $options[
'job']->logMessage(
'[WARNING] Failed to load cvterm: @term', array(
'@term' => $term), TRIPAL_WARNING);
301 throw new Exception(
'FATAL - after extensive searching, cvterm ' . $term .
' could not be found. This will cause insertion errors later on so it needs to be fixed');
304 $trace = debug_backtrace()[1];
306 if (!empty($trace[
'args']) and gettype($trace[
'args']) ==
'array') {
307 foreach ($trace[
'args'] as $key => $arg) {
308 if (gettype($arg) ==
'object' and get_class($arg) ==
'TripalJob') {
309 $job = &$trace[
'args'][$key];
313 $job->logMessage(
'[WARNING] Failed to load cvterm: @term', array(
'@term' => $term), TRIPAL_WARNING);
316 throw new Exception(
'FATAL - after extensive searching, cvterm ' . $term .
' could not be found. This will cause insertion errors later on so it needs to be fixed');
321 variable_set(
'tpps_load_cvterm_' . md5($term), serialize($result));
324 $result = unserialize($check_cache);
◆ tpps_local_install_term()
tpps_local_install_term |
( |
|
$key, |
|
|
|
$version = NULL |
|
) |
| |
Installs a local TPPS cvterm based on a provided key.
This function should be used if the tpps_ols_install_term() function returns "local".
- Parameters
-
string | $key | The key of the TPPS cvterm being installed. |
string | $version | The TPPS cvterm version to use. |
Definition at line 868 of file cvterm_utils.inc.
869 if (empty($version)) {
872 $get_cvt =
'tpps_get_cvterms_v' . $version;
874 $info = $terms[$key] ?? NULL;
876 throw new \Exception(
"Error installing term $key: Term info could not be found for TPPS cvterm version $version.");
879 $local_db = variable_get(
'tpps_local_db');
880 $parts = explode(
':', $info);
882 $cvt = chado_get_cvterm(array(
884 'definition' => $term,
889 drupal_set_message(
"Creating local cvterm $key",
'status');
890 $cvt = chado_insert_cvterm(array(
891 'id' =>
"{$local_db->name}:$key",
893 'definition' => $term,
894 'cv_name' =>
'local',
898 drupal_set_message(
"Error creating local cvterm $key",
'error');
◆ tpps_match_cvterms()
tpps_match_cvterms |
( |
|
$old_cvt, |
|
|
|
$new_cvt |
|
) |
| |
Adds a cvtermsynonym record for two matching cvterms.
This is useful for migrating from an older TPPS cvterm version to a new one.
- Parameters
-
object | $old_cvt | The old cvterm object returned by chado_get_cvterm(). |
object | $new_cvt | The new cvterm object returned by chado_get_cvterm(). |
Definition at line 915 of file cvterm_utils.inc.
916 if (empty($old_cvt->name)) {
919 $result = db_select(
'chado.cvtermsynonym',
'cs')
920 ->fields(
'cs', array(
'cvtermsynonym_id'))
921 ->condition(
'cvterm_id', $new_cvt->cvterm_id)
922 ->condition(
'synonym', $old_cvt->name)
924 ->execute()->fetchObject() ?? NULL;
926 if (empty($result)) {
927 db_insert(
'chado.cvtermsynonym')
929 'cvterm_id' => $new_cvt->cvterm_id,
930 'synonym' => $old_cvt->name,
931 'type_id' => chado_get_cvterm(array(
941 $old_synonyms = db_select(
'chado.cvtermsynonym',
'c')
942 ->fields(
'c', array(
'synonym',
'type_id'))
943 ->condition(
'cvterm_id', $old_cvt->cvterm_id)
946 while (($syn = $old_synonyms->fetchObject())) {
947 $result = db_select(
'chado.cvtermsynonym',
'cs')
948 ->fields(
'cs', array(
'cvtermsynonym_id'))
949 ->condition(
'cvterm_id', $new_cvt->cvterm_id)
950 ->condition(
'synonym', $syn->synonym)
952 ->execute()->fetchObject() ?? NULL;
954 if (empty($result)) {
955 db_insert(
'chado.cvtermsynonym')
957 'cvterm_id' => $new_cvt->cvterm_id,
958 'synonym' => $syn->synonym,
959 'type_id' => $syn->type_id,
◆ tpps_migrate_cvterms()
Migrate TPPS cvterms from an old version to a new version.
This is useful if a term that was previously in a local ontology is being moved to a standardized ontology from OLS. New cvterms inherit all of the same synonyms as the old cvterms. If version numbers are left blank, then the old version number will be imported from the tpps_cvterms_version variable and the new version number will be imported by the TPPS_MAJOR_VERSION and TPPS_MINOR_VERSION constants defined in tpps.module.
- Parameters
-
int | $old_major | Major version of the old cvterms. |
int | $old_minor | Minor version of the old cvterms. |
int | $new_major | Opotional major version of the new cvterms. |
int | $new_minor | Opotional minor version of the new cvterms. |
Definition at line 985 of file cvterm_utils.inc.
986 $old_v = variable_get(
'tpps_cvterms_version',
'1_1');
987 if (!empty($old_major) and !empty($old_minor)) {
988 $old_v = $old_major .
'_' . $old_minor;
990 $new_v = $new_major .
'_' . $new_minor;
991 if ($new_v === $old_v) {
994 $old_term_func =
'tpps_get_cvterms_v' . $old_v;
995 $new_term_func =
'tpps_get_cvterms_v' . $new_v;
996 $old_terms = $old_term_func();
997 $new_terms = $new_term_func();
998 $transaction = db_transaction();
1001 foreach ($old_terms as $key => $old_info) {
1002 $new_info = $new_terms[$key] ?? NULL;
1003 if (!isset($new_info) or !isset($old_info)) {
1007 if ($old_info == $new_info) {
1011 preg_match(
'/^([^:]*):(.*)$/', $old_info, $matches);
1012 $old_ont = $matches[1];
1013 $old_term = $matches[2];
1015 if ($old_ont ==
'local') {
1016 $old_cvt = chado_get_cvterm(array(
1018 'definition' => $old_term,
1022 $old_cvt = chado_get_cvterm(array(
1023 'name' => $old_term,
1029 if ($new_cvt === FALSE) {
1030 throw new \Exception(
"No OLS terms found for term $new_info");
1032 unset($new_terms[$key]);
1035 foreach ($new_terms as $key => $info) {
1036 if (!empty($info)) {
1040 if ($result ===
'local') {
1046 variable_set(
'tpps_cvterms_version', $new_v);
1048 catch (\Exception $e) {
1049 $transaction->rollback();
tpps_match_cvterms($old_cvt, $new_cvt)
tpps_local_install_term($key, $version=NULL)
tpps_ols_install_term($info)
◆ tpps_ols_add_cv()
tpps_ols_add_cv |
( |
|
$ontology_id | ) |
|
Adds a controlled vocabulary to chado based on an OLS ontology id.
- Parameters
-
string | $ontology_id | The OLS ontology id we will be adding. |
- Returns
- object|bool The resulting cv object, or FALSE on failure.
Definition at line 682 of file cvterm_utils.inc.
687 'data' => $cv_info[
'cvname'],
691 $db = chado_get_db($query);
693 drupal_set_message(
"Adding db $ontology_id",
'status');
694 chado_insert_db(array(
695 'name' => $cv_info[
'cvname'],
696 'description' => $cv_info[
'description'],
697 'url' => $cv_info[
'url'],
698 'urlprefix' => $cv_info[
'urlprefix'],
705 drupal_set_message(
"Adding vocabulary $ontology_id",
'status');
706 $cv = chado_insert_cv($cv_info[
'name'], $cv_info[
'description']);
709 drupal_set_message(
"There was an error adding vocabulary $ontology_id",
'error');
tpps_ols_ontology_info($id)
◆ tpps_ols_add_cvterm()
tpps_ols_add_cvterm |
( |
|
$term | ) |
|
Adds a controlled vocabulary term to chado based on an OLS term object.
- Parameters
-
object | $term | The decoded OLS JSON term object returned by the OLS API. |
- Returns
- object|bool The resulting cvterm object, or FALSE on failure
Definition at line 723 of file cvterm_utils.inc.
727 'name' => $term->label,
728 'cv_id' => $cv->cv_id,
731 $cvt = chado_get_cvterm($query);
733 drupal_set_message(
"Adding cvterm {$term->label}, description: {$term->description[0]} to ontology {$term->ontology_prefix}",
'status');
735 'id' => $term->obo_id,
736 'name' => $term->label,
737 'definition' => $term->description[0],
738 'cv_name' => $cv->name,
740 $cvt = chado_insert_cvterm($cvterm);
744 drupal_set_message(
"There was an error adding cvterm {$term->label} to ontology {$term->ontology_prefix}",
'error');
◆ tpps_ols_call()
tpps_ols_call |
( |
|
$type, |
|
|
array |
$args = array() |
|
) |
| |
Makes a call to the OLS API.
- Parameters
-
- Returns
- object Decoded JSON object returned by the OLS API.
Definition at line 78 of file cvterm_utils.inc.
80 $data = file_get_contents($url);
81 return json_decode($data);
tpps_ols_url($types, array $args=array())
◆ tpps_ols_install_term()
tpps_ols_install_term |
( |
|
$info | ) |
|
Install a single cvterm to chado from OLS.
- Parameters
-
string | $info | String of the format '<ontology>:'. |
- Returns
- object|string|bool The resulting cvterm object, or "local", or FALSE on failure.
Definition at line 759 of file cvterm_utils.inc.
762 $parts = explode(
':', $info);
763 $ontology = $parts[0];
764 if ($ontology ==
'local') {
768 $alt_ontology = $parts[2] ?? NULL;
778 $cvt = chado_get_cvterm(array(
780 'cv_id' => $cv->cv_id,
783 if (!$cvt and !empty($alt_ontology)) {
786 $cvt = chado_get_cvterm(array(
788 'cv_id' => $cv->cv_id,
801 catch (Exception $ex) {
807 print_r(
"Searching OLS search for term: $term with ontology: $ontology\n");
811 catch (Exception $ex) {
816 if ($response->numFound == 0) {
819 if ($response->numFound != 1) {
821 foreach ($response->docs as $doc) {
822 $docs[$doc->iri] = $doc;
824 print_r($response->docs);
825 if (count($docs) != 1) {
848 throw new \Exception(
"conflict found for cvterm $term from ontology $ontology: $response->numFound terms found");
850 $response->docs[$doc_index] = current($docs);
tpps_ols_search($query, $ontology=NULL, $exact=TRUE)
tpps_job_logger_write($string, $replacements=[])
tpps_ols_add_cvterm($term)
tpps_ols_add_cv($ontology_id)
tpps_load_cvterm($term, array $options=array(), $version=NULL, $refresh_cache=FALSE)
◆ tpps_ols_ontology_info()
tpps_ols_ontology_info |
( |
|
$id | ) |
|
Retrieves information about an ontology from OLS based on the ontology id.
- Parameters
-
string | $id | The id of the ontology. |
- Returns
- array An array containing some minimal information about the specified ontology.
Definition at line 42 of file cvterm_utils.inc.
47 if (empty($response)) {
50 $name = $response->config->preferredPrefix;
51 $base_uri = $response->config->baseUris[0] ?? NULL;
52 if (substr($base_uri, -1 * (strlen($name) + 1)) ==
"_$name") {
53 $url_prefix = substr($base_uri, 0, -5) .
'{db}_{accession}';
57 'id' => $response->ontologyId,
59 'description' => $response->config->title,
60 'url' => $response->config->homepage,
61 'urlprefix' => $url_prefix ?? NULL,
63 'namespace' => $response->config->annotations->{
'default-namespace'}[0],
tpps_ols_call($type, array $args=array())
◆ tpps_ols_search()
tpps_ols_search |
( |
|
$query, |
|
|
|
$ontology = NULL , |
|
|
|
$exact = TRUE |
|
) |
| |
Searches OLS for a term, possibly from a specific ontology.
- Parameters
-
string | $query | The term we are looking for. |
string | null | $ontology | Optional ontology to search in. |
bool | $exact | Whether or not we should be looking for an exact match. |
- Returns
- object Decoded JSON object returned by the OLS API.
Definition at line 21 of file cvterm_utils.inc.
22 $exact = $exact ?
'true' :
'false';
24 $args[] =
"q=" . urlencode($query);
25 $args[] =
"exact=$exact";
26 $args[] =
"queryFields=label";
27 if (!empty($ontology)) {
28 $args[] =
"ontology=$ontology";
tpps_ols_call($type, array $args=array())
◆ tpps_ols_url()
tpps_ols_url |
( |
|
$types, |
|
|
array |
$args = array() |
|
) |
| |
Constructs a URL for querying the OLS API based on supplied parameters.
- Parameters
-
string | array | $types | Type(s) to specify the type of API call being made. |
array | $args | Optional additional parameters to be passed to the API. |
- Returns
- string The constructed URL for the desired API call.
Definition at line 95 of file cvterm_utils.inc.
98 if (!is_array($types)) {
102 foreach ($types as $type) {
108 $url .=
"?" . implode(
'&', $args);
111 print_r(
'OLS URL:' . $url .
"\n");
113 if(function_exists(
'tpps_job_logger_write')) {
117 catch (Exception $ex) {
tpps_job_logger_write($string, $replacements=[])