|  | @@ -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);
 | 
	
		
			
				|  |  |      }
 |