Просмотр исходного кода

Changed Chado API to use array for indicating status of Chado as it was slowing down loaders the previous way

Stephen Ficklin 11 лет назад
Родитель
Сommit
5f710e226b

+ 1 - 1
tripal_analysis/tripal_analysis.install

@@ -25,7 +25,7 @@ function tripal_analysis_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_analysis'] = array(
             'title' => "tripal_analysis",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 1
tripal_bulk_loader/tripal_bulk_loader.install

@@ -270,7 +270,7 @@ function tripal_bulk_loader_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_bulk_loader'] = array(
             'title' => "tripal_bulk_loader",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 1
tripal_contact/tripal_contact.install

@@ -32,7 +32,7 @@ function tripal_contact_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_contact'] = array(
         'title' => "tripal_contact",
         'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 104 - 149
tripal_core/api/tripal_core_chado.api.inc

@@ -301,12 +301,9 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
         }
         // now check the constraint
         if (tripal_core_chado_select($table, $ukselect_cols, $ukselect_vals)) {
-          tripal_core_report_error(
-            'tripal_core',
-            TRIPAL_ERROR,
+          tripal_core_report_error('tripal_core', TRIPAL_ERROR,
             "tripal_core_chado_insert; Cannot insert duplicate record into $table table: !values",
-            array('!values' => print_r($values, TRUE)),
-            array('print' => $print_errors)
+            array('!values' => print_r($values, TRUE)), array('print' => $print_errors)
           );
           return FALSE;
         }
@@ -317,11 +314,9 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
     if (array_key_exists('primary key', $table_desc)) {
       $pkey = $table_desc['primary key'][0];
       if (array_key_exists($pkey, $insert_values)) {
-        $coptions = array('statement_name' => 'pqsel_' . $table . '_' . $pkey);
+        $coptions = array();
         if (tripal_core_chado_select($table, array($pkey), array($pkey => $insert_values[$pkey]), $coptions)) {
-          tripal_core_report_error(
-            'tripal_core',
-            TRIPAL_ERROR,
+          tripal_core_report_error('tripal_core', TRIPAL_ERROR,
             'tripal_core_chado_insert; Cannot insert duplicate primary key into !table table: !values',
             array('!table' => $table, '!values' => print_r($values, TRUE)),
             array('print' => $print_errors)
@@ -559,7 +554,7 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
         $columns[] = $field;
         $stmt_suffix .= substr($field, 0, 2);
       }
-      $options2 = array('statement_name' => 'sel_' . $table . '_' . $stmt_suffix);
+      $options2 = array();
       $results = tripal_core_chado_select($table, $columns, $match, $options2);
       if (count($results) > 0) {
         foreach ($results as $index => $pkey) {
@@ -574,18 +569,14 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
     if (is_array($value)) {
       $results = tripal_core_chado_get_foreign_key($table_desc, $field, $value);
       if (sizeof($results) > 1) {
-        tripal_core_report_error(
-          'tripal_core',
-          TRIPAL_ERROR,
+        tripal_core_report_error('tripal_core', TRIPAL_ERROR,
           'tripal_core_chado_update: When trying to find record to update, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
         );
       }
       elseif (sizeof($results) < 1) {
-        tripal_core_report_error(
-          'tripal_core',
-          TRIPAL_DEBUG,
+        tripal_core_report_error('tripal_core',TRIPAL_DEBUG,
           'tripal_core_chado_update: When trying to find record to update, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
@@ -875,14 +866,6 @@ function tripal_core_chado_delete($table, $match, $options = NULL) {
  *     An associative array containing the column names of the table as keys
  *     and the type of sort (i.e. ASC, DESC) as the values.  The results in the
  *     query will be sorted by the key values in the direction listed by the value
- *  - statement_name: the name of the prepared statement to use. If the statement
- *     has not yet been prepared it will be prepared automatically. On subsequent
- *     calls with the same statement_name only an execute on the previously
- *     prepared statement will occur.
- *  - is_prepared: TRUE or FALSE. Whether or not the statement is prepared. By
- *     default if the statement is not prepared it will be automatically.
- *     However to avoid this check, which requires a database query you can
- *     set this value to true and the check will not be performed.
  *  - is_duplicate: TRUE or FALSE.  Checks the values submited to see if
  *     they violate any of the unique constraints. If so, the record
  *     is returned, if not, FALSE is returned.
@@ -892,8 +875,7 @@ function tripal_core_chado_delete($table, $match, $options = NULL) {
  *     should specify the number of records to return and 'element' is a
  *     unique integer to differentiate between pagers when more than one
  *     appear on a page.  The 'element' should start with zero and increment by
- *     one for each pager.  The pager currently does not work with prepared queries
- *     (when using the -statement_name option).
+ *     one for each pager.  
  *
  * @return
  *  An array of results, FALSE if the query was not executed
@@ -922,7 +904,6 @@ function tripal_core_chado_delete($table, $match, $options = NULL) {
  *      ),
  *   );
  *   $options = array(
- *     'statement_name' => 'sel_feature_genus_species_cvname'
  *     'order_by' => array(
  *        'name' => 'ASC'
  *     ),
@@ -1091,17 +1072,12 @@ function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
         // and there is no default value then we cannot check if the record
         // is a duplicate so return FALSE
         else {
-          tripal_core_report_error(
-            'tripal_core',
-            TRIPAL_ERROR,
+          tripal_core_report_error('tripal_core', TRIPAL_ERROR,
             'tripal_core_chado_select: There is no value for %field thus we cannot check if this record is unique',
-            array('%field' => $field),
-            array('print' => $print_errors)
-          );
+            array('%field' => $field), array('print' => $print_errors));
           return FALSE;
         }
       }
-      $new_options['statement_name'] = $uq_sname;
 
       $results = tripal_core_chado_select($table, $new_columns, $new_values, $new_options);
       // if we have a duplicate record then return the results
@@ -1367,7 +1343,7 @@ function tripal_core_chado_get_foreign_key($table_desc, $field, $values, $option
     // TODO: what do we do if we get to this point and we have a fk
     // relationship expected but we don't have any definition for one in the
     // table schema??
-    $version = tripal_core_get_chado_version(TRUE);
+    $version = $GLOBALS["chado_version"];
     $message = t("There is no foreign key relationship defined for " . $field . " .
        To define a foreign key relationship, determine the table this foreign
        key referrs to (<foreign table>) and then implement
@@ -1839,14 +1815,7 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
           }
 
           // generate a new object for this table using the FK values in the base table.
-          // if a prepared statement is provided generate a new statement_name so that
-          // we don't conflict when we recurse.
           $new_options = $table_options;
-/*
-          if (array_key_exists('statement_name', $table_options)) {
-             $new_options['statement_name'] = "exp_" . $foreign_table . "_" . substr($left, 0, 2) . substr($right, 0, 2);
-          }
-*/
           $foreign_object = tripal_core_generate_chado_var($foreign_table, array($left => $object->{$right}), $new_options);
 
           // if the generation of the object was successful, update the base object to include it.
@@ -2133,8 +2102,7 @@ function chado_query_range($query, $args, $from, $count) {
  * @ingroup tripal_chado_api
  */
 function chado_query($sql, $args = array()) {
-
-  $is_local = tripal_core_is_chado_local();
+  $is_local = $GLOBALS["chado_is_local"];
 
   // Args should be an array
   if (!is_array($args)) {
@@ -2143,6 +2111,7 @@ function chado_query($sql, $args = array()) {
       array('%value' => $args, '%query' => $sql)
     );
     $args = array($args);
+    return FALSE;
   }
 
   // if Chado is local to the database then prefix the Chado table
@@ -2168,7 +2137,7 @@ function chado_query($sql, $args = array()) {
   // switch to another database
   else {
     $previous_db = tripal_db_set_active('chado') ;
-    $results = db_query($sql);
+    $results = db_query($sql, $args);
     tripal_db_set_active($previous_db);
   }
 
@@ -2322,7 +2291,7 @@ $cv_name, $value, $update_if_present = 0) {
     'name' => $property,
   );
 
-  $options = array('statement_name' => 'sel_cvterm_cv');
+  $options = array();
   $term = tripal_core_chado_select('cvterm', array('cvterm_id'), $values, $options);
   if (!$term or count($term) == 0) {
     watchdog('tripal_core', "Cannot find property '%prop_name'.",
@@ -2347,7 +2316,7 @@ $cv_name, $value, $update_if_present = 0) {
     'rank' => $rank,
   );
 
-  $options = array('statement_name' => 'ins_' . $basetable . 'prop_' . substr($fkcol, 0, 2) . 'tyvara');
+  $options = array();
   $result = tripal_core_chado_insert($basetable . 'prop', $values, $options);
   return $result;
 }
@@ -2591,34 +2560,7 @@ function chado_table_exists($table) {
   }
   return TRUE;
 }
-/**
- * Check that the Chado schema exists within the local database
- *
- * @return
- *   TRUE/FALSE depending upon whether it exists
- */
-function tripal_core_chado_schema_exists() {
 
-  // This is postgresql-specific code to check the existence of the chado schema
-  // @coder-ignore: acting on pg_catalog schema rather then drupal schema therefore, table prefixing does not apply
-  $sql = "
-    SELECT nspname
-    FROM pg_namespace
-    WHERE
-      has_schema_privilege(nspname, 'USAGE') AND
-      nspname = 'chado'
-  ";
-  $results = db_query($sql);
-  $name = $results->fetchObject();
-  if ($name) {
-    variable_set('chado_schema_exists', FALSE);
-    return TRUE;
-  }
-  else {
-    variable_set('chado_schema_exists', TRUE);
-    return FALSE;
-  }
-}
 /**
  * Check that any given schema exists
  *
@@ -2665,10 +2607,9 @@ function tripal_core_schema_exists($schema) {
  * @ingroup tripal_core_api
  */
 function tripal_core_get_chado_tables($include_custom = NULL) {
-
-
+ 
   // first get the chado version that is installed
-  $v = tripal_core_get_chado_version();
+  $v = $GLOBALS["chado_version"];
 
   $tables = array();
   if ($v == '1.2') {
@@ -2698,18 +2639,34 @@ function tripal_core_get_chado_tables($include_custom = NULL) {
   return $tables;
 }
 /**
- * Sets a Drupal variable with the current version of Chado.  This variable
- * can then be queried later using the tripal_core_get_chado_Version
+ * 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_core module which then
+ * sets the $GLOBAL['exact_chado_version'] and $GLOBAL['chado_version'] 
+ * variable.  You can access these variables rather than calling this function.
+ *
+ * @param $exact
+ *   Set 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.
+ *
+ * @param $warn_if_unsupported
+ *   If the currently installed version of Chado is not supported by Tripal
+ *   this generates a Drupal warning.
  *
  * @returns
  *   The version of Chado
  *
  * @ingroup tripal_core_api
  */
-function tripal_core_set_chado_version() {
+function tripal_core_get_chado_version($exact = FALSE, $warn_if_unsupported = FALSE) {
+  
   global $databases;
+  $version = '';
   $is_local = 0;
-
+  
   // check that Chado is installed if not return 'uninstalled as the version'
   $chado_exists = tripal_core_chado_schema_exists();
   if (!$chado_exists) {
@@ -2720,6 +2677,7 @@ function tripal_core_set_chado_version() {
       // return uninstalled as the version
       return 'not installed';
     }
+    $is_local = 0;
     $previous_db = tripal_db_set_active('chado');
     $prop_exists = db_table_exists('chadoprop');
     tripal_db_set_active($previous_db);
@@ -2728,66 +2686,40 @@ function tripal_core_set_chado_version() {
     $is_local = 1;
     $prop_exists = db_table_exists('chado.chadoprop');
   }
-
+  
   // if the table doesn't exist then we don't know what version but we know
   // it must be 1.11 or older.
   if (!$prop_exists) {
-    return "1.11 or older";
-  }
-
-  $sql = "
-    SELECT value
-    FROM {chadoprop} CP
-      INNER JOIN {cvterm} CVT on CVT.cvterm_id = CP.type_id
-      INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id
-    WHERE CV.name = 'chado_properties' and CVT.name = 'version'
-  ";
-  if (!$is_local) {
-    $previous_db = tripal_db_set_active('chado');
-    $results = db_query($sql);
-    tripal_db_set_active($previous_db);
-  }
-  else {
-    $results = chado_query($sql);
-  }
-  $v = $results->fetchObject();
-
-  // if we don't have a version in the chadoprop table then it must be
-  // v1.11 or older
-  if (!$v) {
-    variable_set('chado_version', "1.11 or older");
-    return "1.11 or older";
+    $version = "1.11 or older";
+  }
+  else {  
+    $sql = "
+      SELECT value
+      FROM {chadoprop} CP
+        INNER JOIN {cvterm} CVT on CVT.cvterm_id = CP.type_id
+        INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id
+      WHERE CV.name = 'chado_properties' and CVT.name = 'version'
+    ";
+    if (!$is_local) {
+      $previous_db = tripal_db_set_active('chado');
+      $results = db_query($sql);
+      tripal_db_set_active($previous_db);
+    }
+    else {
+      $results = chado_query($sql);
+    }
+    $v = $results->fetchObject();
+    
+    // if we don't have a version in the chadoprop table then it must be
+    // v1.11 or older
+    if (!$v) {
+      $version =  "1.11 or older";
+    }  
+    $version =  $v->value;
   }
-
-  variable_set('chado_version', $v->value);
-  return $v->value;
-}
-/**
- * Returns the version number of the currently installed Chado instance.
- * It can return the real or effective version.
- *
- * @param $exact
- *   Set 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.
- *
- * @param $warn_if_unsupported
- *   If the currently installed version of Chado is not supported by Tripal
- *   the generatea a Drupal warning.
- *
- * @returns
- *   The version of Chado
- *
- * @ingroup tripal_core_api
- */
-function tripal_core_get_chado_version($exact = FALSE, $warn_if_unsupported = FALSE) {
-  // first get the chado version that is installed
-//  $exact_version = variable_get('chado_version', '');
-//  if (!$exact_version) {
-    $exact_version = tripal_core_set_chado_version();
-//  }
+  
+  // next get the exact Chado version that is installed
+  $exact_version = $version;
 
   // Tripal only supports v1.11 or newer.. really this is the same as v1.1
   // but at the time the v1.11 schema API was written we didn't know that so
@@ -2832,7 +2764,7 @@ function tripal_core_get_chado_version($exact = FALSE, $warn_if_unsupported = FA
 function tripal_core_get_chado_table_schema($table) {
 
   // first get the chado version that is installed
-  $v = tripal_core_get_chado_version();
+  $v = $GLOBALS["chado_version"];
 
   // get the table array from the proper chado schema
   $v = preg_replace("/\./", "_", $v); // reformat version for hook name
@@ -2958,7 +2890,34 @@ function tripal_core_clean_orphaned_nodes($table, $job_id) {
 
   return '';
 }
+/**
+ * Check that the Chado schema exists within the local database
+ *
+ * @return
+ *   TRUE/FALSE depending upon whether it exists
+ */
+function tripal_core_chado_schema_exists() {
 
+  // This is postgresql-specific code to check the existence of the chado schema
+  // @coder-ignore: acting on pg_catalog schema rather then drupal schema therefore, table prefixing does not apply
+  $sql = "
+    SELECT nspname
+    FROM pg_namespace
+    WHERE
+      has_schema_privilege(nspname, 'USAGE') AND
+      nspname = 'chado'
+  ";
+  $results = db_query($sql);
+  $name = $results->fetchObject();
+  if ($name) {
+    variable_set('chado_schema_exists', FALSE);
+    return TRUE;
+  }
+  else {
+    variable_set('chado_schema_exists', TRUE);
+    return FALSE;
+  }
+}
 /**
  * Check whether chado is installed (either in the same or a different database)
  *
@@ -2989,18 +2948,15 @@ function tripal_core_is_chado_installed() {
  * @ingroup tripal_chado_api
  */
 function tripal_core_is_chado_local() {
-  global $db_url, $db_type;
+  global $databases, $db_type;
 
-  $is_installed = tripal_core_is_chado_installed();
-  if ($is_installed) {
-    if (is_array($db_url)) {
-      if (isset($db_url['chado'])) {
-        return FALSE;
-      }
-    }
-    return TRUE;
+  // first check if chado is in the $databases variable of the settings.php file
+  if (array_key_exists('chado', $databases)) {
+    return FALSE;
   }
-  return FALSE;
+  
+  // check to make sure the chado schema exists
+  return tripal_core_chado_schema_exists();
 }
 
 /**
@@ -3035,7 +2991,6 @@ function tripal_core_is_tripal_node_type($chado_table) {
 function tripal_db_set_active($dbname  = 'default') {
   global $databases, $active_db;
 
-  $chado_exists = variable_get('chado_schema_exists', FALSE);
   if ($dbname ) {
     if ($dbname == 'chado') {
       db_query('set search_path to chado,public');

+ 1 - 1
tripal_core/includes/chado_install.inc

@@ -13,7 +13,7 @@
 function tripal_core_chado_load_form() {
 
   // we want to force the version of Chado to be set properly
-  $real_version = tripal_core_set_chado_version();
+  $real_version = tripal_core_get_chado_version(TRUE);
 
   // get the effective version.  Pass true as second argument
   // to warn the user if the current version is not compatible

+ 1 - 1
tripal_core/tripal_core.drush.inc

@@ -305,7 +305,7 @@ function drush_tripal_core_tripal_update_mview() {
  * Returns the current version of chado
  */
 function drush_tripal_core_tripal_chado_version() {
-  $version = tripal_core_get_chado_version();
+  $version = $GLOBALS["exact_chado_version"];
   drush_print('Current Chado Version: ' . $version);
 }
 

+ 15 - 8
tripal_core/tripal_core.module

@@ -36,8 +36,6 @@
  * @ingroup tripal_modules
  */
 
-
-
 require_once "api/tripal_core_chado.api.inc";
 require_once "api/tripal_core_files.api.inc";
 require_once "api/tripal_core_ahah.api.inc";
@@ -51,6 +49,7 @@ require_once "includes/custom_tables.inc";
 require_once "includes/chado_install.inc";
 require_once "includes/form_elements.inc";
 
+
 /**
  * Implements hook_init().
  * Used to set the search_path, create default content and set default variables.
@@ -64,13 +63,22 @@ function tripal_core_init() {
   drupal_add_js(drupal_get_path('module', 'tripal_core') . '/theme/js/tripal.js');
   drupal_add_css(drupal_get_path('module', 'tripal_core') . '/theme/css/tripal.css');
 
-
+  // these global variables are meant to be accessed by all Tripal
+  // modules to find the chado version installed and if Chado is local.
+  // these variables are stored as globals rather than using the drupal_set_variable
+  // functions because the Drupal functions make databaes queries and for long
+  // running loaders we don't want those queries repeatedly.
+  $GLOBALS["chado_is_installed"]  = tripal_core_is_chado_installed();
+  if ($GLOBALS["chado_is_installed"]) {
+    $GLOBALS["chado_is_local"]      = tripal_core_is_chado_local();
+    $GLOBALS["chado_version"]       = tripal_core_get_chado_version();
+    $GLOBALS["exact_chado_version"] = tripal_core_get_chado_version(TRUE);
+  }
+  
+  
   // create the 'tripal' controlled volcabulary in chado but only if it doesn't already exist, and
   // only if the chado database is present.
-  if (tripal_core_is_chado_installed()) {
-
-    // make sure the current version of chado is set
-    tripal_core_set_chado_version();
+  if ($GLOBALS["chado_is_installed"]) {
 
     // if the Tripal cv is missing then add
     $results = chado_query("SELECT * FROM {cv} WHERE name = 'tripal'");
@@ -94,7 +102,6 @@ function tripal_core_init() {
   }
 
   // add some variables for all javasript to use for building URLs
-  global $base_url;
   $theme_dir = drupal_get_path('theme', 'tripal');
   $clean_urls = variable_get('clean_url', 0);
   drupal_add_js(

+ 1 - 1
tripal_cv/tripal_cv.install

@@ -26,7 +26,7 @@ function tripal_cv_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_cv'] = array(
         'title' => "tripal_cv",
         'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 1
tripal_db/tripal_db.install

@@ -26,7 +26,7 @@ function tripal_db_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_db'] = array(
           'title' => "tripal_db",
           'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 0 - 0
tripal_feature/includes/tripal_feature-delete.inc → tripal_feature/includes/tripal_feature.delete.inc


+ 0 - 0
tripal_feature/includes/fasta_loader.inc → tripal_feature/includes/tripal_feature.fasta_loader.inc


+ 93 - 195
tripal_feature/includes/gff_loader.inc → tripal_feature/includes/tripal_feature.gff_loader.inc

@@ -567,12 +567,10 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
               'genus' => $org_matches[1],
               'species' => $org_matches[2],
             ); 
-            $options = array('statement_name' => 'sel_organism_gesp');
-            $org = tripal_core_chado_select('organism', array("*"), $values, $options);
+            $org = tripal_core_chado_select('organism', array("*"), $values);
             if (count($org) == 0) {
               if ($create_organism) {
-                $options = array('statement_name' => 'ins_organism_gesp');
-                $feature_organism = (object) tripal_core_chado_insert('organism', $values, $options);
+                $feature_organism = (object) tripal_core_chado_insert('organism', $values);
                 if (!$feature_organism) {
                   watchdog('T_gff3_loader', "Could not add the organism, '%org', from line %line. Skipping this line. ",
                     array('%org' => $attr_organism, '%line' => $line_num), WATCHDOG_ERROR); 
@@ -661,14 +659,12 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
           'uniquename'  => $landmark,
         );      
         $columns = array('count(*) as num_landmarks');
-        $options = array('statement_name' => 'sel_feature_numland');
         if ($landmark_type) {
           $select['type_id'] = array(
             'name' => $landmark_type,
           );
-          $options = array('statement_name' => 'sel_feature_numlandty');
         }      
-        $count = tripal_core_chado_select('feature', $columns, $select, $options);        
+        $count = tripal_core_chado_select('feature', $columns, $select);        
         if (!$count or count($count) == 0 or $count[0]->num_landmarks == 0) {        
           // now look for the landmark using the name rather than uniquename.
           $select = array(
@@ -676,14 +672,12 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
             'name'  => $landmark,
           );
           $columns = array('count(*) as num_landmarks');
-          $options = array('statement_name' => 'sel_feature_numlandna');              
           if ($landmark_type) {
             $select['type_id'] = array(
               'name' => $landmark_type,
             );
-            $options = array('statement_name' => 'sel_feature_numlandnaty');
           }
-          $count = tripal_core_chado_select('feature', $columns, $select, $options); 
+          $count = tripal_core_chado_select('feature', $columns, $select); 
           if (!$count or count($count) == 0 or $count[0]->num_landmarks == 0) {
             watchdog('T_gff3_loader', "The landmark '%landmark' cannot be found for this organism (%species) " .
                   "Please add the landmark and then retry the import of this GFF3 " .
@@ -730,7 +724,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
         $feature = tripal_feature_load_gff3_feature($feature_organism, $analysis_id, $cvterm,
           $attr_uniquename, $attr_name, $residues, $attr_is_analysis,
           $attr_is_obsolete, $add_only, $score);  
-     
+
         if ($feature) {
           
           // add a record for this feature to the tripal_gff_temp table for
@@ -742,12 +736,10 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
             'uniquename' => $feature->uniquename
           );
           // make sure this record doesn't already exist in oru temp table
-          $options = array('statement_name' => 'sel_tripalgfftemp_all');
-          $results = tripal_core_chado_select('tripal_gff_temp', array('*'), $values, $options);
+          $results = tripal_core_chado_select('tripal_gff_temp', array('*'), $values);
   
           if (count($results) == 0) {
-            $options = array('statement_name' => 'ins_tripalgfftemp');
-            $result = tripal_core_chado_insert('tripal_gff_temp', $values, $options);
+            $result = tripal_core_chado_insert('tripal_gff_temp', $values);
             if (!$result) {
               watchdog('T_gff3_loader', "Cound not save record in temporary table, Cannot continue.", array(), WATCHDOG_ERROR);
               exit;
@@ -760,11 +752,11 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
               $landmark, $fmin, $fmax, $strand, $phase, $attr_fmin_partial,
               $attr_fmax_partial, $attr_residue_info, $attr_locgroup);
           }
-
+          
           // add any aliases for this feature
           if (array_key_exists('Alias', $tags)) {
             tripal_feature_load_gff3_alias($feature, $tags['Alias']);
-          }      
+          }
           // add any dbxrefs for this feature
           if (array_key_exists('Dbxref', $tags)) {
             tripal_feature_load_gff3_dbxref($feature, $tags['Dbxref']);
@@ -772,11 +764,12 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
           // add any ontology terms for this feature
           if (array_key_exists('Ontology_term', $tags)) {
             tripal_feature_load_gff3_ontology($feature, $tags['Ontology_term']);
-          }       
+          }
           // add parent relationships
           if (array_key_exists('Parent', $tags)) {
             tripal_feature_load_gff3_parents($feature, $cvterm, $tags['Parent'], $feature_organism->organism_id, $fmin);
-          }               
+          }
+          
           // add target relationships
           if (array_key_exists('Target', $tags)) {
             tripal_feature_load_gff3_target($feature, $tags, $target_organism_id, $target_type, $create_target, $attr_locgroup);          
@@ -830,21 +823,12 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
       $parents = chado_query($sql);
       
       // build and prepare the SQL for selecting the children relationship
-      $sql = "";
-  
-      $sql = "
-        PREPARE sel_gffchildren (int) AS 
+      $sel_gffchildren_sql = "
         SELECT DISTINCT FR.feature_relationship_id, FL.fmin, FR.rank
         FROM {feature_relationship} FR
           INNER JOIN {featureloc} FL on FL.feature_id = FR.subject_id
-        WHERE FR.object_id = \$1 ORDER BY FL.fmin ASC
+        WHERE FR.object_id = :feature_id ORDER BY FL.fmin ASC
       ";            
-      $success = chado_query('sel_gffchildren', $sql);
-      if (!$success) {
-        watchdog("T_gff3_loader", "Cannot prepare statement 'sel_gffchildren' and cannot set children ranks.", 
-           array(), WATCHDOG_WARNING);
-        return 0;  
-      }
       
       // now set the rank of any parent/child relationships.  The order is based
       // on the fmin.  The start rank is 1.  This allows features with other
@@ -854,7 +838,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
         
         // get the children
         if ($connection) {      
-          $result = chado_query('EXECUTE sel_gffchildren (:feature_id)', array(':feature_id' => $parent->feature_id));
+          $result = chado_query($sel_gffchildren_sql, array(':feature_id' => $parent->feature_id));
         }
         else {
           $result = chado_query($sql, array(':feature_id' => $parent->feature_id));
@@ -878,19 +862,17 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
         $rank = -1;
         foreach ($children as $child) {
           $match = array('feature_relationship_id' => $child->feature_relationship_id);
-          $options = array('statement_name' => 'upd_featurerelationship_rank');      
           $values = array('rank' => $rank);      
-          tripal_core_chado_update('feature_relationship', $match, $values, $options);
+          tripal_core_chado_update('feature_relationship', $match, $values);
           $rank--;
         }
         // now set the rank correctly. The rank should start at 0.
         $rank = 0;
         foreach ($children as $child) {
           $match = array('feature_relationship_id' => $child->feature_relationship_id);
-          $options = array('statement_name' => 'upd_featurerelationship_rank');      
           $values = array('rank' => $rank); 
           //print "Was: " . $child->rank . " now $rank ($parent->strand)\n"     ;
-          tripal_core_chado_update('feature_relationship', $match, $values, $options);
+          tripal_core_chado_update('feature_relationship', $match, $values);
           $rank++;
         }
       }
@@ -924,8 +906,7 @@ function tripal_feature_load_gff3_derives_from($feature, $subject, $organism) {
     'organism_id' => $organism->organism_id,
     'uniquename' => $subject,
   );
-  $options = array('statement_name' => 'sel_tripalgfftemp_orun');
-  $result = tripal_core_chado_select('tripal_gff_temp', array('type_name'), $values, $options);   
+  $result = tripal_core_chado_select('tripal_gff_temp', array('type_name'), $values);   
   if (count($result) == 0) {
     watchdog("T_gff3_loader", "Cannot find subject type for feature in 'derives_from' relationship: %subject", array('%subject' => $subject), WATCHDOG_WARNING);
      return ''; 
@@ -943,8 +924,7 @@ function tripal_feature_load_gff3_derives_from($feature, $subject, $organism) {
       ),
     ),      
   );
-  $options = array('statement_name' => 'sel_feature_orunty');
-  $sfeature = tripal_core_chado_select('feature', array('feature_id'), $match, $options);
+  $sfeature = tripal_core_chado_select('feature', array('feature_id'), $match);
   if (count($sfeature)==0) {
     watchdog('T_gff3_loader', "Could not add 'Derives_from' relationship " .
       "for %uniquename and %subject.  Subject feature, '%subject', " .
@@ -964,15 +944,13 @@ function tripal_feature_load_gff3_derives_from($feature, $subject, $organism) {
     ),
     'rank' => 0
   );
-  $options = array('statement_name' => 'sel_featurerelationship_objectid_subjectid_typeid_rank');
-  $rel = tripal_core_chado_select('feature_relationship', array('*'), $values, $options);
+  $rel = tripal_core_chado_select('feature_relationship', array('*'), $values);
   if (count($rel) > 0) {
     return;
   }
 
   // finally insert the relationship if it doesn't exist
-  $options = array('statement_name' => 'ins_featurerelationship_objectid_subjectid_typeid_rank');
-  $ret = tripal_core_chado_insert('feature_relationship', $values, $options);
+  $ret = tripal_core_chado_insert('feature_relationship', $values);
   if (!$ret) {
     watchdog("T_gff3_loader", "Could not add 'Derives_from' relationship for $feature->uniquename and $subject", 
       array(), WATCHDOG_WARNING);
@@ -990,20 +968,13 @@ function tripal_feature_load_gff3_parents($feature, $cvterm, $parents, $organism
   $rel_type = 'part_of';
 
   // prepare these SQL statements that will be used repeatedly.
-  $psql = "
-    PREPARE sel_cvterm_cvname_cvtname_synonym (text, text, text) AS
+  $cvterm_sql = "
     SELECT CVT.cvterm_id
     FROM {cvterm} CVT
       INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id
       LEFT JOIN {cvtermsynonym} CVTS on CVTS.cvterm_id = CVT.cvterm_id
-    WHERE cv.name = $1 and (CVT.name = $2 or CVTS.synonym = $3)
+    WHERE cv.name = :cvname and (CVT.name = :name or CVTS.synonym = :synonym)
   ";
-  $status = chado_query($psql);
-  if (!$status) {
-     watchdog("T_gff3_loader", "Cannot prepare statement 'sel_cvterm_cvname_cvtname_synonym' for ontology term", 
-       array(), WATCHDOG_WARNING);
-     return '';
-  }
 
   // iterate through the parents in the list
   foreach ($parents as $parent) {
@@ -1012,8 +983,7 @@ function tripal_feature_load_gff3_parents($feature, $cvterm, $parents, $organism
       'organism_id' => $organism_id,
       'uniquename' => $parent,
     );
-    $options = array('statement_name' => 'sel_tripalgfftemp_orun');
-    $result = tripal_core_chado_select('tripal_gff_temp', array('type_name'), $values, $options);    
+    $result = tripal_core_chado_select('tripal_gff_temp', array('type_name'), $values);    
     if (count($result) == 0) {
       watchdog("T_gff3_loader", "Cannot find parent: %parent", array('%parent' => $parent), WATCHDOG_WARNING);
        return '';  
@@ -1021,17 +991,14 @@ function tripal_feature_load_gff3_parents($feature, $cvterm, $parents, $organism
     $parent_type = $result[0]->type_name;
 
     // try to find the parent
-    $parentcvterm = chado_query("EXECUTE sel_cvterm_cvname_cvtname_synonym (:cvname, :name, :synonym)", 
-      array(':cvname' => 'sequence', ':name' => $parent_type, ':synonym' => $parent_type))->fetchObject();
-    $relcvterm = chado_query("EXECUTE sel_cvterm_cvname_cvtname_synonym (:cvname, :name, :synonym)", 
-      array(':cvname' => 'relationship', ':name' => $rel_type, ':synonym' => $rel_type))->fetchObject();
+    $parentcvterm = chado_query($cvterm_sql, array(':cvname' => 'sequence', ':name' => $parent_type, ':synonym' => $parent_type))->fetchObject();
+    $relcvterm = chado_query($cvterm_sql, array(':cvname' => 'relationship', ':name' => $rel_type, ':synonym' => $rel_type))->fetchObject();
     $values = array(
         'organism_id' => $organism_id,
         'uniquename' => $parent,
         'type_id' => $parentcvterm->cvterm_id,
     );
-    $options = array('statement_name' => 'sel_feature_orunty');
-    $result = tripal_core_chado_select('feature', array('feature_id'), $values, $options);
+    $result = tripal_core_chado_select('feature', array('feature_id'), $values);
     $parent_feature = $result[0];
 
     // if the parent exists then add the relationship otherwise print error and skip
@@ -1043,20 +1010,18 @@ function tripal_feature_load_gff3_parents($feature, $cvterm, $parents, $organism
         'subject_id' => $feature->feature_id,
         'type_id' => $relcvterm->cvterm_id,
       );
-      $options = array('statement_name' => 'sel_featurerelationship_objectid_subjectid_typeid');
-      $rel = tripal_core_chado_select('feature_relationship', array('*'), $values, $options);
+      $rel = tripal_core_chado_select('feature_relationship', array('*'), $values);
 
       if (count($rel) > 0) {
       }
       else {
         // the relationship doesn't already exist, so add it.
         $values = array(
-           'subject_id' => $feature->feature_id,
-           'object_id'  => $parent_feature->feature_id,
-           'type_id' => $relcvterm->cvterm_id,
+          'subject_id' => $feature->feature_id,
+          'object_id'  => $parent_feature->feature_id,
+          'type_id' => $relcvterm->cvterm_id,
         );
-        $options = array('statement_name' => 'ins_featurerelationship_subjectid_objectid_typeid');
-        $result = tripal_core_chado_insert('feature_relationship', $values, $options);
+        $result = tripal_core_chado_insert('feature_relationship', $values);
         if (!$result) {
           watchdog("T_gff3_loader", "Failed to insert feature relationship '$uname' ($type) $rel_type '$parent' ($parent_type)", 
             array(), WATCHDOG_WARNING);
@@ -1091,23 +1056,20 @@ function tripal_feature_load_gff3_dbxref($feature, $dbxrefs) {
     // can't be found then look for the name as is.  If it still can't be found
     // the create the database
     $values = array('name' => "DB:$dbname");
-    $options = array('statement_name' => 'sel_db_name');
-    $db = tripal_core_chado_select('db', array('db_id'), $values, $options);
+    $db = tripal_core_chado_select('db', array('db_id'), $values);
     if (count($db) == 0) {
       $values = array('name' => "$dbname");
-      $db = tripal_core_chado_select('db', array('db_id'), $values, $options);
+      $db = tripal_core_chado_select('db', array('db_id'), $values);
     }
     if (count($db) == 0) {
       $values = array(
         'name' => $dbname,
         'description' => 'Added automatically by the GFF loader'
       );
-      $options = array('statement_name' => 'ins_db_name');
-      $success = tripal_core_chado_insert('db', $values, $options);
+      $success = tripal_core_chado_insert('db', $values);
       if ($success) {
         $values = array('name' => "$dbname");
-        $options = array('statement_name' => 'sel_db_name');        
-        $db = tripal_core_chado_select('db', array('db_id'), $values, $options);
+        $db = tripal_core_chado_select('db', array('db_id'), $values);
       }
       else {
         watchdog("T_gff3_loader", "Cannot find or add the database $dbname", array(), WATCHDOG_WARNING);
@@ -1121,8 +1083,7 @@ function tripal_feature_load_gff3_dbxref($feature, $dbxrefs) {
       'accession' => $accession, 
       'db_id' => $db->db_id
     );
-    $options = array('statement_name' => 'sel_dbxref_accession_dbid');
-    $dbxref = tripal_core_chado_select('dbxref', array('dbxref_id'), $values, $options);
+    $dbxref = tripal_core_chado_select('dbxref', array('dbxref_id'), $values);
 
     // if the accession doesn't exist then we want to add it
     if (sizeof($dbxref) == 0) {
@@ -1131,14 +1092,12 @@ function tripal_feature_load_gff3_dbxref($feature, $dbxrefs) {
         'accession' => $accession, 
         'version' => ''
       );
-      $options = array('statement_name' => 'ins_dbxref_dbid_accession_version');
-      $ret = tripal_core_chado_insert('dbxref', $values, $options);
+      $ret = tripal_core_chado_insert('dbxref', $values);
       $values = array(
         'accession' => $accession, 
         'db_id' => $db->db_id
       );
-      $options = array('statement_name' => 'sel_dbxref_accession_dbid');
-      $dbxref = tripal_core_chado_select('dbxref', array('dbxref_id'), $values, $options);
+      $dbxref = tripal_core_chado_select('dbxref', array('dbxref_id'), $values);
     }
     $dbxref = $dbxref[0];
 
@@ -1147,8 +1106,7 @@ function tripal_feature_load_gff3_dbxref($feature, $dbxrefs) {
       'dbxref_id' => $dbxref->dbxref_id, 
       'feature_id' => $feature->feature_id
     );
-    $options = array('statement_name' => 'sel_featuredbxref_dbxrefid_featureid');
-    $fdbx = tripal_core_chado_select('feature_dbxref', array('feature_dbxref_id'), $values, $options);
+    $fdbx = tripal_core_chado_select('feature_dbxref', array('feature_dbxref_id'), $values);
 
     // now associate this feature with the database reference if it doesn't
     // already exist
@@ -1157,8 +1115,7 @@ function tripal_feature_load_gff3_dbxref($feature, $dbxrefs) {
         'dbxref_id' => $dbxref->dbxref_id,
         'feature_id' => $feature->feature_id
       );
-      $options = array('statement_name' => 'ins_featuredbxref_dbxrefid_featureid');
-      $success = tripal_core_chado_insert('feature_dbxref', $values, $options);
+      $success = tripal_core_chado_insert('feature_dbxref', $values);
       if (!$success) {
         watchdog("T_gff3_loader", "Failed to insert Dbxref: $dbname:$accession", array(), WATCHDOG_WARNING);
         return 0;
@@ -1183,11 +1140,10 @@ function tripal_feature_load_gff3_ontology($feature, $dbxrefs) {
     $accession = $ref[1];
 
     // first look for the database name
-    $options = array('statement_name' => 'sel_db_name');
-    $db = tripal_core_chado_select('db', array('db_id'), array('name' => "DB:$dbname"), $options);
+    $db = tripal_core_chado_select('db', array('db_id'), array('name' => "DB:$dbname"));
     if (sizeof($db) == 0) {
       // now look for the name without the 'DB:' prefix.
-      $db = tripal_core_chado_select('db', array('db_id'), array('name' => "$dbname"), $options);
+      $db = tripal_core_chado_select('db', array('db_id'), array('name' => "$dbname"));
       if (sizeof($db) == 0) {
         watchdog("T_gff3_loader", "Database, $dbname, is not present. Cannot associate term: $dbname:$accession", array(), WATCHDOG_WARNING);
         return 0;
@@ -1196,9 +1152,8 @@ function tripal_feature_load_gff3_ontology($feature, $dbxrefs) {
     $db = $db[0];
 
     // now check to see if the accession exists
-    $options = array('statement_name' => 'sel_dbxref_accession_dbid');
     $dbxref = tripal_core_chado_select('dbxref', array('dbxref_id'), 
-      array('accession' => $accession, 'db_id' => $db->db_id), $options);
+      array('accession' => $accession, 'db_id' => $db->db_id));
     if (sizeof($dbxref) == 0) {
       watchdog("T_gff3_loader", "Accession, $accession is missing for reference: $dbname:$accession", array(), WATCHDOG_WARNING);
       return 0;
@@ -1206,14 +1161,12 @@ function tripal_feature_load_gff3_ontology($feature, $dbxrefs) {
     $dbxref = $dbxref[0];
 
     // now check to see if the cvterm exists
-    $options = array('statement_name' => 'sel_cvterm_dbxrefid');
     $cvterm = tripal_core_chado_select('cvterm', array('cvterm_id'), array(
-       'dbxref_id' => $dbxref->dbxref_id), $options);
+       'dbxref_id' => $dbxref->dbxref_id));
     // if it doesn't exist in the cvterm table, look for an alternate id
     if (sizeof($cvterm) == 0) {
-      $options = array('statement_name' => 'sel_cvtermdbxref_dbxrefid');
       $cvterm = tripal_core_chado_select('cvterm_dbxref', array('cvterm_id'), array(
-        'dbxref_id' => $dbxref->dbxref_id), $options);
+        'dbxref_id' => $dbxref->dbxref_id));
       if (sizeof($cvterm) == 0) {
         watchdog("T_gff3_loader", "CV Term is missing for reference: $dbname:$accession", array(), WATCHDOG_WARNING);
         return 0;
@@ -1223,10 +1176,8 @@ function tripal_feature_load_gff3_ontology($feature, $dbxrefs) {
 
 
     // check to see if this feature cvterm already exists
-    $options = array('statement_name' => 'sel_featurecvterm_cvtermid_featureid');
     $fcvt = tripal_core_chado_select('feature_cvterm', array('feature_cvterm_id'),
-      array('cvterm_id' => $cvterm->cvterm_id, 'feature_id' => $feature->feature_id),
-      $options);
+      array('cvterm_id' => $cvterm->cvterm_id, 'feature_id' => $feature->feature_id));
 
     // now associate this feature with the cvterm if it doesn't already exist
     if (sizeof($fcvt)==0) {
@@ -1237,8 +1188,7 @@ function tripal_feature_load_gff3_ontology($feature, $dbxrefs) {
           'uniquename' => 'null',
         ),
       );
-      $options = array('statement_name' => 'ins_featurecvterm_cvtermid_featureid_pubid');
-      $success = tripal_core_chado_insert('feature_cvterm', $values, $options);
+      $success = tripal_core_chado_insert('feature_cvterm', $values);
 
       if (!$success) {
         watchdog("T_gff3_loader", "Failed to insert ontology term: $dbname:$accession", array(), WATCHDOG_WARNING);
@@ -1257,8 +1207,7 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
 
   // make sure we have a 'synonym_type' vocabulary
   $select = array('name' => 'synonym_type');
-  $options = array('statement_name' => 'sel_cv_name');  
-  $results = tripal_core_chado_select('cv', array('*'), $select, $options);
+  $results = tripal_core_chado_select('cv', array('*'), $select);
   
   if (count($results) == 0) {
     // insert the 'synonym_type' vocabulary
@@ -1266,15 +1215,13 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
       'name' => 'synonym_type',
       'definition' => 'vocabulary for synonym types',
     );
-    $options = array('statement_name' => 'ins_cv_name_definition');
-    $success = tripal_core_chado_insert('cv', $values, $options);
+    $success = tripal_core_chado_insert('cv', $values);
     if (!$success) {
       watchdog("T_gff3_loader", "Failed to add the synonyms type vocabulary", array(), WATCHDOG_WARNING);
       return 0;
     }
     // now that we've added the cv we need to get the record
-    $options = array('statement_name' => 'sel_cv_name');
-    $results = tripal_core_chado_select('cv', array('*'), $select, $options);
+    $results = tripal_core_chado_select('cv', array('*'), $select);
     if (count($results) > 0) {
       $syncv = $results[0];
     }
@@ -1290,8 +1237,7 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
         'name' => 'synonym_type'
      ),
   );
-  $options = array('statement_name' => 'sel_cvterm_name_cvid');
-  $result = tripal_core_chado_select('cvterm', array('*'), $select, $options);  
+  $result = tripal_core_chado_select('cvterm', array('*'), $select);  
   if (count($result) == 0) {
     $term = array(
       'name' => 'exact',
@@ -1299,7 +1245,6 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
       'definition' => '',
       'is_obsolete' => 0,
     );
-    // TODO: fix the function so it uses prepared statements    
     $syntype = tripal_cv_add_cvterm($term, $syncv->name, 0, 1);
     if (!$syntype) {
       watchdog("T_gff3_loader", "Cannot add synonym type: internal:$type", array(), WATCHDOG_WARNING);
@@ -1319,22 +1264,19 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
        'name' => $alias,
        'type_id' => $syntype->cvterm_id,
     );
-    $options = array('statement_name' => 'sel_synonym_name_typeid');
-    $result = tripal_core_chado_select('synonym', array('*'), $select, $options);    
+    $result = tripal_core_chado_select('synonym', array('*'), $select);    
     if (count($result) == 0) {
       $values = array(
          'name' => $alias,
          'type_id' => $syntype->cvterm_id,
          'synonym_sgml' => '',
       );
-      $options = array('statement_name' => 'ins_synonym_name_typeid_synonymsgml');
-      $success = tripal_core_chado_insert('synonym', $values, $options);
+      $success = tripal_core_chado_insert('synonym', $values);
       if (!$success) {
         watchdog("T_gff3_loader", "Cannot add alias $alias to synonym table", array(), WATCHDOG_WARNING);
         return 0;
       }
-      $options = array('statement_name' => 'sel_synonym_name_typeid');
-      $result = tripal_core_chado_select('synonym', array('*'), $select, $options);
+      $result = tripal_core_chado_select('synonym', array('*'), $select);
       $synonym = $result[0];
     }
     else {
@@ -1343,20 +1285,18 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
 
     // check to see if we have a NULL publication in the pub table.  If not,
     // then add one.
-    // @coder-ignore: non-drupal schema thus table prefixing does not apply
     $select = array('uniquename' => 'null');
-    $options = array('statement_name' => 'sel_pub_uniquename');
-    $result = tripal_core_chado_select('pub', array('*'), $select, $options);    
+    $result = tripal_core_chado_select('pub', array('*'), $select);    
     if (count($result) == 0) {
       // prepare the statement
-      $psql = "
-        PREPARE ins_pub_uniquename_typeid (text, text) AS
-        INSERT INTO {pub} (uniquename,type_id) VALUES ('%s',
-        (SELECT cvterm_id
-        FROM {cvterm} CVT
-          INNER JOIN {dbxref} DBX on DBX.dbxref_id = CVT.dbxref_id
-          INNER JOIN {db} DB on DB.db_id = DBX.db_id
-        WHERE CVT.name = $1 and DB.name = $2)
+      $pub_sql = "
+        INSERT INTO {pub} (uniquename,type_id) 
+        VALUES (:uname,
+          (SELECT cvterm_id
+           FROM {cvterm} CVT
+             INNER JOIN {dbxref} DBX ON DBX.dbxref_id = CVT.dbxref_id
+             INNER JOIN {db} DB      ON DB.db_id      = DBX.db_id
+           WHERE CVT.name = :type_id))
       ";
       $status = chado_query($psql);
       if (!$status) {
@@ -1365,14 +1305,12 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
       } 
 
       // insert the null pub 
-      $result = chado_query("EXECUTE ins_pub_uniquename_typeid (:uname, :type_id)", 
-        array(':uname' => 'null', ':type_id' => 'null'))->fetchObject();
+      $result = chado_query($pub_sql, array(':uname' => 'null', ':type_id' => 'null'))->fetchObject();
       if (!$result) {
         watchdog("T_gff3_loader", "Cannot add null publication needed for setup of alias", array(), WATCHDOG_WARNING);
         return 0;
       }
-      $options = array('statement_name' => 'sel_pub_uniquename');
-      $result = tripal_core_chado_select('pub', array('*'), $select, $options);
+      $result = tripal_core_chado_select('pub', array('*'), $select);
       $pub = $result[0];
     }
     else {
@@ -1387,16 +1325,14 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
        'pub_id' => $pub->pub_id,
     );
     $columns = array('feature_synonym_id');
-    $options = array('statement_name' => 'sel_featuresynonym_syfepu');
-    $result = tripal_core_chado_select('feature_synonym', $columns, $values, $options);
+    $result = tripal_core_chado_select('feature_synonym', $columns, $values);
     if (count($result) == 0) {      
       $values = array(
          'synonym_id' => $synonym->synonym_id,
          'feature_id' => $feature->feature_id,
          'pub_id' => $pub->pub_id,
       );  
-      $ins_options = array('statement_name' => 'ins_featuresynonym_syfepu');
-      $success = tripal_core_chado_insert('feature_synonym', $values, $ins_options);   
+      $success = tripal_core_chado_insert('feature_synonym', $values);   
      
       if (!$success) {
         watchdog("T_gff3_loader", "Cannot add alias $alias to feature synonym table", array(), WATCHDOG_WARNING);
@@ -1422,9 +1358,8 @@ function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uni
      'uniquename' => $uniquename,
      'type_id' => $cvterm->cvterm_id
   );
-  $options = array('statement_name' => 'sel_feature_orunty');
   $columns = array('feature_id', 'name', 'uniquename', 'seqlen', 'organism_id', 'type_id');
-  $result = tripal_core_chado_select('feature', $columns, $fselect, $options);
+  $result = tripal_core_chado_select('feature', $columns, $fselect);
   if (count($result) > 0) {
     $feature = $result[0];
   }
@@ -1455,8 +1390,7 @@ function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uni
        'is_analysis' => $is_analysis,
        'is_obsolete' => $is_obsolete,
     );
-    $options = array('statement_name' => 'ins_feature_all');
-    $result = tripal_core_chado_insert('feature', $values, $options);
+    $result = tripal_core_chado_insert('feature', $values);
     if (!$result) {
       watchdog("T_gff3_loader", "Failed to insert feature '$uniquename' ($cvterm->name)", array(), WATCHDOG_WARNING);
       return 0;
@@ -1476,8 +1410,7 @@ function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uni
       'uniquename' => $uniquename,
       'type_id' => $cvterm->cvterm_id,
     );
-    $options = array('statement_name' => 'upd_feature');
-    $result = tripal_core_chado_update('feature', $match, $values, $options);
+    $result = tripal_core_chado_update('feature', $match, $values);
     if (!$result) {
       watchdog("T_gff3_loader", "Failed to update feature '$uniquename' ($cvterm->name)", array(), WATCHDOG_WARNING);
       return 0;
@@ -1490,9 +1423,8 @@ function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uni
   }
 
   // get the newly added feature
-  $options = array('statement_name' => 'sel_feature_orunty');
   $columns = array('feature_id', 'name', 'uniquename', 'seqlen', 'organism_id', 'type_id');
-  $result = tripal_core_chado_select('feature', $columns, $fselect, $options);  
+  $result = tripal_core_chado_select('feature', $columns, $fselect);  
   $feature = $result[0];
 
   // add the analysisfeature entry to the analysisfeature table if it doesn't already exist
@@ -1500,18 +1432,13 @@ function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uni
     'analysis_id' => $analysis_id,
     'feature_id' => $feature->feature_id
   );
-  $options = array('statement_name' => 'sel_analysisfeature_analysisid_featureid');
-  $afeature = tripal_core_chado_select('analysisfeature', array('analysisfeature_id'), $af_values, $options);
+  $afeature = tripal_core_chado_select('analysisfeature', array('analysisfeature_id'), $af_values);
   if (count($afeature)==0) {
     // if a score is available then set that to be the significance field
     if (strcmp($score, '.') != 0) {
       $af_values['significance'] = $score;
-      $options = array('statement_name' => 'ins_analysisfeature_analysisid_featureid_significance');
     } 
-    else {
-      $options = array('statement_name' => 'ins_analysisfeature_analysisid_featureid');
-    }
-    if (!tripal_core_chado_insert('analysisfeature', $af_values, $options)) {
+    if (!tripal_core_chado_insert('analysisfeature', $af_values)) {
       watchdog("T_gff3_loader", "Could not add analysisfeature record: $analysis_id, $feature->feature_id", array(), WATCHDOG_WARNING);
     }    
   }
@@ -1525,8 +1452,7 @@ function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uni
       $new_vals['significance'] = '__NULL__';
     }
     if (!$add_only) {
-      $options = array('statement_name' => 'upd_analysisfeature');
-      $ret = tripal_core_chado_update('analysisfeature', $af_values, $new_vals, $options);
+      $ret = tripal_core_chado_update('analysisfeature', $af_values, $new_vals);
       if (!$ret) {
         watchdog("T_gff3_loader", "Could not update analysisfeature record: $analysis_id, $feature->feature_id", array(), WATCHDOG_WARNING);
       }
@@ -1549,12 +1475,10 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
     'organism_id' => $landmark_organism_id ? $landmark_organism_id : $organism->organism_id,
     'uniquename' => $landmark,
   );
-  $options = array('statement_name' => 'sel_feature_orun');
   if ($landmark_type_id) {
     $select['type_id'] = $landmark_type_id;
-    $options = array('statement_name' => 'sel_feature_orunty');
   }  
-  $results = tripal_core_chado_select('feature', array('feature_id'), $select, $options);
+  $results = tripal_core_chado_select('feature', array('feature_id'), $select);
 
   $srcfeature = '';
   if (count($results)==0) {
@@ -1564,19 +1488,16 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
       'organism_id' => $landmark_organism_id ? $landmark_organism_id : $organism->organism_id,
       'name' => $landmark,
     );
-    $options = array('statement_name' => 'sel_feature_orna');    
     if ($landmark_type_id) {
       $select['type_id'] = $landmark_type_id;
-      $options = array('statement_name' => 'sel_feature_ornaty');
     } 
-    $results = tripal_core_chado_select('feature', array('feature_id'), $select, $options);
+    $results = tripal_core_chado_select('feature', array('feature_id'), $select);
     if (count($results) == 0) {
        // if the landmark is the target feature in a matched alignment then try one more time to
        // find it by querying any feature with the same uniquename. If we find one then use it.
        if ($landmark_is_target) {
          $select = array('uniquename' => $landmark);
-         $options = array('statement_name' => 'sel_feature_un');
-         $results = tripal_core_chado_select('feature', array('feature_id'), $select, $options);
+         $results = tripal_core_chado_select('feature', array('feature_id'), $select);
          if (count($results) == 1) {
            $srcfeature = $results[0]; 
          }
@@ -1592,8 +1513,7 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
               'uniquename' => $landmark,
               'type_id' => $landmark_type_id
             );
-            $options = array('statement_name' => 'ins_feature_ornaunty');
-            $results = tripal_core_chado_insert('feature', $values, $options);
+            $results = tripal_core_chado_insert('feature', $values);
             if (!$results) {
               watchdog("T_gff3_loader", "Cannot find landmark feature: '%landmark', nor could it be inserted", 
                 array('%landmark' => $landmark), WATCHDOG_WARNING);
@@ -1639,7 +1559,6 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
   $exists = 0;
   $select = array('feature_id' => $feature->feature_id);
   $options = array(
-    'statement_name' => 'sel_featureloc_fe',
     'order_by' => array(
        'rank' => 'ASC'
     ),
@@ -1654,9 +1573,8 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
       continue;
     }    
     $select = array('feature_id' => $featureloc->srcfeature_id);
-    $options = array('statement_name' => 'sel_feature_fe');
     $columns = array('feature_id', 'name');
-    $locsfeature = tripal_core_chado_select('feature', $columns, $select, $options);   
+    $locsfeature = tripal_core_chado_select('feature', $columns, $select);   
     
     // the source feature name and at least the fmin and fmax must be the same
     // for an update of the featureloc, otherwise we'll insert a new record.
@@ -1675,8 +1593,7 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
          $values['strand'] = $strand;
       }
       if (count($values) > 0) {
-        $options = array('statement_name' => 'upd_featureloc_all');
-        tripal_core_chado_update('featureloc', $match, $values, $options);
+        tripal_core_chado_update('featureloc', $match, $values);
       }
     }
     $rank = $featureloc->rank + 1;
@@ -1708,12 +1625,10 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
        'locgroup'        => $locgroup,
        'rank'            => $rank 
     );
-    $options = array('statement_name' => 'ins_featureloc_all');
     if ($phase) {
       $values['phase'] = $phase;
-      $options = array('statement_name' => 'ins_featureloc_allphase');
     }    
-    $success = tripal_core_chado_insert('featureloc', $values, $options);
+    $success = tripal_core_chado_insert('featureloc', $values);
     if (!$success) {
       watchdog("T_gff3_loader", "Failed to insert featureloc", array(), WATCHDOG_WARNING);
       exit;
@@ -1736,8 +1651,7 @@ function tripal_feature_load_gff3_property($feature, $property, $value) {
         'name' => 'feature_property',
      ),
   );
-  $options = array('statement_name' => 'sel_cvterm_name_cvid');
-  $result = tripal_core_chado_select('cvterm', array('*'), $select, $options);
+  $result = tripal_core_chado_select('cvterm', array('*'), $select);
 
   // if we don't have a property like this already, then add it otherwise, just return
   if (count($result) == 0) {
@@ -1768,7 +1682,6 @@ function tripal_feature_load_gff3_property($feature, $property, $value) {
      'type_id' => $cvterm->cvterm_id,
   );
   $options = array(
-    'statement_name' => 'sel_featureprop_featureid_typeid',
     'order_by' => array(
       'rank' => 'ASC',
     ),
@@ -1789,8 +1702,7 @@ function tripal_feature_load_gff3_property($feature, $property, $value) {
        'value' => $value,
        'rank' => $rank,
     );
-    $options = array('statement_name' => 'ins_featureprop_all');
-    $result = tripal_core_chado_insert('featureprop', $values, $options);
+    $result = tripal_core_chado_insert('featureprop', $values);
     if (!$result) {
       watchdog("T_gff3_loader", "cannot add featureprop, $property", array(), WATCHDOG_WARNING);
     }
@@ -1803,17 +1715,10 @@ function tripal_feature_load_gff3_property($feature, $property, $value) {
 function tripal_feature_load_gff3_fasta($fh, $interval, &$num_read, &$intv_read, &$line_num) {
   print "Loading FASTA sequences\n";
   $residues = '';
-  $sql = " 
-    PREPARE sel_gfftemp_un (text) AS
+  $sel_gfftemp_un_sql = " 
     SELECT feature_id FROM tripal_gff_temp
-    WHERE uniquename = $1
+    WHERE uniquename = :uname
   ";
-  $status = tripal_core_chado_prepare('sel_gfftemp_un', $sql, array('text'));
-  if (!$status) {
-   watchdog('T_gff3_loader', 'Cannot prepare statement \'sel_gfftemp_un\'.', 
-     array(), WATCHDOG_ERROR);
-   return '';  
-  }
   $id = NULL;
   
   // iterate through the remaining lines of the file
@@ -1841,8 +1746,7 @@ function tripal_feature_load_gff3_fasta($fh, $interval, &$num_read, &$intv_read,
       // just finished.     
              
       if ($id) {
-        $sql = "EXECUTE sel_gfftemp_un('%s')";
-        $result = tripal_core_chado_execute_prepared('sel_gfftemp_un', $sql, array($id));
+        $result = chado_query($sel_gfftemp_un_sql, array(':uname' => $id));
         if (!$result) {
           watchdog('T_gff3_loader', 'Cannot find feature to assign FASTA sequence: %uname', 
              array('%uname' => $id), WATCHDOG_WARNING); 
@@ -1852,8 +1756,7 @@ function tripal_feature_load_gff3_fasta($fh, $interval, &$num_read, &$intv_read,
           $feature = $result->fetchObject();    
           $values = array('residues' => $residues);
           $match = array('feature_id' => $feature->feature_id);
-          $options = array('statement_name' => 'upd_feature_re');
-          tripal_core_chado_update('feature', $match, $values, $options);
+          tripal_core_chado_update('feature', $match, $values);
         }
       }
       // get the feature ID for this ID from the tripal_gff_temp table
@@ -1865,8 +1768,7 @@ function tripal_feature_load_gff3_fasta($fh, $interval, &$num_read, &$intv_read,
     }
   } 
   // add in the last sequence
-  $sql = "EXECUTE sel_gfftemp_un('%s')";
-  $result = tripal_core_chado_execute_prepared('sel_gfftemp_un', $sql, array($id));
+  $result = chado_query($sel_gfftemp_un_sql, array(':uname' => $id));
   if (!$result) {
     watchdog('T_gff3_loader', 'Cannot find feature to assign FASTA sequence: %uname', 
        array('%uname' => $id), WATCHDOG_WARNING); 
@@ -1876,8 +1778,7 @@ function tripal_feature_load_gff3_fasta($fh, $interval, &$num_read, &$intv_read,
     $feature = $result->fetchObject();    
     $values = array('residues' => $residues);
     $match = array('feature_id' => $feature->feature_id);
-    $options = array('statement_name' => 'upd_feature_re');
-    tripal_core_chado_update('feature', $match, $values, $options);
+    tripal_core_chado_update('feature', $match, $values);
   } 
 }
 
@@ -1932,8 +1833,7 @@ function tripal_feature_load_gff3_target($feature, $tags, $target_organism_id, $
           'genus' => $matches[1],
           'species' => $matches[2],
         );
-        $options = array('statement_name' => 'sel_organism_gesp');
-        $torganism = tripal_core_chado_select('organism', array('organism_id'), $values, $options);
+        $torganism = tripal_core_chado_select('organism', array('organism_id'), $values);
         if (count($torganism) == 1) {
           $t_organism_id = $torganism[0]->organism_id;
         }
@@ -1961,8 +1861,7 @@ function tripal_feature_load_gff3_target($feature, $tags, $target_organism_id, $
            'name' => 'sequence',
         )
       );
-      $options = array('statement_name' => 'sel_cvterm_nacv');
-      $type = tripal_core_chado_select('cvterm', array('cvterm_id'), $values, $options);
+      $type = tripal_core_chado_select('cvterm', array('cvterm_id'), $values);
       if (count($type) == 1) {
         $t_type_id = $type[0]->cvterm_id;
       }
@@ -1979,8 +1878,7 @@ function tripal_feature_load_gff3_target($feature, $tags, $target_organism_id, $
            'name' => 'sequence',
         )
       );
-      $options = array('statement_name' => 'sel_cvterm_nacv');
-      $type = tripal_core_chado_select('cvterm', array('cvterm_id'), $values, $options);
+      $type = tripal_core_chado_select('cvterm', array('cvterm_id'), $values);
       if (count($type) == 1) {
         $t_type_id = $type[0]->cvterm_id;
       }

+ 0 - 0
tripal_feature/includes/seq_extract.inc → tripal_feature/includes/tripal_feature.seq_extract.inc


+ 1 - 1
tripal_feature/tripal_feature.install

@@ -25,7 +25,7 @@ function tripal_feature_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_feature'] = array(
           'title' => "t ripal_feature",
           'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 7 - 5
tripal_feature/tripal_feature.module

@@ -14,14 +14,16 @@
  */
 
 require_once "api/tripal_feature.api.inc";
+require_once "api/tripal_feature.schema.api.inc";
+
 require_once "includes/tripal_feature.admin.inc";
 require_once "includes/tripal_feature.sync_features.inc";
-require_once "includes/fasta_loader.inc";
-require_once "includes/gff_loader.inc";
-require_once "includes/seq_extract.inc";
-require_once "includes/tripal_feature-delete.inc";
+require_once "includes/tripal_feature.fasta_loader.inc";
+require_once "includes/tripal_feature.gff_loader.inc";
+require_once "includes/tripal_feature.seq_extract.inc";
+require_once "includes/tripal_feature.delete.inc";
 require_once "includes/tripal_feature.form.inc";
-require_once "api/tripal_feature.schema.api.inc";
+
 
 /**
  *

+ 1 - 1
tripal_featuremap/tripal_featuremap.install

@@ -25,7 +25,7 @@ function tripal_featuremap_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_featuremap'] = array(
         'title' => "tripal_featuremap",
         'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 1
tripal_library/tripal_library.install

@@ -25,7 +25,7 @@ function tripal_library_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_library'] = array(
         'title' => "tripal_library",
         'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 1
tripal_natural_diversity/tripal_natural_diversity.install

@@ -25,7 +25,7 @@ function tripal_natural_diversity_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_natural_diversity'] = array(
         'title' => "tripal_natural_diversity",
         'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 1
tripal_organism/tripal_organism.install

@@ -98,7 +98,7 @@ function tripal_organism_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_organism'] = array(
             'title' => "tripal_organism",
             'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 1
tripal_project/tripal_project.install

@@ -32,7 +32,7 @@ function tripal_project_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_project'] = array(
         'title' => "tripal_project",
         'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 1
tripal_pub/tripal_pub.install

@@ -31,7 +31,7 @@ function tripal_pub_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_pub'] = array(
         'title' => "tripal_pub",
         'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 1
tripal_stock/tripal_stock.install

@@ -28,7 +28,7 @@ function tripal_stock_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    if (!tripal_core_is_chado_installed()) {
+    if (!$GLOBALS["chado_is_installed"]) {
       $requirements ['tripal_stock'] = array(
         'title' => "tripal_stock",
         'value' => "ERROR: Chado most be installed before this module can be enabled",

+ 1 - 1
tripal_views/tripal_views.install

@@ -380,7 +380,7 @@ function tripal_views_requirements($phase) {
   $requirements = array();
   if ($phase == 'install') {
     // make sure chado is installed
-    $version = tripal_core_set_chado_version();
+    $version = tripal_get_set_chado_version(TRUE);
     if ($version == 'not installed') {
       $requirements ['tripal_views'] = array(
             'title' => "tripal_views",