浏览代码

Made feature node use autocomplete field for type when creating/editing a feature. Also added additional docuemntation for how to add property types to analysies and featuremaps when editing/inserting

spficklin 11 年之前
父节点
当前提交
a43ef3d007

+ 1 - 1
tripal_analysis/includes/tripal_analysis.form.inc

@@ -191,7 +191,7 @@ function chado_analysis_form(&$node, $form_state = NULL) {
       as many properties as desired by clicking the plus button on the right.  To 
       remove a property, click the minus button.  If a property is not available
       you may add it by ' . l('adding the term', 'admin/tripal/tripal_cv/cvterm/add') . '
-      to the <b>analysis_property</b> vocabulary'),
+      to the <b>analysis_property</b> vocabulary within the <b>tripal</b> database'),
   );
   $form['properties']['table'] = array(
     '#type' => 'markup',

+ 32 - 0
tripal_cv/api/tripal_cv.api.inc

@@ -266,6 +266,9 @@ function tripal_cv_get_cvterm_by_name($name, $cv_id = NULL, $cv_name = 'tripal')
       array('%name' => $name, '%cv' => $cv_name ? $cv_name : $cv_id), WATCHDOG_ERROR);
     return FALSE;
   }
+  if (count($r) == 0) {
+  	return FALSE;
+  }
   return $r[0];
 }
 
@@ -873,4 +876,33 @@ function tripal_cv_add_obo_ref($name, $path) {
   $record->path = $path;
   drupal_write_record('tripal_cv_obo', $record);
   return $record->obo_id;
+}
+
+/**
+ * This function is intended to be used in autocomplete forms
+ * for searching for CV terms that begin with the provided string
+ * 
+ * @param $cv_id
+ * The CV ID in which to search for the term
+ * @param $string
+ * The string to search for
+ * 
+ * @return
+ * A json array of terms that begin with the provided string
+ *  
+ * @ingroup tripal_cv_api
+ */
+function tripal_cv_cvterm_name_autocomplete($cv_id, $string = '') {
+  $sql = "
+    SELECT cvterm_id, name 
+    FROM {cvterm} 
+    WHERE cv_id = %d and lower(name) like lower('%s%%') 
+    ORDER by name
+  ";
+  $results = chado_query($sql, $cv_id, $string);
+  $items = array();
+  while($term = db_fetch_object($results)) {
+     $items[$term->name] = $term->name;
+  }  
+  drupal_json($items);   
 }

+ 1 - 17
tripal_cv/includes/tripal_cv_admin.inc

@@ -426,23 +426,7 @@ function tripal_cv_cvterm_form(&$form_state, $action = 'add') {
   return $form;
 }
 
