소스 검색

Fixed bug with GFF3 loader when adding relationships for children that start at the same coordinate

Stephen Ficklin 4 년 전
부모
커밋
2811ee8220

+ 2 - 1
docs/user_guide/example_genomics/genomes_genes.rst

@@ -27,6 +27,7 @@ Enter the following:
   "File", "Upload the file name Citrus_sinensis-orange1.1g015632m.g.gff3"
   "Analysis", "Whole Genome Assembly and Annotation of Citrus sinensis"
   "Organism", "Citrus sinensis"
+  "Landmark Type", "supercontig"
   "All other options", "leave as default"
 
 Finally, click the Import GFF3 file button. You'll notice a job was submitted to the jobs subsystem. Now, to complete the process we need the job to run. We'll do this manually:
@@ -78,7 +79,7 @@ You should see output similar to the following:
     Step 22 of 26: Insert feature ontology terms...
     Step 23 of 26: Insert 'derives_from' relationships...
     Step 24 of 26: Insert Targets...
-    Step 25 of 26: Associate features with analysis....              
+    Step 25 of 26: Associate features with analysis....
     Step 26 of 26: Adding sequences data (Skipped: none available)...
 
     Done.

+ 1 - 0
tripal_chado/includes/TripalFields/so__transcript/so__transcript.inc

@@ -157,6 +157,7 @@ class so__transcript extends ChadoField {
     $results = chado_query($sql, [':feature_id' => $record->feature_id]);
     $i = 0;
     while ($transcript = $results->fetchObject()) {
+      dpm($transcript);
       // Get the location of this mRNA.
       $sql = "
         SELECT FL.*, F.name as srcfeature_name

+ 29 - 22
tripal_chado/includes/TripalImporter/GFF3Importer.inc

@@ -2033,7 +2033,7 @@ class GFF3Importer extends TripalImporter {
     $batch_num = 1;
     $sql = '';
     $args = [];
-    foreach ($this->parent_lookup as $parent => $children) {
+    foreach ($this->parent_lookup as $parent => $starts) {
       $total++;
       $i++;
 
@@ -2041,21 +2041,22 @@ class GFF3Importer extends TripalImporter {
       $parent_uniquename = $parent_feature['uniquename'];
       $parent_feature_id = $this->features[$parent_uniquename]['feature_id'];
       if (!$parent_feature['skipped']) {
-
-        foreach ($children as $child_findex) {
-          $j++;
-          $child_feature = $this->getCachedFeature($child_findex);
-          $child_uniquename = $child_feature['uniquename'];
-          $child_feature_id = $this->features[$child_uniquename]['feature_id'];
-          $type_id = $part_of;
-          if ($child_feature['type'] == 'polypeptide' or $child_feature['type'] == 'protein') {
-            $type_id = $derives_from;
+        foreach ($starts as $start => $children) {
+          foreach ($children as $child_findex) {
+            $j++;
+            $child_feature = $this->getCachedFeature($child_findex);
+            $child_uniquename = $child_feature['uniquename'];
+            $child_feature_id = $this->features[$child_uniquename]['feature_id'];
+            $type_id = $part_of;
+            if ($child_feature['type'] == 'polypeptide' or $child_feature['type'] == 'protein') {
+              $type_id = $derives_from;
+            }
+            $sql .= "(:subject_id_$j, :object_id_$j, :type_id_$j, :rank_$j),\n";
+            $args[":subject_id_$j"] = $child_feature_id;
+            $args[":object_id_$j"] = $parent_feature_id;
+            $args[":type_id_$j"] = $type_id;
+            $args[":rank_$j"] = $this->features[$child_uniquename]['rank'];
           }
-          $sql .= "(:subject_id_$j, :object_id_$j, :type_id_$j, :rank_$j),\n";
-          $args[":subject_id_$j"] = $child_feature_id;
-          $args[":object_id_$j"] = $parent_feature_id;
-          $args[":type_id_$j"] = $type_id;
-          $args[":rank_$j"] = $this->features[$child_uniquename]['rank'];
         }
       }
 
@@ -2151,7 +2152,12 @@ class GFF3Importer extends TripalImporter {
         // Place features in order that they appear by their start coordinates.
         $parent = $feature['parent'];
         $start = $feature['start'];
-        $this->parent_lookup[$parent][$start] = $info['findex'];
+        // We can have multiple children that start at the same location
+        // so we'll store children in an array indexed by start position.
+        if (!array_key_exists($start, $this->parent_lookup[$parent])) {
+          $this->parent_lookup[$parent][$start] = [];
+        }
+        $this->parent_lookup[$parent][$start][] = $info['findex'];
       }
       $this->setItemsHandled($i);
     }
@@ -2168,15 +2174,16 @@ class GFF3Importer extends TripalImporter {
     $this->setItemsHandled(0);
     $this->setTotalItems(count(array_keys($this->parent_lookup)));
     $i = 0;
-    foreach ($this->parent_lookup as $parent => $children) {
-      $starts = array_keys($children);
+    foreach ($this->parent_lookup as $parent => $starts) {
+      $starts = array_keys($starts);
       sort($starts);
       $j = 0;
       foreach ($starts as $start) {
-        $child_findex = $children[$start];
-        $child = $this->getCachedFeature($child_findex);
-        $this->features[$child['uniquename']]['rank'] = $j;
-        $j++;
+        foreach ($this->parent_lookup[$parent][$start] as $child_findex) {
+          $child = $this->getCachedFeature($child_findex);
+          $this->features[$child['uniquename']]['rank'] = $j;
+          $j++;
+        }
       }
       $this->setItemsHandled($j);
     }