| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 | <?php/** * @file * Wrapper functions to provide backwards compatibility for the tripal stock api *//** * @deprecated Restructured API to make naming more readable and consistent. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now. * This function has been replaced by tripal_get_stock(). * * @see tripal_get_stock(). */function tripal_stock_get_stock_by_nid($nid) {  tripal_report_error(    'tripal_deprecated',    TRIPAL_NOTICE,    "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",    array(      '%old_function'=>'tripal_stock_get_stock_by_nid',      '%new_function' => 'tripal_get_stock'    )  );  return tripal_get_stock(array('nid' => $nid));}/** * @deprecated Restructured API to make naming more readable and consistent. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now. * This function has been replaced by tripal_get_stock(). * * @see tripal_get_stock(). */function tripal_stock_get_stock_by_stock_id($stock_id) {  tripal_report_error(    'tripal_deprecated',    TRIPAL_NOTICE,    "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",    array(      '%old_function'=>'tripal_stock_get_stock_by_stock_id',      '%new_function' => 'tripal_get_stock'    )  );  return tripal_get_stock(array('stock_id' => $stock_id));}/** * @deprecated Restructured API to make naming more readable and consistent. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now. * This function has been replaced by tripal_get_multiple_stocks(). * * @see tripal_get_multiple_stocks(). */function tripal_stock_get_all_stocks() {  tripal_report_error(    'tripal_deprecated',    TRIPAL_NOTICE,    "DEPRECATED: %old_function has been completely deprecated. There are often so many     stocks in a chado database that it is unlikely a user really wants all of them.",    array(      '%old_function'=>'tripal_stock_get_all_stocks'    )  );  $sql = "SELECT stock_id, nid from {chado_stock}";  $resource = db_query($sql);  $stocks = array();  while ($r = $resource->fetchObject()) {    $node = node_load($r->nid);    if ($node) {      $stocks[$r->stock_id] = $node;    }  }  return $stocks;}/** * @deprecated Restructured API to make naming more readable and consistent. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now. * This function has been replaced by tripal_get_multiple_stocks(). * * @see tripal_get_multiple_stocks(). */function tripal_stock_get_stocks($values) {  tripal_report_error(    'tripal_deprecated',    TRIPAL_NOTICE,    "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",    array(      '%old_function'=>'tripal_stock_get_stocks',      '%new_function' => 'tripal_get_multiple_stocks'    )  );  return tripal_get_multiple_stocks($values);}/** * @deprecated Restructured API to make naming more readable and consistent. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now. * This function has been replaced by tripal_get_stock(). * * @see tripal_get_stock(). */function tripal_stock_get_stocks_by_stockprop($stockprop_values, $stock_values) {  tripal_report_error(    'tripal_deprecated',    TRIPAL_NOTICE,    "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",    array(      '%old_function'=>'tripal_stock_get_stocks_by_stockprop',      '%new_function' => 'tripal_get_stock'    )  );  $stock_values['property'] = $stockprop_values;  return tripal_get_multiple_stocks($stock_values);}/** * @deprecated Restructured API to make naming more readable and consistent. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now. * This function has been replaced by tripal_get_stock(). * * Return all stocks with a given name identifier *  which might match stock.name, stock.uniquename, dbxref.accession, *  stockprop.value where stockprop.type='synonym' * * @param $name *   The name identfier to be used * @param $organism_id *   The stock.organism_id of the stock to be selected * * @return *   An array of stock node objects * * @see tripal_get_stock(). */function tripal_stock_get_stock_by_name_identifier($name, $organism_id) {  tripal_report_error(    'tripal_deprecated',    TRIPAL_NOTICE,    "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",    array(      '%old_function'=>'tripal_stock_get_stock_by_name_identifier',      '%new_function' => 'tripal_get_stock'    )  );  $stock_ids = array();  $options = array(    'case_insensitive_columns' => array('name', 'uniquename', 'accession', 'value')  );  // where name_identifier = stock.name-------------------------------  $current_stocks = chado_select_record('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 = chado_select_record('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 = chado_select_record('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 = chado_select_record('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 = chado_select_record('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;}
 |