-/*
- * @ingroup tripal_cv
- */
-function tripal_cv_cvterm_name_autocomplete($cv_id, $string = '') {
-  $sql = "
-    SELECT cvterm_id, name 
-    FROM {cvterm} 
-    WHERE cv_id = %d and name like '%s%%' 
-    ORDER by name
-  ";
-  $results = chado_query($sql, $cv_id, $string);
-  $items = array();
-  while($term = db_fetch_object($results)) {
-     $items[$term->name] = $term->name;
-  }  
-  drupal_json($items);   
-}
+
 /**
  * Purpose: Validates the input for adding a cvterm
  *

+ 0 - 32
tripal_feature/includes/tripal_feature.admin.inc

@@ -85,34 +85,6 @@ function tripal_feature_admin() {
        '#weight' => 2,
     );
 
-
-    $form['feature_edit'] = array(
-       '#type' => 'fieldset',
-       '#title' => t('Feature Editing'),
-       '#collapsible' => 1,
-       '#collapsed' => 1 ,
-    );
-
-    $form['feature_edit']['browser_desc'] = array(
-       '#type'        => 'markup',
-       '#value' => 'When editing or creating a feature, a user must provide the feature type. '.
-                   'The Sequence Ontology list is very large, therefore, to simply the list of types for the user, the following '.
-                   'textbox allows you to specify which features types can be used. This list of terms will appear in the '.
-                   'feature type drop down list of the feature creation/edit form.',
-
-    );
-    $form['feature_edit']['feature_edit_types'] = array(
-       '#title'       => t('Feature Types'),
-       '#type'        => 'textarea',
-       '#description' => t("Enter the Sequence Ontology (SO) terms for the allowed feature types when creating or editing features."),
-       '#default_value' => variable_get('chado_edit_feature_types', 'gene contig EST mRNA'),
-    );
-
-    $form['feature_edit']['set_feature_types'] = array(
-       '#type' => 'submit',
-       '#value' => t('Set Feature Types'),
-    );
-
     $form['summary'] = array(
        '#type' => 'fieldset',
        '#title' => t('Feature Summary Report'),
@@ -208,10 +180,6 @@ function tripal_feature_admin_validate($form, &$form_state) {
       variable_set('tripal_analysis_feature_browse_setting', $form_state['values']['browse_features_analysis']);
     break;
 
-    case t('Set Feature Types') :
-      variable_set('tripal_feature_type_setting', $form_state['values']['feature_edit_types']);
-    break;
-
     case t('Set Summary') :
       variable_set('tripal_feature_summary_setting', $form_state['values']['feature_summary']);
       variable_set('tripal_feature_summary_report_mapping', $form_state['values']['feature_mapping']);

+ 12 - 17
tripal_feature/tripal_feature.module

@@ -784,7 +784,6 @@ function chado_feature_form($node, $param) {
     '#required' => TRUE,
     '#default_value' => $node->title,
     '#description' => t('The title must be a unique identifier for this feature.  It is recommended to use a combination of uniquename, organism and feature type in the title as this is guranteed to be unique.'),
-    '#weight' => 1,
     '#maxlength' => 255
   );
 
@@ -794,7 +793,6 @@ function chado_feature_form($node, $param) {
     '#required' => TRUE,
     '#default_value' => $feature->uniquename,
     '#description' => t('Enter a unique name for this feature.  This name must be unique for the organism and feature type.'),
-    '#weight' => 1,
     '#maxlength' => 255
   );
 
@@ -804,26 +802,21 @@ function chado_feature_form($node, $param) {
     '#required' => TRUE,
     '#default_value' => $feature->name,
     '#description' => t('Enter the name used by humans to refer to this feature.'),
-    '#weight' => 1,
     '#maxlength' => 255
   );
 
-  // get the list of supported feature types
-  $ftypes = array();
-  $ftypes[''] = '';
-  $supported_ftypes = split("[ \n]", variable_get('tripal_feature_type_setting', 'gene mRNA EST contig'));
-  foreach ($supported_ftypes as $ftype) {
-    $ftypes["$ftype"] = $ftype;
-  }
+  // get the sequence ontology CV ID
+  $values = array('name' => 'sequence');
+  $cv = tripal_core_chado_select('cv', array('cv_id'), $values); 
+  $cv_id = $cv[0]->cv_id; 
 
   $form['feature_type'] = array(
    '#title'       => t('Feature Type'),
-   '#type'        => t('select'),
+   '#type'        => 'textfield',
    '#description' => t("Choose the feature type."),
    '#required'    => TRUE,
    '#default_value' => $feature->type_id->name,
-   '#options'     => $ftypes,
-   '#weight'      => 2
+   '#autocomplete_path' => "admin/tripal/tripal_cv/cvterm/auto_name/$cv_id",
   );
 
   // get the list of organisms
@@ -841,7 +834,6 @@ function chado_feature_form($node, $param) {
     '#required'    => TRUE,
     '#default_value' => $feature->organism_id->organism_id,
     '#options'     => $organisms,
-    '#weight'      => 3,
   );
 
   // Get synonyms
@@ -861,7 +853,6 @@ function chado_feature_form($node, $param) {
     '#required' => FALSE,
     '#default_value' => $syn_text,
     '#description' => t('Enter alternate names (synonmys) for this feature to help in searching and identification. You may enter as many alternate names as needed each on different lines.'),
-    '#weight' => 5,
   );
 
   $form['residues']= array(
@@ -870,7 +861,6 @@ function chado_feature_form($node, $param) {
     '#required' => FALSE,
     '#default_value' => $feature->residues,
     '#description' => t('Enter the nucelotide sequences for this feature'),
-    '#weight' => 6
   );
 
   $checked = '';
@@ -883,7 +873,6 @@ function chado_feature_form($node, $param) {
     '#required' => FALSE,
     '#default_value' => $checked,
     '#description' => t('Check this box if this sequence should be retired and no longer included in further analysis.'),
-    '#weight' => 8
   );
   return $form;
 }
@@ -894,6 +883,12 @@ function chado_feature_form($node, $param) {
  */
 function chado_feature_validate($node) {
   $result = 0;
+  
+  // make sure the feature type is a real sequence ontology term
+  $type = tripal_cv_get_cvterm_by_name($node->feature_type, NULL, 'sequence');
+  if (!$type) {
+     form_set_error('feature_type', t("The feature type is not a valid name from the Sequence Ontology."));	
+  }
 
   // if this is an update, we want to make sure that a different feature for
   // the organism doesn't already have this uniquename. We don't want to give

+ 7 - 1
tripal_featuremap/includes/tripal_featuremap.form.inc

@@ -515,7 +515,13 @@ function theme_chado_featuremap_node_form($form) {
   $markup .= drupal_render($form['title']);
   $markup .= drupal_render($form['unittype_id']);
   $markup .= drupal_render($form['description']);
-  $markup .= "<b>Include Additional Details</b><br>You may add additional properties to this map by scrolling to the bottom of this table, selecting a property type from the dropdown and adding text.  You may add as many properties as desired by clicking the plus button on the right.  To remove a property, click the minus button";
+  $markup .= "<b>Include Additional Details</b><br>You may add additional 
+    properties to this map by scrolling to the bottom of this table, selecting 
+    a property type from the dropdown and adding text.  You may add as many 
+    properties as desired by clicking the plus button on the right.  To 
+    remove a property, click the minus button. If a property is not available
+    you may add it by " . l('adding the term', 'admin/tripal/tripal_cv/cvterm/add') . "
+    to the <b>featuremap_property</b> vocabulary within the <b>tripal</b> database.";
   $markup .= $properties_table;
   $markup .= drupal_render($form['is_obsolete']);