Parcourir la source

Added specific handling of Patent type publications. Fixed the tpub.obo as some of the accessions were missing the colon between the DB name and number.

spficklin il y a 11 ans
Parent
commit
e557f16da4

+ 1 - 1
tripal_feature/includes/gff_loader.inc

@@ -436,7 +436,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
         $result = chado_query("EXECUTE sel_cvterm_idnasy (%d, '%s', '%s')", $cv->cv_id, $landmark_type, $landmark_type);
         $cvterm = db_fetch_object($result);
         if (!$cvterm) {
-          watchdog('T_gff3_loader', 'cannot find feature term \'%landmark_type\' on line %line_num of the GFF file', 
+          watchdog('T_gff3_loader', 'cannot find feature type \'%landmark_type\' on line %line_num of the GFF file', 
             array('%landmark_type' => $landmark_type, '%line_num' => $line_num), WATCHDOG_ERROR);
           return '';
         }

+ 41 - 0
tripal_pub/api/tripal_pub.api.inc

@@ -558,6 +558,47 @@ function tripal_pub_get_pubs_by_title_type_pyear_series($title, $type = NULL, $p
   }
   return $return;  
 }
+/**
+ * Returns the list of publications that match a given title, type and year
+ * 
+ * @param title
+ *   The title of the publication to look for
+ * @param type
+ *   Optional. The publication type. The value of this field should come from 
+ *   the Tripal Pub vocabulary. This should be the type name (e.g. cvterm.name)
+ * @param year
+ *   Optional. The year the publication was published.
+ * @param series_name
+ *   Optional.  The name of the series (e.g. Journal name)
+ * 
+ * @return
+ *   Returns an array of all the publications that have the provided
+ *   cross reference. If no publications match, then an empty array
+ *   is returned.
+ *   
+ * @ingroup tripal_pub_api 
+ * 
+ */
+function tripal_pub_get_pub_by_uniquename($name) {
+  
+  $return = array();
+  
+  // build the values array for the query. 
+  $values = array(
+    'uniquename' => $name,
+  );
+  $options = array(
+    'statement_name' => 'sel_pub_un',
+    'case_insensitive_columns' => array('uniquename'),
+  );
+  $results = tripal_core_chado_select('pub', array('pub_id'), $values, $options);
+  
+  // iterate through any matches and pull out the pub_id
+  foreach ($results as $index => $pub) {
+    $return[] = $pub->pub_id;  
+  }
+  return $return;  
+}
 /**
  * Adds a new publication to the Chado, along with all properties and
  * database cross-references. If the publication does not already exist

Fichier diff supprimé car celui-ci est trop grand
+ 148 - 141
tripal_pub/files/tpub.obo


+ 33 - 5
tripal_pub/includes/pub_form.inc

@@ -212,7 +212,7 @@ function chado_pub_validate($node, &$form) {
   $options = array('statement_name' => 'sel_pub_ty');
   $cvterm = tripal_core_chado_select('cvterm', array('name'), $values, $options);
   if (count($cvterm) == 0) {
-    $message = t('Invalided publication type.');
+    $message = t('Invalid publication type.');
     form_set_error('type_id', $message);
     return;
   }
@@ -226,20 +226,33 @@ function chado_pub_validate($node, &$form) {
       $prop_type = tripal_cv_get_cvterm_by_id($prop_type_id);
       if($prop_type->name == 'Conference Name' or $prop_type->name == 'Journal Name') {
         $series_name = $value;
-      }    
+      }  
+      if($prop_type->name == 'Citation') {
+        $uniquename = $value;
+      }  
     }
     // if this is a new property (added by this submit of the form)
     elseif ($element = 'new_id') {
       $prop_type = tripal_cv_get_cvterm_by_id($value);
       if($prop_type->name == 'Conference Name' or $prop_type->name == 'Journal Name') {
         $series_name = $node->new_value;
-      }  
+      }
+      if($prop_type->name == 'Citation') {
+        $uniquename = $value;
+      }    
     }
   }
+  
+  $skip_duplicate_check = 0; 
+  
+  // if this publication is a Patent then skip the validation below.  Patents can have the title
+  // name and year but be different    
+  if (strcmp($cvterm[0]->name,'Patent') == 0) {
+    $skip_duplicate_check = 1;
+  }
  
   // on an update ($pub_id is set), check to see if there have been  changes to fields that
-  // are used to check for duplicates. If not, then no need to check for duplicates
-  $skip_duplicate_check = 0; 
+  // are used to check for duplicates. If not, then no need to check for duplicates  
   if ($pub_id) {
     // first get the original title, type and year before it was changed
     $values = array('pub_id' => $pub_id);
@@ -306,6 +319,21 @@ function chado_pub_validate($node, &$form) {
         break;
     }      
   } 
+  // even though we are skipping the duplication checks above we must make sure the uniquename is unique 
+  // as that is the offical table constraint
+  else {
+    $results = tripal_pub_get_pub_by_uniquename($uniquename);
+    // make sure we don't capture our pub_id in the list (remove it)
+    foreach ($results as $index => $found_pub_id) {
+      if($found_pub_id == $pub_id){
+        unset($results[$index]);
+      }
+    }         
+    if (count($results) > 0) {
+      $message = t('A publication with this unique citation already exists.'); 
+      form_set_error('uniquename', $message);
+    }  
+  }
 }
 /*
  * 

+ 4 - 2
tripal_pub/tripal_pub.module

@@ -189,7 +189,7 @@ function tripal_pub_menu() {
  */
 function tripal_pub_theme() {
 
-  return array(
+  $themes = array(
     // node templates
     'tripal_pub_base' => array(
       'arguments' => array('node' => NULL),
@@ -223,8 +223,10 @@ function tripal_pub_theme() {
     ),
     'chado_pub_node_form' => array(
        'arguments' => array('form'),
-    ),
+    ),   
   );
+  
+  return $themes;
 }
 
 /**

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff