|
@@ -1,10 +1,10 @@
|
|
|
<?php
|
|
|
/**
|
|
|
- * @file
|
|
|
- * Tripal Ontology Loader
|
|
|
- *
|
|
|
* @defgroup tripal_obo_loader Ontology Loader
|
|
|
* @ingroup tripal_cv
|
|
|
+ * @{
|
|
|
+ * Functions to aid in loading ontologies into the chado cv module
|
|
|
+ * @}
|
|
|
*/
|
|
|
|
|
|
/**
|
|
@@ -99,7 +99,7 @@ function tripal_cv_obo_form_submit($form, &$form_state) {
|
|
|
$obo_name = $form_state['values']['obo_name'];
|
|
|
$obo_url = $form_state['values']['obo_url'];
|
|
|
$obo_file = $form_state['values']['obo_file'];
|
|
|
-
|
|
|
+
|
|
|
tripal_cv_submit_obo_job($obo_id, $obo_name, $obo_url, $obo_file);
|
|
|
}
|
|
|
|
|
@@ -143,9 +143,9 @@ function tripal_cv_load_obo_v1_2_id($obo_id, $jobid = NULL) {
|
|
|
*/
|
|
|
function tripal_cv_load_obo_v1_2_file($obo_name, $file, $jobid = NULL, $is_new = TRUE) {
|
|
|
$newcvs = array();
|
|
|
-
|
|
|
+
|
|
|
// TODO: need better error detection
|
|
|
-
|
|
|
+
|
|
|
tripal_cv_load_obo_v1_2($file, $jobid, $newcvs);
|
|
|
if ($is_new) {
|
|
|
tripal_cv_add_obo_ref($obo_name, $file);
|
|
@@ -154,7 +154,7 @@ function tripal_cv_load_obo_v1_2_file($obo_name, $file, $jobid = NULL, $is_new =
|
|
|
|
|
|
// update the cvtermpath table
|
|
|
tripal_cv_load_update_cvtermpath($newcvs, $jobid);
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -218,23 +218,23 @@ function tripal_cv_load_update_cvtermpath($newcvs, $jobid) {
|
|
|
* @ingroup tripal_obo_loader
|
|
|
*/
|
|
|
function tripal_cv_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
|
|
|
-
|
|
|
+
|
|
|
$transaction = db_transaction();
|
|
|
print "\nNOTE: Loading of this OBO file is performed using a database transaction. \n" .
|
|
|
"If the load fails or is terminated prematurely then the entire set of \n" .
|
|
|
"insertions/updates is rolled back and will not be found in the database\n\n";
|
|
|
try {
|
|
|
$header = array();
|
|
|
-
|
|
|
+
|
|
|
// make sure our temporary table exists
|
|
|
- $ret = array();
|
|
|
-
|
|
|
+ $ret = array();
|
|
|
+
|
|
|
// empty the temp table
|
|
|
$sql = "DELETE FROM {tripal_obo_temp}";
|
|
|
chado_query($sql);
|
|
|
-
|
|
|
- print "Step 1: Preloading File $file\n";
|
|
|
-
|
|
|
+
|
|
|
+ print "Step 1: Preloading File $file\n";
|
|
|
+
|
|
|
// make sure we have an 'internal' and a '_global' database
|
|
|
if (!tripal_db_add_db('internal')) {
|
|
|
tripal_cv_obo_quiterror("Cannot add 'internal' database");
|
|
@@ -242,23 +242,23 @@ function tripal_cv_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
|
|
|
if (!tripal_db_add_db('_global')) {
|
|
|
tripal_cv_obo_quiterror("Cannot add '_global' database");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// parse the obo file
|
|
|
$default_db = tripal_cv_obo_parse($file, $header, $jobid);
|
|
|
-
|
|
|
+
|
|
|
// add the CV for this ontology to the database
|
|
|
$defaultcv = tripal_cv_add_cv($header['default-namespace'][0], '');
|
|
|
if (!$defaultcv) {
|
|
|
tripal_cv_obo_quiterror('Cannot add namespace ' . $header['default-namespace'][0]);
|
|
|
}
|
|
|
$newcvs[$header['default-namespace'][0]] = $defaultcv->cv_id;
|
|
|
-
|
|
|
+
|
|
|
// add any typedefs to the vocabulary first
|
|
|
- print "\nStep 2: Loading type defs...\n";
|
|
|
+ print "\nStep 2: Loading type defs...\n";
|
|
|
tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid);
|
|
|
-
|
|
|
+
|
|
|
// next add terms to the vocabulary
|
|
|
- print "\nStep 3: Loading terms...\n";
|
|
|
+ print "\nStep 3: Loading terms...\n";
|
|
|
if (!tripal_cv_obo_process_terms($defaultcv, $jobid, $newcvs, $default_db)) {
|
|
|
tripal_cv_obo_quiterror('Cannot add terms from this ontology');
|
|
|
}
|
|
@@ -286,20 +286,20 @@ function tripal_cv_obo_quiterror($message) {
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- *
|
|
|
+ *
|
|
|
*/
|
|
|
function tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
|
|
|
$sql = "SELECT * FROM {tripal_obo_temp} WHERE type = 'Typedef' ";
|
|
|
$typedefs = chado_query($sql);
|
|
|
-
|
|
|
+
|
|
|
$sql = "
|
|
|
SELECT count(*) as num_terms
|
|
|
FROM {tripal_obo_temp}
|
|
|
- WHERE type = 'Typedef'
|
|
|
- ";
|
|
|
+ WHERE type = 'Typedef'
|
|
|
+ ";
|
|
|
$result = chado_query($sql)->fetchObject();
|
|
|
$count = $result->num_terms;
|
|
|
-
|
|
|
+
|
|
|
// calculate the interval for updates
|
|
|
$interval = intval($count * 0.0001);
|
|
|
if ($interval < 1) {
|
|
@@ -308,16 +308,16 @@ function tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
|
|
|
$i = 0;
|
|
|
foreach ($typedefs as $typedef) {
|
|
|
$term = unserialize(base64_decode($typedef->stanza));
|
|
|
-
|
|
|
+
|
|
|
// update the job status every interval
|
|
|
if ($jobid and $i % $interval == 0) {
|
|
|
$complete = ($i / $count) * 33.33333333;
|
|
|
- tripal_job_set_progress($jobid, intval($complete + 33.33333333));
|
|
|
- printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
|
|
|
- }
|
|
|
-
|
|
|
+ tripal_job_set_progress($jobid, intval($complete + 33.33333333));
|
|
|
+ printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
|
|
|
+ }
|
|
|
+
|
|
|
tripal_cv_obo_process_term($term, $defaultcv->name, 1, $newcvs, $default_db);
|
|
|
-
|
|
|
+
|
|
|
$i++;
|
|
|
}
|
|
|
// set the final status
|
|
@@ -328,9 +328,9 @@ function tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
|
|
|
else {
|
|
|
$complete = 33.33333333;
|
|
|
}
|
|
|
- tripal_job_set_progress($jobid, intval($complete + 33.33333333));
|
|
|
+ tripal_job_set_progress($jobid, intval($complete + 33.33333333));
|
|
|
printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
|
|
|
- }
|
|
|
+ }
|
|
|
return 1;
|
|
|
}
|
|
|
/**
|
|
@@ -348,15 +348,15 @@ function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $defau
|
|
|
ORDER BY id
|
|
|
";
|
|
|
$terms = chado_query($sql);
|
|
|
-
|
|
|
+
|
|
|
$sql = "
|
|
|
SELECT count(*) as num_terms
|
|
|
FROM {tripal_obo_temp}
|
|
|
- WHERE type = 'Term'
|
|
|
- ";
|
|
|
+ WHERE type = 'Term'
|
|
|
+ ";
|
|
|
$result = chado_query($sql)->fetchObject();
|
|
|
$count = $result->num_terms;
|
|
|
-
|
|
|
+
|
|
|
// calculate the interval for updates
|
|
|
$interval = intval($count * 0.0001);
|
|
|
if ($interval < 1) {
|
|
@@ -364,14 +364,14 @@ function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $defau
|
|
|
}
|
|
|
foreach ($terms as $t) {
|
|
|
$term = unserialize(base64_decode($t->stanza));
|
|
|
-
|
|
|
+
|
|
|
// update the job status every interval
|
|
|
if ($jobid and $i % $interval == 0) {
|
|
|
$complete = ($i / $count) * 33.33333333;
|
|
|
- tripal_job_set_progress($jobid, intval($complete + 66.666666));
|
|
|
- printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
|
|
|
- }
|
|
|
-
|
|
|
+ tripal_job_set_progress($jobid, intval($complete + 66.666666));
|
|
|
+ printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
|
|
|
+ }
|
|
|
+
|
|
|
// add/update this term
|
|
|
if (!tripal_cv_obo_process_term($term, $defaultcv->name, 0, $newcvs, $default_db)) {
|
|
|
tripal_cv_obo_quiterror("Failed to process terms from the ontology");
|
|
@@ -379,7 +379,7 @@ function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $defau
|
|
|
|
|
|
$i++;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// set the final status
|
|
|
if ($jobid) {
|
|
|
if ($count > 0) {
|
|
@@ -388,10 +388,10 @@ function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $defau
|
|
|
else {
|
|
|
$complete = 33.33333333;
|
|
|
}
|
|
|
- tripal_job_set_progress($jobid, intval($complete + 66.666666));
|
|
|
+ tripal_job_set_progress($jobid, intval($complete + 66.666666));
|
|
|
printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -400,35 +400,35 @@ function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $defau
|
|
|
* @ingroup tripal_obo_loader
|
|
|
*/
|
|
|
function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$newcvs, $default_db) {
|
|
|
-
|
|
|
+
|
|
|
// construct the term array for sending to the tripal_cv_add_cvterm function
|
|
|
// for adding a new cvterm
|
|
|
- $t = array();
|
|
|
+ $t = array();
|
|
|
$t['id'] = $term['id'][0];
|
|
|
$t['name'] = $term['name'][0];
|
|
|
if (array_key_exists('def', $term)) {
|
|
|
$t['def'] = $term['def'][0];
|
|
|
}
|
|
|
if (array_key_exists('subset', $term)) {
|
|
|
- $t['subset'] = $term['subset'][0];
|
|
|
- }
|
|
|
+ $t['subset'] = $term['subset'][0];
|
|
|
+ }
|
|
|
if (array_key_exists('namespace', $term)) {
|
|
|
$t['namespace'] = $term['namespace'][0];
|
|
|
}
|
|
|
if (array_key_exists('is_obsolete', $term)) {
|
|
|
$t['is_obsolete'] = $term['is_obsolete'][0];
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
// add the cvterm
|
|
|
- $cvterm = tripal_cv_add_cvterm($t, $defaultcv, $is_relationship, 1, $default_db);
|
|
|
+ $cvterm = tripal_cv_add_cvterm($t, $defaultcv, $is_relationship, 1, $default_db);
|
|
|
if (!$cvterm) {
|
|
|
tripal_cv_obo_quiterror("Cannot add the term " . $term['id'][0]);
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
if (array_key_exists('namespace', $term)) {
|
|
|
$newcvs[$term['namespace'][0]] = $cvterm->cv_id;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// now handle other properites
|
|
|
if (array_key_exists('is_anonymous', $term)) {
|
|
|
//print "WARNING: unhandled tag: is_anonymous\n";
|
|
@@ -440,12 +440,12 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (array_key_exists('subset', $term)) {
|
|
|
//print "WARNING: unhandled tag: subset\n";
|
|
|
}
|
|
|
// add synonyms for this cvterm
|
|
|
- if (array_key_exists('synonym', $term)) {
|
|
|
+ if (array_key_exists('synonym', $term)) {
|
|
|
if (!tripal_cv_obo_add_synonyms($term, $cvterm)) {
|
|
|
tripal_cv_obo_quiterror("Cannot add synonyms");
|
|
|
}
|
|
@@ -477,7 +477,7 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
|
|
|
tripal_cv_obo_quiterror("Cannot add/update synonyms");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// add the comment to the cvtermprop table
|
|
|
if (array_key_exists('comment', $term)) {
|
|
|
$comments = $term['comment'];
|
|
@@ -498,7 +498,7 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (array_key_exists('xref_analog', $term)) {
|
|
|
foreach ($term['xref_analog'] as $xref) {
|
|
|
if (!tripal_cv_obo_add_cvterm_dbxref($cvterm, $xref)) {
|
|
@@ -561,7 +561,7 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
|
|
|
*
|
|
|
* @ingroup tripal_obo_loader
|
|
|
*/
|
|
|
-function tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
|
|
|
+function tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
|
|
|
$objname, $object_is_relationship = 0, $default_db = 'OBO_REL') {
|
|
|
|
|
|
// make sure the relationship cvterm exists
|
|
@@ -572,16 +572,16 @@ function tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
|
|
|
'is_obsolete' => 0,
|
|
|
);
|
|
|
$relcvterm = tripal_cv_add_cvterm($term, $defaultcv, 1, 0, $default_db);
|
|
|
-
|
|
|
+
|
|
|
if (!$relcvterm) {
|
|
|
- // if the relationship term couldn't be found in the default_db provided
|
|
|
+ // if the relationship term couldn't be found in the default_db provided
|
|
|
// then do on more check to find it in the relationship ontology
|
|
|
$term = array(
|
|
|
'name' => $rel,
|
|
|
'id' => "OBO_REL:$rel",
|
|
|
'definition' => '',
|
|
|
'is_obsolete' => 0,
|
|
|
- );
|
|
|
+ );
|
|
|
$relcvterm = tripal_cv_add_cvterm($term, $defaultcv, 1, 0, 'OBO_REL');
|
|
|
if (!$relcvterm) {
|
|
|
tripal_cv_obo_quiterror("Cannot find the relationship term in the current ontology or in the relationship ontology: $rel\n");
|
|
@@ -593,23 +593,23 @@ function tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
|
|
|
if (!$oterm) {
|
|
|
tripal_cv_obo_quiterror("Could not find object term $objname\n");
|
|
|
}
|
|
|
-
|
|
|
- $objterm = array();
|
|
|
+
|
|
|
+ $objterm = array();
|
|
|
$objterm['id'] = $oterm['id'][0];
|
|
|
$objterm['name'] = $oterm['name'][0];
|
|
|
if (array_key_exists('def', $oterm)) {
|
|
|
$objterm['def'] = $oterm['def'][0];
|
|
|
}
|
|
|
if (array_key_exists('subset', $oterm)) {
|
|
|
- $objterm['subset'] = $oterm['subset'][0];
|
|
|
- }
|
|
|
+ $objterm['subset'] = $oterm['subset'][0];
|
|
|
+ }
|
|
|
if (array_key_exists('namespace', $oterm)) {
|
|
|
$objterm['namespace'] = $oterm['namespace'][0];
|
|
|
}
|
|
|
if (array_key_exists('is_obsolete', $oterm)) {
|
|
|
$objterm['is_obsolete'] = $oterm['is_obsolete'][0];
|
|
|
}
|
|
|
- $objcvterm = tripal_cv_add_cvterm($objterm, $defaultcv, $object_is_relationship, 1, $default_db);
|
|
|
+ $objcvterm = tripal_cv_add_cvterm($objterm, $defaultcv, $object_is_relationship, 1, $default_db);
|
|
|
if (!$objcvterm) {
|
|
|
tripal_cv_obo_quiterror("Cannot add cvterm " . $oterm['name'][0]);
|
|
|
}
|
|
@@ -662,14 +662,14 @@ function tripal_cv_obo_add_synonyms($term, $cvterm) {
|
|
|
// now add the synonyms
|
|
|
if (array_key_exists('synonym', $term)) {
|
|
|
foreach ($term['synonym'] as $synonym) {
|
|
|
-
|
|
|
+
|
|
|
// separate out the synonym definition and the synonym type
|
|
|
$def = preg_replace('/^\s*"(.*)"\s*.*$/', '\1', $synonym);
|
|
|
// the scope will be 'EXACT', etc...
|
|
|
$scope = drupal_strtolower(preg_replace('/^.*"\s+(.*?)\s+.*$/', '\1', $synonym));
|
|
|
if (!$scope) { // if no scope then default to 'exact'
|
|
|
- $scope = 'exact';
|
|
|
- }
|
|
|
+ $scope = 'exact';
|
|
|
+ }
|
|
|
|
|
|
// make sure the synonym type exists in the 'synonym_type' vocabulary
|
|
|
$values = array(
|
|
@@ -701,14 +701,14 @@ function tripal_cv_obo_add_synonyms($term, $cvterm) {
|
|
|
|
|
|
// make sure the synonym doesn't already exists
|
|
|
$values = array(
|
|
|
- 'cvterm_id' => $cvterm->cvterm_id,
|
|
|
+ 'cvterm_id' => $cvterm->cvterm_id,
|
|
|
'synonym' => $def
|
|
|
);
|
|
|
$options = array('statement_name' => 'sel_cvtermsynonym_cvsy');
|
|
|
$results = tripal_core_chado_select('cvtermsynonym', array('*'), $values, $options);
|
|
|
if (count($results) == 0) {
|
|
|
$values = array(
|
|
|
- 'cvterm_id' => $cvterm->cvterm_id,
|
|
|
+ 'cvterm_id' => $cvterm->cvterm_id,
|
|
|
'synonym' => $def,
|
|
|
'type_id' => $syntype->cvterm_id
|
|
|
);
|
|
@@ -754,34 +754,34 @@ function tripal_cv_obo_parse($obo_file, &$header, $jobid) {
|
|
|
$line_num = 0;
|
|
|
$num_read = 0;
|
|
|
$intv_read = 0;
|
|
|
-
|
|
|
- $filesize = filesize($obo_file);
|
|
|
+
|
|
|
+ $filesize = filesize($obo_file);
|
|
|
$interval = intval($filesize * 0.01);
|
|
|
if ($interval < 1) {
|
|
|
$interval = 1;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
// iterate through the lines in the OBO file and parse the stanzas
|
|
|
$fh = fopen($obo_file, 'r');
|
|
|
while ($line = fgets($fh)) {
|
|
|
-
|
|
|
+
|
|
|
$line_num++;
|
|
|
$size = drupal_strlen($line);
|
|
|
$num_read += $size;
|
|
|
- $intv_read += $size;
|
|
|
- $line = trim($line);
|
|
|
+ $intv_read += $size;
|
|
|
+ $line = trim($line);
|
|
|
|
|
|
// update the job status every 1% features
|
|
|
- if ($jobid and $intv_read >= $interval) {
|
|
|
+ if ($jobid and $intv_read >= $interval) {
|
|
|
$percent = sprintf("%.2f", ($num_read / $filesize) * 100);
|
|
|
print "Parsing Line $line_num (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes.\r";
|
|
|
tripal_job_set_progress($jobid, intval(($num_read / $filesize) * 33.33333333));
|
|
|
- $intv_read = 0;
|
|
|
+ $intv_read = 0;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// remove newlines
|
|
|
$line = rtrim($line);
|
|
|
-
|
|
|
+
|
|
|
// remove any special characters that may be hiding
|
|
|
$line = preg_replace('/[^(\x20-\x7F)]*/', '', $line);
|
|
|
|
|
@@ -794,7 +794,7 @@ function tripal_cv_obo_parse($obo_file, &$header, $jobid) {
|
|
|
$line = preg_replace('/^(.*?)\!.*$/', '\1', $line); // TODO: if the explamation is escaped
|
|
|
|
|
|
// at the first stanza we're out of header
|
|
|
- if (preg_match('/^\s*\[/', $line)) {
|
|
|
+ if (preg_match('/^\s*\[/', $line)) {
|
|
|
$in_header = 0;
|
|
|
|
|
|
// store the stanza we just finished reading
|
|
@@ -811,7 +811,7 @@ function tripal_cv_obo_parse($obo_file, &$header, $jobid) {
|
|
|
watchdog('T_obo_loader', "ERROR: Cannot insert stanza into temporary table.", array(), 'error');
|
|
|
exit;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
// get the stanza type: Term, Typedef or Instance
|
|
|
$type = preg_replace('/^\s*\[\s*(.+?)\s*\]\s*$/', '\1', $line);
|
|
@@ -825,13 +825,13 @@ function tripal_cv_obo_parse($obo_file, &$header, $jobid) {
|
|
|
$pair = explode(":", $line, 2);
|
|
|
$tag = $pair[0];
|
|
|
$value = ltrim(rtrim($pair[1]));// remove surrounding spaces
|
|
|
-
|
|
|
+
|
|
|
// if this is the ID then look for the default DB
|
|
|
$matches = array();
|
|
|
if ($tag == 'id' and preg_match('/^(.+?):.*$/', $value, $matches)) {
|
|
|
$default_db = $matches[1];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$tag = preg_replace("/\|-\|-\|/", "\:", $tag); // return the escaped colon
|
|
|
$value = preg_replace("/\|-\|-\|/", "\:", $value);
|
|
|
if ($in_header) {
|
|
@@ -910,7 +910,7 @@ function tripal_cv_obo_add_cvterm_dbxref($cvterm, $xref) {
|
|
|
);
|
|
|
$options = array('statement_name' => 'sel_cvtermdbxref_cvdb');
|
|
|
$result = tripal_core_chado_select('cvterm_dbxref', array('*'), $values, $options);
|
|
|
- if (count($result) == 0) {
|
|
|
+ if (count($result) == 0) {
|
|
|
$ins_options = array(
|
|
|
'statement_name' => 'ins_cvtermdbxref_cvdb',
|
|
|
'return_record' => FALSE
|
|
@@ -944,7 +944,7 @@ function tripal_cv_obo_add_cvterm_prop($cvterm, $property, $value, $rank) {
|
|
|
);
|
|
|
$options = array('statement_name' => 'sel_cvterm_nacv_na');
|
|
|
$results = tripal_core_chado_select('cvterm', array('*'), $values, $options);
|
|
|
- if (count($results) == 0) {
|
|
|
+ if (count($results) == 0) {
|
|
|
$term = array(
|
|
|
'name' => $property,
|
|
|
'id' => "internal:$property",
|
|
@@ -969,7 +969,7 @@ function tripal_cv_obo_add_cvterm_prop($cvterm, $property, $value, $rank) {
|
|
|
if (!$success) {
|
|
|
tripal_cv_obo_quiterror("Could not remove existing properties to update property $property for term\n");
|
|
|
return FALSE;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// now add the property
|
|
@@ -1020,8 +1020,8 @@ function tripal_cv_obo_add_dbxref($db_id, $accession, $version='', $description=
|
|
|
if (!$result) {
|
|
|
tripal_cv_obo_quiterror("Failed to insert the dbxref record $accession");
|
|
|
return FALSE;
|
|
|
- }
|
|
|
- $result = tripal_core_chado_select('dbxref', array('dbxref_id'), $values, $options);
|
|
|
+ }
|
|
|
+ $result = tripal_core_chado_select('dbxref', array('dbxref_id'), $values, $options);
|
|
|
}
|
|
|
return $result[0];
|
|
|
}
|