TripalCultivate / TripalCultivate-Phenotypes

Provides generic support for large scale phenotypic data and traits with importers, content pages and visualizations.
GNU General Public License v3.0
1 stars 0 forks source link

G4.78 - The get functions in the Traits Service do not handle more than one relationship between trait and method, or method and unit #78

Closed carolyncaron closed 3 months ago

carolyncaron commented 4 months ago

Branch

g4.78-fixTraitServiceGetters

Groups

Group 4 - API | Services | Plugins

Describe

The get functions in TripalCultivatePhenotypesTraitsService.php are not accommodating situations when we have multiple methods relating to a trait, or multiple units for a method. For example, the following Trait + Method + Unit combinations are all valid in the database at the same time:

Trait: Plant height Method: Ruler Unit: cm

Trait: Plant height Method: Ruler Unit: inches

Trait: Plant height Method: barcode reader Unit: serial number

Thus, we need a way to get all method records for a single trait, and all units for a single method.

Design

In general, situations in which more than one record is returned should be handled (including when it shouldn't be possible, which warrants an exception being thrown) rather than LIMIT being used in an SQL query. These are the lines in question:

https://github.com/TripalCultivate/TripalCultivate-Phenotypes/blob/526caaf5f97054c69b99449db564f40f90b89a8c/trpcultivate_phenotypes/src/Service/TripalCultivatePhenotypesTraitsService.php#L337

https://github.com/TripalCultivate/TripalCultivate-Phenotypes/blob/526caaf5f97054c69b99449db564f40f90b89a8c/trpcultivate_phenotypes/src/Service/TripalCultivatePhenotypesTraitsService.php#L388

https://github.com/TripalCultivate/TripalCultivate-Phenotypes/blob/526caaf5f97054c69b99449db564f40f90b89a8c/trpcultivate_phenotypes/src/Service/TripalCultivatePhenotypesTraitsService.php#L411

reynoldtan commented 4 months ago

For a method that will return some relevant values relating to the combination of Trait Name + Method Short Name + Unit Name.

Return value options:

  1. An array where each trait asset gets resolved into its cvterm record plus the genus information. trait - name, description, ... method - name, description, ... unit - name, description, ... genus

  2. A Boolean value. True if combination already exists and a False value to indicate that the combination does not exists in the genus (May be in the other genus).

Uses (where trait name, method name and unit name are available):

/**
 * Get trait, method and unit records.
 *
 * @param $trait
 * @param $method
 * @param $unit
 */
public function getTraitMethodUnitCombination($trait, $method, $unit) {
  // Get Trait
  // Get Method
  // Get Unit

  return []
}

I would like to include this method in the same branch and PR since it relates to the issue above.

@laceysanderson and @carolyncaron please do expand on this method design.