Skip to content

Commit

Permalink
Merge pull request #1158 from tripal/tv3.5-pre-release-fixes
Browse files Browse the repository at this point in the history
Bug Fixes pre v3.5 release.
  • Loading branch information
spficklin committed Jan 28, 2021
2 parents a453a45 + e5e2633 commit 1c504ae
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
6 changes: 5 additions & 1 deletion docs/user_guide/example_genomics/genomes_genes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ 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"

.. note::
The Landmark Type is provided for this demo GFF3 file because the chromosome is not defined in the file, only the genomic features on the chromosomes. The landmark type is not needed if the GFF3 file has the chromosomes (scaffolds or contigs) defined in the GFF3 file.

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:

::
Expand Down Expand Up @@ -78,7 +82,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.
Expand Down
54 changes: 32 additions & 22 deletions tripal_chado/includes/TripalImporter/GFF3Importer.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2033,29 +2033,30 @@ 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++;

$parent_feature = $this->getCachedFeature($this->features[$parent]['findex']);
$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'];
}
}

Expand Down Expand Up @@ -2151,7 +2152,15 @@ 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($parent, $this->parent_lookup)) {
$this->parent_lookup[$parent] = [];
}
if (!array_key_exists($start, $this->parent_lookup[$parent])) {
$this->parent_lookup[$parent][$start] = [];
}
$this->parent_lookup[$parent][$start][] = $info['findex'];
}
$this->setItemsHandled($i);
}
Expand All @@ -2168,15 +2177,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);
}
Expand Down

0 comments on commit 1c504ae

Please sign in to comment.