From 963088d35d71ee2c259b35014b5c087601895208 Mon Sep 17 00:00:00 2001 From: Andrew Yates <ayates@ebi.ac.uk> Date: Thu, 2 May 2013 11:24:25 +0000 Subject: [PATCH] There are some circumstances where exon coordinate recalculation is not the right thing to do and the user has them correctly set out (ori spanning transcription models). Rather than tie this directly into the coordinate recalculations we are allowing skipping this procedure. It is up to the user to do the right thing if using this module. It also does not alter any existing functionality --- modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm | 6 ++++-- modules/Bio/EnsEMBL/DBSQL/TranscriptAdaptor.pm | 11 +++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm index daa9b97142..19e12072e6 100644 --- a/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/GeneAdaptor.pm @@ -1141,6 +1141,8 @@ sub store_alt_alleles { The gene to store in the database Arg [2] : ignore_release in xrefs [default 1] set to 0 to use release info in external database references + Arg [3] : prevent coordinate recalculation if you are persisting + transcripts with this gene Example : $gene_adaptor->store($gene); Description: Stores a gene in the database. Returntype : the database identifier (dbID) of the newly stored gene @@ -1152,7 +1154,7 @@ sub store_alt_alleles { =cut sub store { - my ($self, $gene, $ignore_release) = @_; + my ($self, $gene, $ignore_release, $skip_recalculating_coordinates) = @_; if (!ref $gene || !$gene->isa('Bio::EnsEMBL::Gene')) { throw("Must store a gene object, not a $gene"); @@ -1281,7 +1283,7 @@ sub store { my $new = $transcripts->[$i]; my $old = $original_transcripts->[$i]; - $transcript_adaptor->store($new, $gene_dbID, $analysis_id); + $transcript_adaptor->store($new, $gene_dbID, $analysis_id, $skip_recalculating_coordinates); if (!defined($new_canonical_transcript_id) && $new->is_canonical()) diff --git a/modules/Bio/EnsEMBL/DBSQL/TranscriptAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/TranscriptAdaptor.pm index 799e73cff4..933d491abb 100644 --- a/modules/Bio/EnsEMBL/DBSQL/TranscriptAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/TranscriptAdaptor.pm @@ -749,6 +749,8 @@ sub fetch_all_by_biotype { backward compatibility only and used to fall back to the gene analysis_id if no analysis object is attached to the transcript (which you should do for new code). + Arg [4] : prevent coordinate recalculation if you are persisting + transcripts with this gene Example : $transID = $tr_adaptor->store($transcript, $gene->dbID); Description: Stores a transcript in the database and returns the new internal identifier for the stored transcript. @@ -760,7 +762,7 @@ sub fetch_all_by_biotype { =cut sub store { - my ( $self, $transcript, $gene_dbID, $analysis_id ) = @_; + my ( $self, $transcript, $gene_dbID, $analysis_id, $skip_recalculating_coordinates ) = @_; if ( !ref($transcript) || !$transcript->isa('Bio::EnsEMBL::Transcript') ) @@ -775,7 +777,12 @@ sub store { } # Force lazy-loading of exons and ensure coords are correct. - $transcript->recalculate_coordinates(); + # If we have been told not to do this then skip doing this + # and we assume the user knows what they are doing. You have been + # warned + if(! $skip_recalculating_coordinates) { + $transcript->recalculate_coordinates(); + } my $is_current = ( defined( $transcript->is_current() ) ? $transcript->is_current() -- GitLab