Przeglądaj źródła

fix features in wrong order leading to wrong CDS sequences (fixes #415)

Anthony Bretaudeau 6 lat temu
rodzic
commit
d4443fcf27
1 zmienionych plików z 15 dodań i 16 usunięć
  1. 15 16
      tripal_chado/api/modules/tripal_chado.feature.api.inc

+ 15 - 16
tripal_chado/api/modules/tripal_chado.feature.api.inc

@@ -2,7 +2,7 @@
 /**
  * @file
  * Provides API functions specificially for managing feature
- * records in Chado.  
+ * records in Chado.
  */
 
 /**
@@ -10,7 +10,7 @@
  * @ingroup tripal_chado_api
  * @{
  * Provides API functions specificially for managing feature
- * records in Chado especially retrieving relationships and sequences derived 
+ * records in Chado especially retrieving relationships and sequences derived
  * from relationships and feature alignments.
  * @}
  */
@@ -95,8 +95,8 @@ function chado_reverse_compliment_sequence($sequence) {
  *    - name: The feature name. This will appear on the FASTA definition line.
  *    - parent_id:  (optional) only retrieve a sequence if 'derive_from_parent'
  *      is true and the parent matches this ID.
- *    - featureloc_id: (optional) only retrieve a sequence if 
- *      'derive_from_parent' is true and the alignment is defined with this 
+ *    - featureloc_id: (optional) only retrieve a sequence if
+ *      'derive_from_parent' is true and the alignment is defined with this
  *      featureloc_id.
  * @param $options
  *   An associative array of options. Valid keys include:
@@ -305,7 +305,7 @@ function chado_get_feature_sequences($feature, $options) {
         INNER JOIN {feature} OF   on FL.srcfeature_id = OF.feature_id
         INNER JOIN {cvterm}  OCVT on OF.type_id       = OCVT.cvterm_id
         INNER JOIN {organism} OO  on OF.organism_id   = OO.organism_id
-      WHERE SF.feature_id = :feature_id and NOT (OF.residues = \'\' or OF.residues IS NULL)) as tbl1
+      WHERE SF.feature_id = :feature_id and NOT (OF.residues = \'\' or OF.residues IS NULL) ORDER BY fmin) as tbl1
   ';
   // This query is meant to get all of the sub features of any given
   // feature (arg #1) and order them as they appear on the reference
@@ -392,8 +392,8 @@ function chado_get_feature_sequences($feature, $options) {
             $types[] = $child->type_name;
           }
 
-          // If the first sub feature we need to include the upstream bases. 
-          // First check if the feature is in the foward direction or the 
+          // 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
@@ -408,8 +408,8 @@ function chado_get_feature_sequences($feature, $options) {
             $q = chado_query($parent_sql, array(':upstream' => 0, ':downstream' => $downstream, ':feature_id' => $child->feature_id));
           }
 
-          // Next, if the last sub feature we need to include the downstream 
-          // bases. First check if the feature is in teh forward direction or 
+          // 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.
           elseif ($i == $num_children - 1 and $parent->strand >= 0) {  // forward direction
             // -------------------------- ref
@@ -697,15 +697,15 @@ function chado_get_bulk_feature_sequences($options) {
  * Returns a definition line that can be used in a FASTA file.
  *
  * @param $feature
- *   A single feature object containing all the fields from the chado.feature 
- *   table. Best case is to provide an object generated by the 
+ *   A single feature object containing all the fields from the chado.feature
+ *   table. Best case is to provide an object generated by the
  *   chado_generate_var() function.
  * @param $notes
  *   Optional: additional notes to be added to the definition line.
  * @param $featureloc
  *   Optional: a single featureloc object generated using chado_generate_var
  *   that contains a record from the chado.featureloc table. Provide this if the
- *   sequence was obtained by using the alignment rather than from the 
+ *   sequence was obtained by using the alignment rather than from the
  *   feature.residues column.
  * @param $type
  *   Optional: the type of sequence. By default the feature type is used.
@@ -714,9 +714,9 @@ function chado_get_bulk_feature_sequences($options) {
  *
  * @return
  *   A string of the format: uniquename|name|type|feature_id
- *   or if an alignment:  srcfeature_name:fmin..fmax[+-]; alignment of 
+ *   or if an alignment:  srcfeature_name:fmin..fmax[+-]; alignment of
  *   uniquename|name|type|feature_id.
- * 
+ *
  * @ingroup tripal_feature_api
  */
 function chado_get_fasta_defline($feature, $notes = '', $featureloc = NULL, $type = '', $length = 0) {
@@ -769,7 +769,7 @@ function chado_get_fasta_defline($feature, $notes = '', $featureloc = NULL, $typ
  *
  *  @return
  *   A string of the format: uniquename:featurelocmin..featurelocmax.strand
- * 
+ *
  * @ingroup tripal_feature_api
  */
 function chado_get_location_string($featureloc) {
@@ -785,4 +785,3 @@ function chado_get_location_string($featureloc) {
 
   return $featureloc->srcfeature_id->name . ":" . ($featureloc->fmin + 1) . ".." . $featureloc->fmax .  $strand;
 }
-