Tripal
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy Class Reference
Inheritance diagram for Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy:
Inheritance graph
[legend]
Collaboration diagram for Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy:
Collaboration graph
[legend]

Public Member Functions

 __construct (array $configuration, $plugin_id, $plugin_definition, ChadoConnection $connection, ChadoBuddyPluginManager $buddy_manager)
 
 getCv (array $conditions, array $options=[])
 
 getCvterm (array $conditions, array $options=[])
 
 getCvtermSynonym (array $conditions, array $options=[])
 
 insertCv (array $values, array $options=[])
 
 insertCvterm (array $values, array $options=[])
 
 insertCvtermSynonym (array $values, array $options=[])
 
 updateCv (array $values, array $conditions, array $options=[])
 
 updateCvterm (array $values, array $conditions, array $options=[])
 
 updateCvtermSynonym (array $values, array $conditions, array $options=[])
 
 upsertCv (array $values, array $options=[])
 
 upsertCvterm (array $values, array $options=[])
 
 upsertCvtermSynonym (array $values, array $options=[])
 
 associateCvterm (string $base_table, int $record_id, ChadoBuddyRecord $cvterm, array $options=[])
 
- Public Member Functions inherited from Drupal\tripal_chado\ChadoBuddy\ChadoBuddyPluginBase
 __construct (array $configuration, $plugin_id, $plugin_definition, ChadoConnection $connection)
 
 label ()
 
 description ()
 

Static Public Member Functions

static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 

Protected Member Functions

 upsertDbxref (array $values, array $conditions, array $options=[])
 
- Protected Member Functions inherited from Drupal\tripal_chado\ChadoBuddy\ChadoBuddyPluginBase
 getTableColumns (array $chado_tables, string $filter='all')
 
 getTableCache ()
 
 addTableToCache (string $chado_table, array &$cached_tables)
 
 makeUpsertConditions (array $values, array $key_columns)
 
 makeAlias (string $name)
 
 unmakeAlias (string $name)
 
 removeTablePrefix (array $values)
 
 addConditions (object &$query, array $conditions, array $options)
 
 validateInput (array $user_values, array $valid_values)
 
 dereferenceBuddyRecord (array $values)
 
 subsetInput (array $user_values, array $valid_tables)
 
 validateOutput ($output_records, array $values)
 

Protected Attributes

object $buddy_manager
 
object $dbxref_instance
 

Additional Inherited Members

- Public Attributes inherited from Drupal\tripal_chado\ChadoBuddy\ChadoBuddyPluginBase
ChadoConnection $connection
 

Constructor & Destructor Documentation

◆ __construct()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::__construct ( array  $configuration,
  $plugin_id,
  $plugin_definition,
ChadoConnection  $connection,
ChadoBuddyPluginManager  $buddy_manager 
)

{}

Member Function Documentation

◆ associateCvterm()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::associateCvterm ( string  $base_table,
int  $record_id,
ChadoBuddyRecord  $cvterm,
array  $options = [] 
)

Add a record to a controlled vocabulary term linking table (e.g. feature_cvterm).

Parameters
string$base_tableThe base table for which the cvterm should be associated. Thus to associate a cvterm with a feature the base_table=feature and cvterm_id is added to the feature_cvterm table.
int$record_idThe primary key of the base_table to associate the cvterm with.
ChadoBuddyRecord$cvtermA cvterm object returned by any of the *Cvterm() in this service.
$options'pkey': Looking up the primary key for the base table is costly. If it is known, then pass it in as this option for better performance.

Also pass in any other columns used in the linking table, some of which may have a NOT NULL constraint. See the table below for a list of which of the following may be required: 'pub_id', 'is_not', 'rank', 'cvterm_type_id'. If not specified, then they will be looked up automatically, but this will be a slight performance hit. Disable this by specifying at least one additional column, or by setting the option 'lookup_columns' to FALSE.

