function tripal_library_reindex_features

1.x tripal_library.admin.inc tripal_library_reindex_features($library_id = NULL, $job_id = NULL)

Related topics

1 string reference to 'tripal_library_reindex_features'

File

tripal_library/includes/tripal_library.admin.inc, line 473

Code

function tripal_library_reindex_features($library_id = NULL, $job_id = NULL) {
  $i = 0;

  // if the caller provided a library_id then get all of the features
  // associated with the library. Otherwise get all sequences assoicated
  // with all libraries.
  if ($library_id) {
    $sql = "SELECT LF.feature_id, L.library_id, L.name as libname " .
      " FROM {library_feature} LF " .
      "  INNER JOIN Library L ON LF.library_id = L.library_id " .
      "WHERE L.library_id = $library_id " .
      "ORDER BY LF.feature_id";
    $results = chado_query($sql);
  }
  else {
    $sql = "SELECT LF.feature_id, L.library_id, L.name as libname " .
      " FROM {library_feature} LF " .
      "  INNER JOIN Library L ON LF.library_id = L.library_id " .
      "ORDER BY LF.feature_id";
    $results = chado_query($sql);
  }

  // load into ids array
  $count = 0;
  $ids = array();
  while ($id = db_fetch_object($results)) {
    $ids[$count] = $id->feature_id;
    $count++;
  }

  $interval = intval($count * 0.01);
  foreach ($ids as $feature_id) {
    // update the job status every 1% features
    if ($job_id and $i % interval == 0) {
      tripal_job_set_progress($job_id, intval(($i / $count) * 100));
    }
    $i++;
  }
}