Tripal
Functions
Tripal_chado_DEPRECATED_api
Collaboration diagram for Tripal_chado_DEPRECATED_api:

Functions

 tripal_chado_publish_records ($values, $job_id=NULL)
 
 tripal_get_chado_tokens ($base_table)
 
 tripal_replace_chado_tokens ($string, $record)
 
 tripal_chado_migrate_tripal_content_type ($type=[])
 
 tripal_add_mview ($name, $modulename, $mv_schema, $query, $comment=NULL, $redirect=TRUE)
 
 tripal_edit_mview ($mview_id, $name, $modulename, $mv_table, $mv_specs, $indexed, $query, $special_index, $comment=NULL, $mv_schema=NULL)
 
 tripal_get_mview_id ($view_name)
 
 tripal_refresh_mview ($mview_id)
 
 tripal_get_mviews ()
 
 tripal_delete_mview ($mview_id)
 
 tripal_populate_mview ($mview_id)
 
 hook_tripal_get_schema_name_alter ($schema_name, $context)
 
 tripal_get_schema_name ($schema='chado')
 
 tripal_add_chado_semweb_table ($chado_table)
 
 tripal_associate_chado_semweb_term ($chado_table, $chado_column, $term, $update=FALSE)
 
 tripal_get_chado_semweb_term ($chado_table, $chado_column, $options=[])
 
 tripal_format_chado_semweb_term ($cvterm)
 
 tripal_get_chado_semweb_column ($chado_table, $term)
 

Detailed Description

Deprecated legacy api code.

Function Documentation

◆ hook_tripal_get_schema_name_alter()

hook_tripal_get_schema_name_alter (   $schema_name,
  $context 
)

Alter the name of the schema housing Chado and/or Drupal.

This example implementation shows a solution for the case where your chado database was well established in the "public" schema and you added Drupal later in a "drupal" schema. Please note that this has not been tested and while we can ensure that Tripal will work as expected, we have no control over whether Drupal is compatible with not being in the public schema. That's why we recommened the organization we have (ie: Chado in a "chado" schema and Drupal in the "public schema).

Parameters
$schema_nameThe current name of the schema as known by Tripal. This is likely the default set in tripal_get_schema_name() but in the case of multiple alter hooks, it might be different.
$contextThis is an array of items to provide context.
  • schema: this is the schema that was passed to tripal_get_schema_name() and will be either "chado" or "drupal". This should be used to determine you are changing the name of the correct schema.

◆ tripal_add_chado_semweb_table()

tripal_add_chado_semweb_table (   $chado_table)

Adds a new Chado table to the semantic web support for Chado.

Newly added tables (i.e. custom tables) need to be integrated into the semantic web infrastructure. After a new table is created and added to the Chado schema, this function should be called to indicate that the table should be included in the semantic web. No associations are made for the columns. The associations should be added using the tripal_associate_chado_semweb_term() function.

If the table has already been added previously then this function does nothing. It will not overwrite existing assocations.

