123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <?php
- function chado_get_analysis($identifier, $options) {
-
- if (!isset($options['include_fk'])) {
-
- $options['include_fk'] = array();
- }
-
- if (!is_array($identifiers)) {
- tripal_report_error(
- 'tripal_stock_api',
- TRIPAL_ERROR,
- "chado_get_stock: The identifier passed in is expected to be an array with the key
- matching a column name in the analysis table (ie: analysis_id or name). You passed in %identifier.",
- array(
- '%identifier'=> print_r($identifiers, TRUE)
- )
- );
- }
- elseif (empty($identifiers)) {
- tripal_report_error(
- 'tripal_stock_api',
- TRIPAL_ERROR,
- "chado_get_stock: You did not pass in anything to identify the analysis you want. The identifier
- is expected to be an array with the key matching a column name in the analysis table
- (ie: stock_id or name). You passed in %identifier.",
- array(
- '%identifier'=> print_r($identifiers, TRUE)
- )
- );
- }
-
- if (isset($identifiers['property'])) {
- $property = $identifiers['property'];
- unset($identifiers['property']);
- $analysis = chado_get_record_with_property(
- array('table' => 'analysis', 'base_records' => $identifiers),
- array('type_name' => $property)
- );
- }
-
-
- else {
-
- $analysis = chado_generate_var(
- 'analysis',
- $identifiers,
- $options
- );
- }
-
- if (is_array($analysis)) {
- tripal_report_error(
- 'tripal_analysis_api',
- TRIPAL_ERROR,
- "chado_get_analysis: The identifiers you passed in were not unique. You passed in %identifier.",
- array(
- '%identifier'=> print_r($identifiers, TRUE)
- )
- );
- }
-
-
- elseif ($analysis === FALSE) {
- tripal_report_error(
- 'tripal_analysis_api',
- TRIPAL_ERROR,
- "chado_get_analysis: chado_generate_var() failed to return a analysis based on the identifiers
- you passed in. You should check that your identifiers are correct, as well as, look
- for a chado_generate_var error for additional clues. You passed in %identifier.",
- array(
- '%identifier'=> print_r($identifiers, TRUE)
- )
- );
- }
-
- else {
- return $analysis;
- }
- }
- function chado_get_analysis_select_options($syncd_only = TRUE) {
- $analysis_list = array();
- $analysis_list[] = 'Select an analysis';
- if ($syncd_only) {
- $sql = "
- SELECT *
- FROM [chado_analysis] CA
- INNER JOIN {analysis} A ON A.analysis_id = CO.analysis_id
- ORDER BY A.name
- ";
- $analyses = chado_query($sql);
-
- foreach ($analyses as $analysis) {
- $analysis_list[$analysis->analysis_id] = $analysis->name;
- }
- }
- else {
-
- $csql = "SELECT * FROM {analysis} ORDER BY name";
- $analyses = chado_query($csql);
-
- foreach ($analyses as $analysis) {
- $analysis_list[$analysis->analysis_id] = $analysis->name;
- }
- }
- return $analysis_list;
- }
|