function tripal_stock_get_stock_by_name_identifier
2.x tripal_stock.DEPRECATED.inc | tripal_stock_get_stock_by_name_identifier($name, $organism_id) |
3.x tripal_stock.DEPRECATED.inc | tripal_stock_get_stock_by_name_identifier($name, $organism_id) |
1.x tripal_stock.api.inc | tripal_stock_get_stock_by_name_identifier($name, $organism_id) |
Purpose: Return all stocks with a given name identifier which might match stock.name, stock.uniquename, dbxref.accession, stockprop.value where stockprop.type='synonym'
Parameters
$name: The name identfier to be used
$organism_id: The stock.organism_id of the stock to be selected
Return value
An array of stock node objects
Related topics
2 calls to tripal_stock_get_stock_by_name_identifier()
- tripal_stock_add_ONE_relationship_form_validate in tripal_stock/
includes/ tripal_stock-relationships.inc - tripal_stock_edit_ALL_relationships_form_validate in tripal_stock/
includes/ tripal_stock-relationships.inc
File
- tripal_stock/
api/ tripal_stock.api.inc, line 208 - Provides an application programming interface (API) to manage stocks
Code
function tripal_stock_get_stock_by_name_identifier($name, $organism_id) {
$stock_ids = array();
$options = array(
'case_insensitive_columns' => array('name', 'uniquename', 'accession', 'value')
);
// where name_identifier = stock.name-------------------------------
$current_stocks = tripal_core_chado_select('stock', array('stock_id'),
array(
'name' => $name,
'organism_id' => $organism_id,
),
array(
'case_insensitive_columns' => array('name'),
)
);
if (!empty($current_stocks)) {
foreach ($current_stocks as $c) {
$stock_ids[] = $c->stock_id;
}
}
// where name_identifier = stock.uniquename-------------------------------
$current_stocks = tripal_core_chado_select('stock', array('stock_id'),
array(
'uniquename' => $name,
'organism_id' => $organism_id,
),
array(
'case_insensitive_columns' => array('uniquename'),
)
);
if (!empty($current_stocks)) {
foreach ($current_stocks as $c) {
$stock_ids[] = $c->stock_id;
}
}
// where name_identifier = dbxref.accession-------------------------------
// linked to stock through stock.dbxref
$current_stocks = tripal_core_chado_select('stock', array('stock_id'),
array(
'dbxref_id' => array(
'accession' => $name,
),
'organism_id' => $organism_id,
),
array(
'case_insensitive_columns' => array('accession'),
)
);
if (!empty($current_stocks)) {
foreach ($current_stocks as $c) {
$stock_ids[] = $c->stock_id;
}
}
// linked to stock through stock_dbxref?
$current_stocks = tripal_core_chado_select('stock_dbxref', array('stock_id'),
array(
'dbxref_id' => array(
'accession' => $name,
),
'stock_id' => array(
'organism_id' => $organism_id,
),
),
array(
'case_insensitive_columns' => array('accession'),
)
);
if (!empty($current_stocks)) {
foreach ($current_stocks as $c) {
$stock_ids[] = $c->stock_id;
}
}
// where name_identifier = stockprop.value-------------------------------
// where type='synonym'
$current_stocks = tripal_core_chado_select('stockprop', array('stock_id'),
array(
'stock_id' => array(
'organism_id' => $organism_id,
),
'type_id' => array(
'cv_id' => variable_get('chado_stock_prop_types_cv', 'null'),
'name' => 'synonym',
),
'value' => $name,
),
array(
'case_insensitive_columns' => array('value'),
)
);
if (!empty($current_stocks)) {
foreach ($current_stocks as $c) {
$stock_ids[] = $c->stock_id;
}
}
// Change from stock_ids to nodes-----------------------------------
$stock_ids = array_filter($stock_ids);
$stock_ids = array_unique($stock_ids);
$stocks = array();
foreach ($stock_ids as $stock_id) {
$node = tripal_stock_get_stock_by_stock_id($stock_id);
if ($node) {
$stocks[] = $node;
}
}
return $stocks;
}