Chado 1.3 defines these columns in the various linking tables: | table | pub_id | is_not | rank | cvterm_type_id | +--------------------------—+-------—+----------—+----------—+-------------—+ | analysis_cvterm | -absent | has default | has default | -absent | | cell_line_cvterm | not null | -absent | has default | -absent | | environment_cvterm | -absent | -absent | -absent | -absent | | expression_cvterm | -absent | -absent | has default | not null | | feature_cvterm | not null | has default | has default | -absent | | library_cvterm | not null | -absent | -absent | -absent | | organism_cvterm | not null | -absent | has default | -absent | | phenotype_comparison_cvterm | not null | -absent | has default | -absent | | phenotype_cvterm | -absent | -absent | has default | -absent | | stock_cvterm | not null | has default | has default | -absent | | stock_relationship_cvterm | yes null | -absent | -absent | -absent |

Returns
bool Returns TRUE if successful. Both the cvterm and the chado record indicated by $record_id MUST ALREADY EXIST.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ create()

static Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::create ( ContainerInterface  $container,
array  $configuration,
  $plugin_id,
  $plugin_definition 
)
static

Implements ContainerFactoryPluginInterface->create().

We are injecting an additional dependency here, the ChadoBuddyPluginManager, so that this buddy can have access to the Dbxref buddy.

Since we have implemented the ContainerFactoryPluginInterface this static function will be called behind the scenes when a Plugin Manager uses createInstance(). Specifically this method is used to determine the parameters to pass to the constructor.

Parameters
\Symfony\Component\DependencyInjection\ContainerInterface$container
array$configuration
string$plugin_id
mixed$plugin_definition
Returns
static

Reimplemented from Drupal\tripal_chado\ChadoBuddy\ChadoBuddyPluginBase.

◆ getCv()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::getCv ( array  $conditions,
array  $options = [] 
)

Retrieves a controlled vocabulary.

Parameters
array$conditionsAn array where the key is a column in chado and the value describes the cv you want to select. Valid keys include:
  • cv.cv_id
  • cv.name
  • cv.definition
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$options(Optional) Associative array of options.
  • 'case_insensitive' - a single key, or an array of keys to query case insensitively.
Returns
array An array of ChadoBuddyRecord objects. More specifically, (1) if the select values return a single record then we return an array containing a single ChadoBuddyRecord describing the record. (2) if the select values return multiple records, then we return an array of ChadoBuddyRecords describing the results. (3) if there are no results then we return an empty array.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ getCvterm()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::getCvterm ( array  $conditions,
array  $options = [] 
)

Retrieves a controlled vocabulary term.

Parameters
array$conditionsAn array where the key is a column in chado and the value describes the cvterm you want to select. Valid keys include:
  • cv.cv_id
  • cv.name
  • cv.definition
  • cvterm.cvterm_id
  • cvterm.cv_id
  • cvterm.name
  • cvterm.definition
  • cvterm.is_obsolete
  • cvterm.is_relationshiptype
  • dbxref.dbxref_id
  • dbxref.db_id
  • dbxref.description
  • dbxref.accession
  • dbxref.version
  • db.db_id
  • db.name
  • db.description
  • db.urlprefix
  • db.url
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$options(Optional) Associative array of options.
  • 'case_insensitive' - a single key, or an array of keys to query case insensitively.
  • 'synonyms' - set to true to enable synonym query, used internally be getCvtermSynonym()
Returns
array An array of ChadoBuddyRecord objects. More specifically, (1) if the select values return a single record then we return an array containing a single ChadoBuddyRecord describing the record. (2) if the select values return multiple records, then we return an array of ChadoBuddyRecords describing the results. (3) if there are no results then we return an empty array.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ getCvtermSynonym()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::getCvtermSynonym ( array  $conditions,
array  $options = [] 
)

Retrieves a controlled vocabulary term.

