|
@@ -409,18 +409,18 @@ class OBOImporter extends TripalImporter {
|
|
|
|
|
|
// Update the cv_root_mview materiailzed view.
|
|
// Update the cv_root_mview materiailzed view.
|
|
$this->logMessage("Updating the cv_root_mview materialized view...");
|
|
$this->logMessage("Updating the cv_root_mview materialized view...");
|
|
- $mview_id = chado_get_mview_id('cv_root_mview');
|
|
|
|
- chado_populate_mview($mview_id);
|
|
|
|
|
|
+ $mview_id = tripal_get_mview_id('cv_root_mview');
|
|
|
|
+ tripal_populate_mview($mview_id);
|
|
|
|
|
|
$this->logMessage("Updating the db2cv_mview materialized view...");
|
|
$this->logMessage("Updating the db2cv_mview materialized view...");
|
|
- $mview_id = chado_get_mview_id('db2cv_mview');
|
|
|
|
- chado_populate_mview($mview_id);
|
|
|
|
|
|
+ $mview_id = tripal_get_mview_id('db2cv_mview');
|
|
|
|
+ tripal_populate_mview($mview_id);
|
|
|
|
|
|
// Upate the cvtermpath table for each newly added CV.
|
|
// Upate the cvtermpath table for each newly added CV.
|
|
$this->logMessage("Updating cvtermpath table. This may take a while...");
|
|
$this->logMessage("Updating cvtermpath table. This may take a while...");
|
|
foreach ($this->newcvs as $namespace => $cvid) {
|
|
foreach ($this->newcvs as $namespace => $cvid) {
|
|
$this->logMessage("- Loading paths for @vocab", array('@vocab' => $namespace));
|
|
$this->logMessage("- Loading paths for @vocab", array('@vocab' => $namespace));
|
|
- chado_update_cvtermpath($cvid);
|
|
|
|
|
|
+ tripal_update_cvtermpath($cvid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
@@ -486,7 +486,7 @@ class OBOImporter extends TripalImporter {
|
|
*/
|
|
*/
|
|
private function loadOBO_v1_2_file($obo_name, $file, $is_new = TRUE) {
|
|
private function loadOBO_v1_2_file($obo_name, $file, $is_new = TRUE) {
|
|
if ($is_new) {
|
|
if ($is_new) {
|
|
- chado_insert_obo($obo_name, $file);
|
|
|
|
|
|
+ tripal_insert_obo($obo_name, $file);
|
|
}
|
|
}
|
|
|
|
|
|
$success = $this->loadOBO_v1_2($file, $obo_name);
|
|
$success = $this->loadOBO_v1_2($file, $obo_name);
|
|
@@ -528,7 +528,7 @@ class OBOImporter extends TripalImporter {
|
|
fclose($obo_fh);
|
|
fclose($obo_fh);
|
|
|
|
|
|
if ($is_new) {
|
|
if ($is_new) {
|
|
- chado_insert_obo($obo_name, $url);
|
|
|
|
|
|
+ tripal_insert_obo($obo_name, $url);
|
|
}
|
|
}
|
|
|
|
|
|
// second, parse the OBO
|
|
// second, parse the OBO
|
|
@@ -568,7 +568,7 @@ class OBOImporter extends TripalImporter {
|
|
// present for each stanza. Some ontologies have adopted the v1.4 method
|
|
// present for each stanza. Some ontologies have adopted the v1.4 method
|
|
// in their v1.2 files and not including it.
|
|
// in their v1.2 files and not including it.
|
|
if (array_key_exists('default-namespace', $header)) {
|
|
if (array_key_exists('default-namespace', $header)) {
|
|
- $defaultcv = chado_insert_cv($header['default-namespace'][0], '');
|
|
|
|
|
|
+ $defaultcv = tripal_insert_cv($header['default-namespace'][0], '');
|
|
if (!$defaultcv) {
|
|
if (!$defaultcv) {
|
|
throw new Exception('Cannot add namespace ' . $header['default-namespace'][0]);
|
|
throw new Exception('Cannot add namespace ' . $header['default-namespace'][0]);
|
|
}
|
|
}
|
|
@@ -607,7 +607,7 @@ class OBOImporter extends TripalImporter {
|
|
else {
|
|
else {
|
|
$results = $short_name;
|
|
$results = $short_name;
|
|
}
|
|
}
|
|
- $defaultcv = chado_insert_cv(strtoupper($results), '');
|
|
|
|
|
|
+ $defaultcv = tripal_insert_cv(strtoupper($results), '');
|
|
$this->newcvs[$defaultcv->name] = $defaultcv->cv_id;
|
|
$this->newcvs[$defaultcv->name] = $defaultcv->cv_id;
|
|
}
|
|
}
|
|
catch (Exception $e) {
|
|
catch (Exception $e) {
|
|
@@ -759,6 +759,42 @@ class OBOImporter extends TripalImporter {
|
|
$t['is_obsolete'] = $term['is_obsolete'][0];
|
|
$t['is_obsolete'] = $term['is_obsolete'][0];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Check the id isn't a reference to another term.
|
|
|
|
+ if (strpos($t['id'], ':')) {
|
|
|
|
+ $pair = explode(":", $t['id']);
|
|
|
|
+ $ontology_id = $pair[0];
|
|
|
|
+ $accession_num = $pair[1];
|
|
|
|
+ if (is_numeric($accession_num)) {
|
|
|
|
+ $results = $this->oboEbiLookup($t['id'], 'query');
|
|
|
|
+ if (!empty($results)) {
|
|
|
|
+ if (array_key_exists('docs', $results)) {
|
|
|
|
+ if (!empty($results['docs'])) {
|
|
|
|
+ $t['id'] = $results['docs']['label'];
|
|
|
|
+ } else {
|
|
|
|
+ // The first search doesn't work, so let's try a broader one.
|
|
|
|
+ $results = $this->oboEbiLookup($t['id'], 'query-non-local');
|
|
|
|
+ if (!empty($results)) {
|
|
|
|
+ if (array_key_exists('docs', $results)) {
|
|
|
|
+ if (!empty($results['docs'])) {
|
|
|
|
+ $accession = $t['id'];
|
|
|
|
+ $accession_underscore = str_replace(":", "_", $accession);
|
|
|
|
+ foreach ($results['docs'] as $item) {
|
|
|
|
+ if ($item['label'] != $accession && $item['label'] != $accession_underscore) {
|
|
|
|
+ //Found the first place a label is other than the accession is used, so take
|
|
|
|
+ // that info and then end the loop.
|
|
|
|
+ $t['id'] = $item['label'];
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// Check that the default_cv is in the cv table.
|
|
// Check that the default_cv is in the cv table.
|
|
$sql = "
|
|
$sql = "
|
|
SELECT CV.name
|
|
SELECT CV.name
|
|
@@ -776,7 +812,7 @@ class OBOImporter extends TripalImporter {
|
|
elseif (array_key_exists('namespace', $ontology_info['config'])) {
|
|
elseif (array_key_exists('namespace', $ontology_info['config'])) {
|
|
$results = $ontology_info['config']['namespace'];
|
|
$results = $ontology_info['config']['namespace'];
|
|
}
|
|
}
|
|
- $cv_returned = chado_insert_cv($results[0], '');
|
|
|
|
|
|
+ $cv_returned = tripal_insert_cv($results[0], '');
|
|
// If name && definition are both empty then look up the term from the ontology you just loaded.
|
|
// If name && definition are both empty then look up the term from the ontology you just loaded.
|
|
if($cv_returned) {
|
|
if($cv_returned) {
|
|
$defaultcv = $cv_returned;
|
|
$defaultcv = $cv_returned;
|
|
@@ -790,7 +826,7 @@ class OBOImporter extends TripalImporter {
|
|
$t['db_name'] = $default_db;
|
|
$t['db_name'] = $default_db;
|
|
|
|
|
|
// add the cvterm
|
|
// add the cvterm
|
|
- $cvterm = chado_insert_cvterm($t, array('update_existing' => TRUE));
|
|
|
|
|
|
+ $cvterm = tripal_insert_cvterm($t, array('update_existing' => TRUE));
|
|
if (!$cvterm) {
|
|
if (!$cvterm) {
|
|
throw new Exception("Cannot add the term " . $term['id'][0]);
|
|
throw new Exception("Cannot add the term " . $term['id'][0]);
|
|
}
|
|
}
|
|
@@ -1001,7 +1037,7 @@ class OBOImporter extends TripalImporter {
|
|
'is_relationship' => TRUE,
|
|
'is_relationship' => TRUE,
|
|
'db_name' => $default_db
|
|
'db_name' => $default_db
|
|
);
|
|
);
|
|
- $relcvterm = chado_insert_cvterm($term, array('update_existing' => FALSE));
|
|
|
|
|
|
+ $relcvterm = tripal_insert_cvterm($term, array('update_existing' => FALSE));
|
|
|
|
|
|
if (!$relcvterm) {
|
|
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
|
|
@@ -1015,7 +1051,7 @@ class OBOImporter extends TripalImporter {
|
|
'is_relationship' => TRUE,
|
|
'is_relationship' => TRUE,
|
|
'db_name' => 'OBO_REL'
|
|
'db_name' => 'OBO_REL'
|
|
);
|
|
);
|
|
- $relcvterm = chado_insert_cvterm($term, array('update_existing' => FALSE));
|
|
|
|
|
|
+ $relcvterm = tripal_insert_cvterm($term, array('update_existing' => FALSE));
|
|
if (!$relcvterm) {
|
|
if (!$relcvterm) {
|
|
throw new Exception("Cannot find the relationship term in the current ontology or in the relationship ontology: $rel\n");
|
|
throw new Exception("Cannot find the relationship term in the current ontology or in the relationship ontology: $rel\n");
|
|
}
|
|
}
|
|
@@ -1047,7 +1083,7 @@ class OBOImporter extends TripalImporter {
|
|
$objterm['is_relationship'] = $object_is_relationship;
|
|
$objterm['is_relationship'] = $object_is_relationship;
|
|
$objterm['db_name'] = $default_db;
|
|
$objterm['db_name'] = $default_db;
|
|
|
|
|
|
- $objcvterm = chado_insert_cvterm($objterm, array('update_existing' => TRUE));
|
|
|
|
|
|
+ $objcvterm = tripal_insert_cvterm($objterm, array('update_existing' => TRUE));
|
|
if (!$objcvterm) {
|
|
if (!$objcvterm) {
|
|
throw new Exception("Cannot add cvterm " . $oterm['name'][0]);
|
|
throw new Exception("Cannot add cvterm " . $oterm['name'][0]);
|
|
}
|
|
}
|
|
@@ -1100,7 +1136,7 @@ class OBOImporter extends TripalImporter {
|
|
private function addSynonym($term, $cvterm) {
|
|
private function addSynonym($term, $cvterm) {
|
|
|
|
|
|
// make sure we have a 'synonym_type' vocabulary
|
|
// make sure we have a 'synonym_type' vocabulary
|
|
- $syncv = chado_insert_cv(
|
|
|
|
|
|
+ $syncv = tripal_insert_cv(
|
|
'synonym_type',
|
|
'synonym_type',
|
|
'A local vocabulary added for synonym types.'
|
|
'A local vocabulary added for synonym types.'
|
|
);
|
|
);
|
|
@@ -1124,7 +1160,7 @@ class OBOImporter extends TripalImporter {
|
|
'name' => 'synonym_type',
|
|
'name' => 'synonym_type',
|
|
),
|
|
),
|
|
);
|
|
);
|
|
- $syntype = chado_get_cvterm($values);
|
|
|
|
|
|
+ $syntype = tripal_get_cvterm($values);
|
|
|
|
|
|
// if it doesn't exist then add it
|
|
// if it doesn't exist then add it
|
|
if (!$syntype) {
|
|
if (!$syntype) {
|
|
@@ -1137,7 +1173,7 @@ class OBOImporter extends TripalImporter {
|
|
'cv_name' => $syncv->name,
|
|
'cv_name' => $syncv->name,
|
|
'is_relationship' => FALSE
|
|
'is_relationship' => FALSE
|
|
);
|
|
);
|
|
- $syntype = chado_insert_cvterm($term, array('update_existing' => TRUE));
|
|
|
|
|
|
+ $syntype = tripal_insert_cvterm($term, array('update_existing' => TRUE));
|
|
if (!$syntype) {
|
|
if (!$syntype) {
|
|
throw new Exception("Cannot add synonym type: internal:$scope");
|
|
throw new Exception("Cannot add synonym type: internal:$scope");
|
|
}
|
|
}
|
|
@@ -1324,7 +1360,7 @@ class OBOImporter extends TripalImporter {
|
|
}
|
|
}
|
|
|
|
|
|
// add the database
|
|
// add the database
|
|
- $db = chado_insert_db(array('name' => $dbname));
|
|
|
|
|
|
+ $db = tripal_insert_db(array('name' => $dbname));
|
|
if (!$db) {
|
|
if (!$db) {
|
|
throw new Exception("Cannot find database '$dbname' in Chado.");
|
|
throw new Exception("Cannot find database '$dbname' in Chado.");
|
|
}
|
|
}
|
|
@@ -1369,7 +1405,7 @@ class OBOImporter extends TripalImporter {
|
|
private function addCvtermProp($cvterm, $property, $value, $rank) {
|
|
private function addCvtermProp($cvterm, $property, $value, $rank) {
|
|
|
|
|
|
// make sure the 'cvterm_property_type' CV exists
|
|
// make sure the 'cvterm_property_type' CV exists
|
|
- $cv = chado_insert_cv('cvterm_property_type', '');
|
|
|
|
|
|
+ $cv = tripal_insert_cv('cvterm_property_type', '');
|
|
if (!$cv) {
|
|
if (!$cv) {
|
|
throw new Exception("Cannot add/find cvterm_property_type cvterm");
|
|
throw new Exception("Cannot add/find cvterm_property_type cvterm");
|
|
}
|
|
}
|
|
@@ -1389,7 +1425,7 @@ class OBOImporter extends TripalImporter {
|
|
'cv_name' => $cv->name,
|
|
'cv_name' => $cv->name,
|
|
'is_relationship' => FALSE,
|
|
'is_relationship' => FALSE,
|
|
);
|
|
);
|
|
- $cvproptype = chado_insert_cvterm($term, array('update_existing' => FALSE));
|
|
|
|
|
|
+ $cvproptype = tripal_insert_cvterm($term, array('update_existing' => FALSE));
|
|
if (!$cvproptype) {
|
|
if (!$cvproptype) {
|
|
throw new Exception("Cannot add cvterm property: internal:$property");
|
|
throw new Exception("Cannot add cvterm property: internal:$property");
|
|
}
|
|
}
|