Browse Source

Trying to fix bug in feature API call to extract feature sequence from alignment

spficklin 12 years ago
parent
commit
8762ae675c

+ 7 - 4
tripal_feature/api/tripal_feature.api.inc

@@ -640,7 +640,8 @@ function tripal_feature_get_formatted_sequence($feature_id, $feature_name,
           
           $sql = "EXECUTE sequence_by_parent (%d, %d, %d)";
 
-          // if the first sub feature we need to include the upstream bases
+          // if the first sub feature we need to include the upstream bases. first check if 
+          // the feature is in the foward direction or the reverse.
           if ($i == 0 and $parent->strand >= 0) {  // forward direction
             // -------------------------- ref
             //    ....---->  ---->        
@@ -652,9 +653,11 @@ function tripal_feature_get_formatted_sequence($feature_id, $feature_name,
             //    ....<----  <----
             //    down  1       2
             $q = chado_query($sql, 0, $downstream, $child->feature_id);
-          }          
-          // if the last sub feature we need to include the downstream bases
-          elseif ($i == $num_children->num_children - 1 and $parent->strand >= 0) {  // forward direction
+          }
+                    
+          // Next, if the last sub feature we need to include the downstream bases. first check if
+          // the feature is in teh forward direction or the reverse
+          if ($i == $num_children->num_children - 1 and $parent->strand >= 0) {  // forward direction
             // -------------------------- ref
             //        ---->  ---->....
             //          1       2 down

+ 6 - 1
tripal_feature/includes/seq_extract.inc

@@ -523,7 +523,12 @@ function tripal_feature_seq_extract_get_features($org_commonname, $genus, $speci
     $feature_id = $feature->feature_id;
     
     // build the header for each FASTA entry
-    $feature_name = "$feature->uniquename $feature->name $feature->feature_type ($feature->genus $feature->species)";
+    if($feature->uniquename == $feature->name) {
+      $feature_name = "$feature->uniquename $feature->feature_type ($feature->genus $feature->species)";
+    } 
+    else {
+      $feature_name = "$feature->uniquename $feature->name $feature->feature_type ($feature->genus $feature->species)";
+    }
       
     // generate the sequence
     $sequence = tripal_feature_get_formatted_sequence($feature_id, $feature_name,