Tripal
Functions
Chado Schema

Functions

 Drupal\tripal_chado\api\ChadoSchema::getBaseTables ()
 
 Drupal\tripal_chado\api\ChadoSchema::checkColumnExists ($table, $column)
 
 Drupal\tripal_chado\api\ChadoSchema::checkColumnType ($table, $column, $expected_type=NULL)
 
 Drupal\tripal_chado\api\ChadoSchema::checkSequenceExists ($table, $column, $sequence_name=NULL)
 
 chado_table_exists ($table, $chado_schema=NULL)
 
 chado_column_exists ($table, $column, $chado_schema=NULL)
 
 chado_sequence_exists ($sequence, $chado_schema=NULL)
 
 chado_index_exists ($table, $name, $no_suffix=FALSE, $chado_schema=NULL)
 
 chado_add_index ($table, $name, $fields, $chado_schema=NULL)
 
 chado_dbschema_exists ($chado_schema)
 
 chado_is_local ($force_recheck=FALSE, $chado_schema=NULL)
 
 chado_is_installed ($chado_schema=NULL)
 
 chado_get_version ($exact=FALSE, $warn_if_unsupported=FALSE, $chado_schema=NULL)
 
 chado_get_table_names ($include_custom=NULL, $chado_schema=NULL)
 
 chado_get_schema ($table, $chado_schema=NULL)
 
 chado_get_custom_table_schema ($table, $chado_schema=NULL)
 
 chado_get_base_tables ($chado_schema=NULL)
 

Detailed Description

Provides an application programming interface (API) for describing Chado tables. This API consists of a set of functions, one for each table in Chado. Each function simply returns a Drupal style array that defines the table.

Because Drupal 6 does not handle foreign key (FK) relationships, however FK relationships are needed to for Tripal Views. Therefore, FK relationships have been added to the schema defintitions below.

The functions provided in this documentation should not be called as is, but if you need the Drupal-style array definition for any table, use the following function call:

$table_desc = chado_get_schema($table)

where the variable $table contains the name of the table you want to retireve. The chado_get_schema function determines the appropriate version of Chado and uses the Drupal hook infrastructure to call the appropriate hook function to retrieve the table schema.

Function Documentation

◆ chado_add_index()

chado_add_index (   $table,
  $name,
  $fields,
  $chado_schema = NULL 
)

A Chado-aware replacement for the db_add_index() function.

Parameters
string$tableThe table to be altered.
string$nameThe name of the index.
string$fieldsAn array of field names.
string$chado_schemaThe name of the chado schema you would like to add the index to.
Returns
bool The return value of the create index query.

◆ chado_column_exists()

chado_column_exists (   $table,
  $column,
  $chado_schema = NULL 
)

Check that any given column in a Chado table exists.

This function is necessary because Drupal's db_field_exists() will not look in any other schema but the one where Drupal is installed

Parameters
string$tableThe name of the chado table.
string$columnThe name of the column in the chado table.
string$chado_schemaThe name of the chado schema you want to check a column in.
Returns
bool TRUE if the column exists for the table in the chado schema and FALSE if it does not.

◆ chado_dbschema_exists()

chado_dbschema_exists (   $chado_schema)

Check that any given schema exists.

Parameters
string$schemaThe name of the schema to check the existence of
Returns
bool TRUE/FALSE depending upon whether or not the schema exists.

◆ chado_get_base_tables()

chado_get_base_tables (   $chado_schema = NULL)

Returns all chado base tables.

Base tables are those that contain the primary record for a data type. For example, feature, organism, stock, are all base tables. Other tables include linker tables (which link two or more base tables), property tables, and relationship tables. These provide additional information about primary data records and are therefore not base tables. This function retrieves only the list of tables that are considered 'base' tables.

Parameters
string$chado_schemaThe chado schema you are interested in.
Returns
array An array of base table names.

◆ chado_get_custom_table_schema()

chado_get_custom_table_schema (   $table,
  $chado_schema = NULL 
)

Retrieves the schema in an array for the specified custom table.

Parameters
string$tableThe name of the table to create.
string$chado_schemaThe name of the chado schema you would like to get the custom table from.
Returns
array A Drupal-style Schema API array definition of the table. Returns FALSE on failure.

◆ chado_get_schema()

chado_get_schema (   $table,
  $chado_schema = NULL 
)

Retrieves the chado tables Schema API array.

Parameters
string$tableThe name of the table to retrieve. The function will use the appopriate Tripal chado schema API hooks (e.g. v1.11 or v1.2).
string$chado_schemaThe name of the chado schema you would like to get the table schema for.
Returns
array A Drupal Schema API array defining the table.

◆ chado_get_table_names()

chado_get_table_names (   $include_custom = NULL,
  $chado_schema = NULL 
)

Retrieves the list of tables in the Chado schema. By default it only returns the default Chado tables, but can return custom tables added to the Chado schema if requested.

Parameters
bool$include_customOptional. Set as TRUE to include any custom tables created in the Chado schema. Custom tables are added to Chado using the tripal_chado_chado_create_table() function.
string$chado_schemaThe schema you want table names from.
Returns
array An associative array where the key and value pairs are the Chado table names.

◆ chado_get_version()

chado_get_version (   $exact = FALSE,
  $warn_if_unsupported = FALSE,
  $chado_schema = NULL 
)

Returns the version number of the currently installed Chado instance. It can return the real or effective version. Note, this function is executed in the hook_init() of the tripal_chado module which then sets the $GLOBAL['exact_chado_version'] and $GLOBAL['chado_version'] variable. You can access these variables rather than calling this function.

Parameters
bool$exactSet this argument to 1 to retrieve the exact version that is installed. Otherwise, this function will set the version to the nearest 'tenth'. Chado versioning numbers in the hundreds represent changes to the software and not the schema. Changes in the tenth's represent changes in the schema.
bool$warn_if_unsupportedIf the currently installed version of Chado is not supported by Tripal this generates a Drupal warning.
string$chado_schemaThe name of the schema you want to check the version of.
Returns
string The version of Chado

@upgrade

◆ chado_index_exists()

chado_index_exists (   $table,
  $name,
  $no_suffix = FALSE,
  $chado_schema = NULL 
)

A Chado-aware replacement for the db_index_exists() function.

Parameters
string$tableThe table to be altered.
string$nameThe name of the index.
string$chado_schemaThe name of the chado schema you would like to look in.
Returns
bool TRUE if the index exists and FALSE otherwise.

◆ chado_is_installed()

chado_is_installed (   $chado_schema = NULL)

Check whether chado is installed (either in the same or a different database)

Parameters
string$chado_schemaThe name of the chado schema you want to check the existence of.
Returns
bool TRUE/FALSE depending upon whether chado is installed.

◆ chado_is_local()

chado_is_local (   $force_recheck = FALSE,
  $chado_schema = NULL 
)

Check that the Chado schema exists within the local database

Parameters
bool$force_recheckIndicate whether or not to use the cached value.
string$chado_schemaThe schema to check if it's local.
Returns
bool TRUE/FALSE depending upon whether it exists

@upgrade

◆ chado_sequence_exists()

chado_sequence_exists (   $sequence,
  $chado_schema = NULL 
)

Check that any given column in a Chado table exists.

This function is necessary because Drupal's db_field_exists() will not look in any other schema but the one where Drupal is installed

Parameters
string$sequenceThe name of the sequence.
string$chado_schemaThe name of the chado schema to check in.
Returns
bool TRUE if the seqeuence exists in the chado schema and FALSE if it does not.

◆ chado_table_exists()

chado_table_exists (   $table,
  $chado_schema = NULL 
)

Check that any given Chado table exists.

This function is necessary because Drupal's db_table_exists() function will not look in any other schema but the one where Drupal is installed

Parameters
string$tableThe name of the chado table whose existence should be checked.
string$chado_schemaThe name of the chado schema you expect the table to exist in.
Returns
bool TRUE if the table exists in the chado schema and FALSE if it does not.

◆ checkColumnExists()

Drupal\tripal_chado\api\ChadoSchema::checkColumnExists (   $table,
  $column 
)

Check that any given column in a Chado table exists.

This function is necessary because Drupal's db_field_exists() will not look in any other schema but the one where Drupal is installed

Parameters
$tableThe name of the chado table.
$columnThe name of the column in the chado table.
Returns
TRUE if the column exists for the table in the chado schema and FALSE if it does not.

◆ checkColumnType()

Drupal\tripal_chado\api\ChadoSchema::checkColumnType (   $table,
  $column,
  $expected_type = NULL 
)

Check that any given column in a Chado table exists.

This function is necessary because Drupal's db_field_exists() will not look in any other schema but the one where Drupal is installed

Parameters
$tableThe name of the chado table.
$columnThe name of the column in the chado table.
$type(OPTIONAL) The PostgreSQL type to check for. If not supplied it will be looked up via the schema (PREFERRED).
Returns
TRUE if the column type matches what we expect and FALSE if it does not.

◆ checkSequenceExists()

Drupal\tripal_chado\api\ChadoSchema::checkSequenceExists (   $table,
  $column,
  $sequence_name = NULL 
)

Check that any given sequence in a Chado table exists.

Parameters
tableThe name of the table the sequence is used in.
columnThe name of the column the sequence is used to populate.
Returns
TRUE if the seqeuence exists in the chado schema and FALSE if it does not.

◆ getBaseTables()

Drupal\tripal_chado\api\ChadoSchema::getBaseTables ( )

Returns all chado base tables.

Base tables are those that contain the primary record for a data type. For example, feature, organism, stock, are all base tables. Other tables include linker tables (which link two or more base tables), property tables, and relationship tables. These provide additional information about primary data records and are therefore not base tables. This function retrieves only the list of tables that are considered 'base' tables.

Returns
An array of base table names.