Temporary tables (e.g. Tripal tables that begin with 'tripal_' and end with '_temp', are not supported.

Parameters
$chado_tableThe name of the Chado table.

◆ tripal_add_mview()

tripal_add_mview (   $name,
  $modulename,
  $mv_schema,
  $query,
  $comment = NULL,
  $redirect = TRUE 
)

Add a materialized view to the chado database to help speed data access. This function supports the older style where postgres column specifications are provided using the $mv_table, $mv_specs and $indexed variables. It also supports the newer preferred method where the materialized view is described using the Drupal Schema API array.

Parameters
$nameThe name of the materialized view.
$modulenameThe name of the module submitting the materialized view (e.g. 'tripal_library').
$mv_schemaIf using the newer Schema API array to define the materialized view then this variable should contain the array or a string representation of the array.
$queryThe SQL query that loads the materialized view with data.
$commentA string containing a description of the materialized view.
$redirectOptional (default: TRUE). By default this function redirects back to admin pages. However, when called by Drush we don't want to redirect. This parameter allows this to be used as a true API function.

◆ tripal_associate_chado_semweb_term()

tripal_associate_chado_semweb_term (   $chado_table,
  $chado_column,
  $term,
  $update = FALSE 
)

Associates a controlled vocabulary term with a field in a Chado table.

For sharing of data via the semantic web we need to associate a term from a controlled vocabulary with every column of every table in Chado.

Temporary tables (e.g. Tripal tables that begin with 'tripal_' and end with '_temp', are not supported.

Parameters
$chado_tableThe name of the table in Chado. This argument is optional. If left empty or set to NULL then all fields in all Chado tables with that have the $column_name will be associated with the provided $term.
$chado_columnThe column name in the Chado table to which the term should be associated.
$termA cvterm object as returned by chado_generate_var().
$updateSet to TRUE if the association should be updated to use the new term if a term is already associated with the table and column. Default is FALSE. If not TRUE and a term is already associated, then no change occurs.
Returns
boolean Returns TRUE if the association was made successfully and FALSE otherwise.

◆ tripal_chado_migrate_tripal_content_type()

tripal_chado_migrate_tripal_content_type (   $type = [])

Migrate Tripal content types

Migrate specified Tripal content type and publish all its content. The content type will be created if it does not already exist.

Parameters
$typeA type array specifying the vocabular, accession, term_name, and chado data_table e.g. $type = array( 'vocabulary' => 'OBI', 'accession' => '0100026', 'term_name' => 'organism', 'storage_args' => array ( 'data_table' => $table ) )

◆ tripal_chado_publish_records()

tripal_chado_publish_records (   $values,
  $job_id = NULL 
)

Publishes content in Chado as a new TripalEntity entity.

Parameters
$valuesA key/value associative array that supports the following keys:
  • bundle_name: The name of the the TripalBundle (e.g. bio_data-12345).
$job_id(Optional) The numeric job ID as provided by the Tripal jobs system. There is no need to specify this argument if this function is being called outside of the jobs systems.
Returns
boolean TRUE if all of the records of the given bundle type were published, and FALSE if a failure occured.

◆ tripal_delete_mview()

tripal_delete_mview (   $mview_id)

Does the specified action for the specified Materialized View.

Parameters
$opThe action to be taken. One of update or delete.
$mview_idThe unique ID of the materialized view for the action to be performed on.

◆ tripal_edit_mview()

tripal_edit_mview (   $mview_id,
  $name,
  $modulename,
  $mv_table,
  $mv_specs,
  $indexed,
  $query,
  $special_index,
  $comment = NULL,
  $mv_schema = NULL 
)

Edits a materialized view to the chado database to help speed data access. This function supports the older style where postgres column specifications are provided using the $mv_table, $mv_specs and $indexed variables. It also supports the newer preferred method where the materialized view is described using the Drupal Schema API array.

Parameters
$mview_idThe mview_id of the materialized view to edit.
$nameThe name of the materialized view.
$modulenameThe name of the module submitting the materialized view (e.g. 'tripal_library').
$mv_tableThe name of the table to add to chado. This is the table that can be queried.
$mv_specsThe table definition.
$indexedThe columns that are to be indexed.
$queryThe SQL query that loads the materialized view with data.
$special_indexcurrently not used.
$commentA string containing a description of the materialized view.
$mv_schemaIf using the newer Schema API array to define the materialized view then this variable should contain the array.

◆ tripal_format_chado_semweb_term()

tripal_format_chado_semweb_term (   $cvterm)

Formats a controlled vocabulary term from Chado for use with Tripal.

Parameters
$cvtermA cvterm object.
Returns
The semantic web name for the term.

◆ tripal_get_chado_semweb_column()

tripal_get_chado_semweb_column (   $chado_table,
  $term 
)

Retreive the column name in a Chado table that matches a given term.

Parameters
$chado_tableThe name of the Chado table.
$termThe term. This can be a term name or a unique identifer of the form {db}:{accession} or of the form {db}__{term_name}.
Returns
The name of the Chado column that matches the given term or FALSE if the term is not mapped to the Chado table.

◆ tripal_get_chado_semweb_term()

tripal_get_chado_semweb_term (   $chado_table,
  $chado_column,
  $options = [] 
)

Retrieves the term that maps to the given Chado table and field.

Parameters
$chado_tableThe name of the Chado table.
$chado_columnThe name of the Chado field.
$optionsAn associative array of one or more of the following keys: -return_object: Set to TRUE to return the cvterm object rather than the string version of the term.
Returns
Returns a string-based representation of the term (e.g. SO:0000704). If the 'return_object' options is provided then a cvterm object is returned. returns NULL if no term is mapped to the table and column.

◆ tripal_get_chado_tokens()

tripal_get_chado_tokens (   $base_table)

Returns an array of tokens based on Tripal Entity Fields.

Parameters
$base_tableThe name of a base table in Chado.
Returns
An array of tokens where the key is the machine_name of the token.

◆ tripal_get_mview_id()

tripal_get_mview_id (   $view_name)

Retrieve the materialized view_id given the name.

Parameters
$view_nameThe name of the materialized view.
Returns
The unique identifier for the given view.

◆ tripal_get_mviews()

tripal_get_mviews ( )

Retrieves the list of materialized view IDs and their names.

Returns
An array of objects with the following properties: mview_id, name.

◆ tripal_get_schema_name()

tripal_get_schema_name (   $schema = 'chado')

Retrieve the name of the PostgreSQL schema housing Chado or Drupal.

Parameters
$schemaWehter you want the schema name for 'chado' or 'drupal'. Chado is the default.
Returns
The name of the PostgreSQL schema housing the $schema specified.

◆ tripal_populate_mview()

tripal_populate_mview (   $mview_id)

Update a Materialized View.

Parameters
$mview_idThe unique identifier for the materialized view to be updated.
Returns
True if successful, FALSE otherwise.

◆ tripal_refresh_mview()

tripal_refresh_mview (   $mview_id)

Populates the specified Materialized View.

Parameters
$mview_idThe unique ID of the materialized view for the action to be performed on.

◆ tripal_replace_chado_tokens()

tripal_replace_chado_tokens (   $string,
  $record 
)

Replace all Chado Tokens in a given string.

NOTE: If there is no value for a token then the token is removed.

Parameters
string$stringThe string containing tokens.
$recordA Chado record as generated by chado_generate_var()
Returns
The string will all tokens replaced with values.