Parameters
array$conditionsAn array where the key is a column in chado and the value describes the cvterm you want to select. Valid keys include:
  • cv.cv_id
  • cv.name
  • cv.definition
  • cvterm.cvterm_id
  • cvterm.cv_id
  • cvterm.name
  • cvterm.definition
  • cvterm.is_obsolete
  • cvterm.is_relationshiptype
  • cvtermsynonym.cvtermsynonym_id
  • cvtermsynonym.cvterm_id
  • cvtermsynonym.synonym
  • cvtermsynonym.type_id
  • dbxref.dbxref_id
  • dbxref.db_id
  • dbxref.description
  • dbxref.accession
  • dbxref.version
  • db.db_id
  • db.name
  • db.description
  • db.urlprefix
  • db.url
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$options(Optional) Associative array of options.
  • 'case_insensitive' - a single key, or an array of keys to query case insensitively.
Returns
array An array of ChadoBuddyRecord objects. More specifically, (1) if the select values return a single record then we return an array containing a single ChadoBuddyRecord describing the record. (2) if the select values return multiple records, then we return an array of ChadoBuddyRecords describing the results. (3) if there are no results then we return an empty array.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ insertCv()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::insertCv ( array  $values,
array  $options = [] 
)

Add a controlled vocabulary.

Parameters
$valuesAn associative array of the values to be inserted including:
  • cv.cv_id
  • cv.name
  • cv.definition
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
$options(Optional) None supported yet. Here for consistency.
Returns
ChadoBuddyRecord The inserted ChadoBuddyRecord will be returned on success and an exception will be thrown if an error is encountered. If the record already exists then an error will be thrown. If this is not the desired behaviour then use the upsert version of this method.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ insertCvterm()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::insertCvterm ( array  $values,
array  $options = [] 
)

Add a controlled vocabulary term, including creating a dbxref entry if necessary.

Parameters
$valuesAn associative array of the values to be inserted including:
  • cv.cv_id (either cv_id, cvterm.cv_id, or cv_name required)
  • cv.name
  • cv.definition
  • cvterm.cvterm_id: Not valid for an insert.
  • cvterm.cv_id
  • cvterm.name: Required.
  • cvterm.definition
  • cvterm.is_obsolete
  • cvterm.is_relationshiptype
  • dbxref.dbxref_id
  • dbxref.db_id: Required if generating a dbxref record.
  • dbxref.description: Optional
  • dbxref.accession: Required if generating a dbxref record.
  • dbxref.version: Optional
  • db.db_id: Can be used in place of dbxref.db_id
  • db.name: valid, but has no effect for this function.
  • db.description: valid, but has no effect for this function.
  • db.urlprefix: valid, but has no effect for this function.
  • db.url: valid, but has no effect for this function.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
$options(Optional)
  • create_dbxref - set to FALSE (default TRUE) if you do not want to automatically create a dbxref if one does not already exist.
Returns
ChadoBuddyRecord The inserted ChadoBuddyRecord will be returned on success and an exception will be thrown if an error is encountered. If the record already exists then an error will be thrown. If this is not the desired behaviour then use the upsert version of this method.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ insertCvtermSynonym()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::insertCvtermSynonym ( array  $values,
array  $options = [] 
)

Add a controlled vocabulary term synonym. The existing Cvterm must already exist.

Parameters
$valuesAn associative array of the values to be inserted including:
  • cv.cv_id (either cv_id, cvterm.cv_id, or cv_name required)
  • cv.name
  • cv.definition
  • cvterm.cvterm_id: Not valid for an insert.
  • cvterm.cv_id
  • cvterm.name: Required.
  • cvterm.definition
  • cvterm.is_obsolete
  • cvterm.is_relationshiptype
  • cvtermsynonym.cvtermsynonym_id
  • cvtermsynonym.cvterm_id
  • cvtermsynonym.synonym
  • cvtermsynonym.type_id
  • dbxref.dbxref_id
  • dbxref.db_id: Required if generating a dbxref record.
  • dbxref.description: Optional
  • dbxref.accession: Required if generating a dbxref record.
  • dbxref.version: Optional
  • db.db_id: Can be used in place of dbxref.db_id
  • db.name: valid, but has no effect for this function.
  • db.description: valid, but has no effect for this function.
  • db.urlprefix: valid, but has no effect for this function.
  • db.url: valid, but has no effect for this function.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
