Browse Source

API: Updated featuremap api. Finished except for tripal_featuremap_add_featuremap_dbxref() which is just waiting for the associate dbxref function

Lacey Sanderson 11 years ago
parent
commit
9e4c60b0b3

+ 60 - 5
tripal_featuremap/api/tripal_featuremap.DEPRECATED.inc

@@ -23,7 +23,7 @@ function tripal_featuremap_get_property($featuremap_id, $property) {
     )
   );
 
-  return FALSE;
+  return chado_get_property('featuremap', $featuremap_id, $property, 'featuremap_property');
 }
 
 /**
@@ -45,7 +45,7 @@ function tripal_featuremap_insert_property($featuremap_id, $property, $value, $u
     )
   );
 
-  return FALSE;
+  return chado_insert_property('featuremap', $featuremap_id, $property, 'featuremap_property', $value, $update_if_present);
 }
 
 /**
@@ -67,7 +67,7 @@ function tripal_featuremap_update_property($featuremap_id, $property, $value, $i
     )
   );
 
-  return FALSE;
+  return chado_update_property('featuremap', $featuremap_id, $property, 'featuremap_property', $value, $insert_if_missing);
 }
 
 /**
@@ -89,7 +89,7 @@ function tripal_featuremap_delete_property($featuremap_id, $property) {
     )
   );
 
-  return FALSE;
+  return chado_delete_property('featuremap', $featuremap_id, $property, 'featuremap_property');
 }
 
 /**
@@ -111,5 +111,60 @@ function tripal_featuremap_add_featuremap_dbxref($featuremap_id, $featuremap_dbx
     )
   );
 
-  return FALSE;
+  // break apart the dbxref
+  $dbname = '';
+  $accession = '';
+  if(preg_match('/^(.*?):(.*?)$/', $featuremap_dbxref, $matches)) {
+    $dbname = $matches[1];
+    $accession = $matches[2];
+  }
+  else {
+    return FALSE;
+  }
+
+  // check to see if the featuremap_dbxref record already exist
+  $values = array(
+    'dbxref_id' => array(
+      'accession' => $accession,
+      'db_id' => array(
+        'name' => $dbname,
+      ),
+    ),
+    'featuremap_id' => $featuremap_id,
+  );
+  $options = array('statement_name' => 'sel_featuremapdbxref_dbpu');
+  $results = chado_select_record('featuremap_dbxref', array('*'), $values, $options);
+
+  // if the featuremap_dbxref record  exist then we don't need to re-add it.
+  if(count($results) > 0) {
+    return $results[0];
+  }
+
+  // make sure our database already exists
+  $db = tripal_db_add_db($dbname);
+
+  // get the database cross-reference
+  $dbxvalues = array(
+    'accession' => $accession,
+    'db_id' => $db->db_id,
+  );
+  $dbxoptions = array('statement_name' => 'sel_dbxref_acdb');
+  $results = chado_select_record('dbxref', array('dbxref_id'), $dbxvalues, $dbxoptions);
+  // if the accession doesn't exist then add it
+  if(count($results) == 0){
+    $dbxref = tripal_db_add_dbxref($db->db_id, $accession);
+  }
+  else {
+    $dbxref = $results[0];
+  }
+
+  // now add the record
+  $options = array('statement_name' => 'ins_featuremapdbxref_dbpu');
+  $results = chado_insert_record('featuremap_dbxref', $values, $options);
+  if (!$results) {
+    tripal_report_error('t_featuremap', TRIPAL_ERROR, "Cannot add map dbxref: %db:%accession.",
+      array('%db' => $dbname, '%accession' => $accession));
+    return FALSE;
+  }
+  return $results;
 }

+ 0 - 153
tripal_featuremap/api/tripal_featuremap.api.inc

@@ -11,156 +11,3 @@
  * Provides an application programming interface (API) to manage chado feature maps
  * @}
  */
