function tripal_organism_taxonify_features

1.x tripal_organism.admin.inc tripal_organism_taxonify_features($organism_id = NULL, $job_id = NULL)

Related topics

1 string reference to 'tripal_organism_taxonify_features'

File

tripal_organism/includes/tripal_organism.admin.inc, line 402

Code

function tripal_organism_taxonify_features($organism_id = NULL, $job_id = NULL) {
  $i = 0;

  if (!$organism_id) {
    return;
  }

  $sql = "SELECT * " .
    "FROM {feature} " .
    "WHERE organism_id = $organism_id " .
    "ORDER BY 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++;
  }

  // make sure our vocabularies are set before proceeding
  tripal_feature_set_vocabulary();

  // use this SQL for getting the nodes
  $nsql = "SELECT * FROM {chado_feature} CF " .
    "  INNER JOIN {node} N ON N.nid = CF.nid " .
    "WHERE feature_id = %d";

  // iterate through the features and set the taxonomy
  $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));
    }
    $node = db_fetch_object(db_query($nsql, $feature_id));
    tripal_feature_set_taxonomy($node, $feature_id);
    $i++;
  }
}