$options(Optional) None supported yet. Here for consistency.
Returns
ChadoBuddyRecord The inserted ChadoBuddyRecord will be returned on success and an exception will be thrown if an error is encountered. If the record already exists then an error will be thrown. If this is not the desired behaviour then use the upsert version of this method.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ updateCv()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::updateCv ( array  $values,
array  $conditions,
array  $options = [] 
)

Updates an existing controlled vocabulary.

Parameters
array$valuesAn associative array of the values for the final record (i.e what you want to update the record to be) including:
  • cv.cv_id (only used for $conditions)
  • cv.name
  • cv.definition
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$conditionsAn associative array of the conditions to find the record to update. The same keys are supported as those indicated for the $values.
array$options(Optional) None supported yet. Here for consistency.
Returns
bool|ChadoBuddyRecord The updated ChadoBuddyRecord will be returned on success, FALSE will be returned if no record was found to update.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ updateCvterm()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::updateCvterm ( array  $values,
array  $conditions,
array  $options = [] 
)

Updates an existing controlled vocabulary term.

Parameters
array$valuesAn associative array of the values for the final record (i.e what you want to update the record to be) including:
  • cv.cv_id (either cv_id, cvterm.cv_id, or cv_name required)
  • cv.name
  • cv.definition
  • cvterm.cvterm_id: Not valid for an insert.
  • cvterm.cv_id
  • cvterm.name: Required.
  • cvterm.definition
  • cvterm.is_obsolete
  • cvterm.is_relationshiptype
  • dbxref.dbxref_id
  • dbxref.db_id: Required if generating a dbxref record.
  • dbxref.description: Optional
  • dbxref.accession: Required if generating a dbxref record.
  • dbxref.version: Optional
  • db.db_id: Can be used in place of dbxref.db_id
  • db.name: valid, but has no effect for this function.
  • db.description: valid, but has no effect for this function.
  • db.urlprefix: valid, but has no effect for this function.
  • db.url: valid, but has no effect for this function.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$conditionsAn associative array of the conditions to find the record to update. The same keys are supported as those indicated for the $values.
array$options(Optional) None supported yet. Here for consistency.
Returns
bool|ChadoBuddyRecord The updated ChadoBuddyRecord will be returned on success, FALSE will be returned if no record was found to update.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ updateCvtermSynonym()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::updateCvtermSynonym ( array  $values,
array  $conditions,
array  $options = [] 
)

Updates an existing controlled vocabulary term synonym.

Parameters
array$valuesAn associative array of the values for the final record (i.e what you want to update the record to be) including:
  • cv.cv_id (either cv_id, cvterm.cv_id, or cv_name required)
  • cv.name
  • cv.definition
  • cvterm.cvterm_id: Not valid for an insert.
  • cvterm.cv_id
  • cvterm.name: Required.
  • cvterm.definition
  • cvterm.is_obsolete
  • cvterm.is_relationshiptype
  • cvtermsynonym.cvtermsynonym_id
  • cvtermsynonym.cvterm_id
  • cvtermsynonym.synonym
  • cvtermsynonym.type_id
  • dbxref.dbxref_id
  • dbxref.db_id: Required if generating a dbxref record.
  • dbxref.description: Optional
  • dbxref.accession: Required if generating a dbxref record.
  • dbxref.version: Optional
  • db.db_id: Can be used in place of dbxref.db_id
  • db.name: valid, but has no effect for this function.
  • db.description: valid, but has no effect for this function.
  • db.urlprefix: valid, but has no effect for this function.
  • db.url: valid, but has no effect for this function.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$conditionsAn associative array of the conditions to find the record to update. The same keys are supported as those indicated for the $values.