-
-/**
- * Retrieve properties of a given type for a given featuremap
- *
- * @param $featuremap_id
- *    The featuremap_id of the properties you would like to retrieve
- * @param $property
- *    The cvterm name of the properties to retrieve
- *
- * @return
- *    An featuremap chado variable with the specified properties expanded
- *
- * @ingroup tripal_featuremap_api
- */
-function tripal_featuremap_get_property($featuremap_id, $property) {
-  return chado_get_property('featuremap', $featuremap_id, $property, 'featuremap_property');
-}
-
-/**
- * Insert a given property
- *
- * @param $featuremap_id
- *   The featuremap_id of the property to insert
- * @param $property
- *   The cvterm name of the property to insert
- * @param $value
- *   The value of the property to insert
- * @param $update_if_present
- *   A boolean indicated whether to update the record if it's already present
- *
- * @return
- *   True of success, False otherwise
- *
- * @ingroup tripal_featuremap_api
- */
-function tripal_featuremap_insert_property($featuremap_id, $property, $value, $update_if_present = 0) {
-  return chado_insert_property('featuremap', $featuremap_id, $property, 'featuremap_property', $value, $update_if_present);
-}
-
-/**
- * Update a given property
- *
- * @param $featuremap_id
- *   The featuremap_id of the property to update
- * @param $property
- *   The cvterm name of the property to update
- * @param $value
- *   The value of the property to update
- * @param $insert_if_missing
- *   A boolean indicated whether to insert the record if it's absent
- *
- * Note: The property will be identified using the unique combination of the $featuremap_id and $property
- * and then it will be updated with the supplied value
- *
- * @return
- *   True of success, False otherwise
- *
- * @ingroup tripal_featuremap_api
- */
-function tripal_featuremap_update_property($featuremap_id, $property, $value, $insert_if_missing = 0) {
-  return chado_update_property('featuremap', $featuremap_id, $property, 'featuremap_property', $value, $insert_if_missing);
-}
-
-/**
- * Delete a given property
- *
- * @param $featuremap_id
- *   The featuremap_id of the property to delete
- * @param $property
- *   The cvterm name of the property to delete
- *
- * Note: The property will be identified using the unique combination of the $featuremap_id and $property
- * and then it will be deleted
- *
- * @return
- *   True of success, False otherwise
- *
- * @ingroup tripal_featuremap_api
- */
-function tripal_featuremap_delete_property($featuremap_id, $property) {
-  return chado_delete_property('featuremap', $featuremap_id, $property, 'featuremap_property');
-}
-
-/**
- * Add a dbxref to the featuremap_dbxref table
- *
- * @param $featuremap_id
- *  The id of the featuremap of interest
- * @param $featuremap_dbxref
- *  A string describing the dbxref with the db name separated from the dbxref accession
- *  by a colon (:)
- *
- * @ingroup tripal_featuremap_api
- */
-function tripal_featuremap_add_featuremap_dbxref($featuremap_id, $featuremap_dbxref) {
-
-  // break apart the dbxref
-  $dbname = '';
-  $accession = '';
-  if(preg_match('/^(.*?):(.*?)$/', $featuremap_dbxref, $matches)) {
-    $dbname = $matches[1];
-    $accession = $matches[2];
-  }
-  else {
-    return FALSE;
-  }
-
-  // check to see if the featuremap_dbxref record already exist
-  $values = array(
-    'dbxref_id' => array(
-      'accession' => $accession,
-      'db_id' => array(
-        'name' => $dbname,
-      ),
-    ),
-    'featuremap_id' => $featuremap_id,
-  );
-  $options = array('statement_name' => 'sel_featuremapdbxref_dbpu');
-  $results = chado_select_record('featuremap_dbxref', array('*'), $values, $options);
-
-  // if the featuremap_dbxref record  exist then we don't need to re-add it.
-  if(count($results) > 0) {
-    return $results[0];
-  }
-
-  // make sure our database already exists
-  $db = tripal_db_add_db($dbname);
-
-  // get the database cross-reference
-  $dbxvalues = array(
-    'accession' => $accession,
-    'db_id' => $db->db_id,
-  );
-  $dbxoptions = array('statement_name' => 'sel_dbxref_acdb');
-  $results = chado_select_record('dbxref', array('dbxref_id'), $dbxvalues, $dbxoptions);
-  // if the accession doesn't exist then add it
-  if(count($results) == 0){
-    $dbxref = tripal_db_add_dbxref($db->db_id, $accession);
-  }
-  else {
-    $dbxref = $results[0];
-  }
-
-  // now add the record
-  $options = array('statement_name' => 'ins_featuremapdbxref_dbpu');
-  $results = chado_insert_record('featuremap_dbxref', $values, $options);
-  if (!$results) {
-    tripal_report_error('t_featuremap', TRIPAL_ERROR, "Cannot add map dbxref: %db:%accession.",
-      array('%db' => $dbname, '%accession' => $accession));
-    return FALSE;
-  }
-  return $results;
-}

+ 2 - 9
tripal_featuremap/tripal_featuremap.module

@@ -13,7 +13,7 @@
  */
 
 require_once 'api/tripal_featuremap.api.inc';
-//require_once 'api/tripal_featuremap.DEPRECATED.inc';
+require_once 'api/tripal_featuremap.DEPRECATED.inc';
 
 require_once 'theme/tripal_featuremap.theme.inc';
 
@@ -218,13 +218,6 @@ function tripal_featuremap_theme($existing, $type, $theme, $path) {
       'variables' =>  array(NULL),
       'path' => "$path/theme/tripal_featuremap",
     ),
-    
-    // templates for the chado_feature node type
-    'tripal_feature_featurepos' => array(
-      'arguments' => array('node' => NULL),
-      'template' => 'tripal_feature_featurepos',
-      'path' => "$path/theme/tripal_feature",
-    ),
   );
   return $items;
 }
@@ -284,7 +277,7 @@ function tripal_featuremap_block_view($delta = '') {
         $block['content'] = theme('tripal_featuremap_publication', $node);
         break;
       case 'maprefs':
-        $block['subject'] = t('Cross References');
+        $block['subject'] = t('References');
         $block['content'] = theme('tripal_featuremap_references', $node);
         break;
       default :