array$options(Optional) None supported yet. Here for consistency.
Returns
bool|ChadoBuddyRecord The updated ChadoBuddyRecord will be returned on success, FALSE will be returned if no record was found to update.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ upsertCv()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::upsertCv ( array  $values,
array  $options = [] 
)

Insert a controlled vocabulary if it doesn't yet exist OR update it if it does.

Parameters
array$valuesAn associative array of the values for the final record including:
  • cv.cv_id
  • cv.name
  • cv.definition
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$options(Optional) None supported yet. Here for consistency.
Returns
ChadoBuddyRecord The inserted/updated ChadoBuddyRecord will be returned on success.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ upsertCvterm()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::upsertCvterm ( array  $values,
array  $options = [] 
)

Insert a controlled vocabulary term if it doesn't yet exist OR update it if it does.

Parameters
array$valuesAn associative array of the values for the final record including:
  • cv.cv_id (either cv_id, cvterm.cv_id, or cv_name required)
  • cv.name
  • cv.definition
  • cvterm.cvterm_id: Not valid for an insert.
  • cvterm.cv_id
  • cvterm.name: Required.
  • cvterm.definition
  • cvterm.is_obsolete
  • cvterm.is_relationshiptype
  • dbxref.dbxref_id
  • dbxref.db_id: Required if generating a dbxref record.
  • dbxref.description: Optional
  • dbxref.accession: Required if generating a dbxref record.
  • dbxref.version: Optional
  • db.db_id: Can be used in place of dbxref.db_id
  • db.name: valid, but has no effect for this function.
  • db.description: valid, but has no effect for this function.
  • db.urlprefix: valid, but has no effect for this function.
  • db.url: valid, but has no effect for this function.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$options(Optional) None supported yet. Here for consistency.
Returns
ChadoBuddyRecord The inserted/updated ChadoBuddyRecord will be returned on success.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ upsertCvtermSynonym()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::upsertCvtermSynonym ( array  $values,
array  $options = [] 
)

Insert a controlled vocabulary term synonym if it doesn't yet exist OR update it if it does.

Parameters
array$valuesAn associative array of the values for the final record including:
  • cv.cv_id (either cv_id, cvterm.cv_id, or cv_name required)
  • cv.name
  • cv.definition
  • cvterm.cvterm_id: Not valid for an insert.
  • cvterm.cv_id
  • cvterm.name: Required.
  • cvterm.definition
  • cvterm.is_obsolete
  • cvterm.is_relationshiptype
  • cvtermsynonym.cvtermsynonym_id
  • cvtermsynonym.cvterm_id
  • cvtermsynonym.synonym
  • cvtermsynonym.type_id
  • dbxref.dbxref_id
  • dbxref.db_id: Required if generating a dbxref record.
  • dbxref.description: Optional
  • dbxref.accession: Required if generating a dbxref record.
  • dbxref.version: Optional
  • db.db_id: Can be used in place of dbxref.db_id
  • db.name: valid, but has no effect for this function.
  • db.description: valid, but has no effect for this function.
  • db.urlprefix: valid, but has no effect for this function.
  • db.url: valid, but has no effect for this function.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$options(Optional) None supported yet. Here for consistency.
Returns
ChadoBuddyRecord The inserted/updated ChadoBuddyRecord will be returned on success.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ upsertDbxref()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::upsertDbxref ( array  $values,
array  $conditions,
array  $options = [] 
)
protected

A helper function to add or update a dbxref for a cvterm, this will filter out extra non-applicable fields that the Cvterm function here may have.

Member Data Documentation

◆ $buddy_manager

object Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::$buddy_manager
protected

Used to store the manager so we can create a buddy

◆ $dbxref_instance

object Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoCvtermBuddy::$dbxref_instance
protected

Provide the dbxref instance


The documentation for this class was generated from the following file: