Commit f8abbac7 authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

In store():

  * Use fetch_all_by_Transcript() rather than translation() on the
    transcript to get the canonical translation (and any alternative
    translations).

  * ... then store the translation and any alternative translations.

Solves a problem stopping genebuilders from copying genes from one
database to another.
parent a74758df
...@@ -789,7 +789,13 @@ sub store { ...@@ -789,7 +789,13 @@ sub store {
# #
# store translation # store translation
# #
my $translation = $transcript->translation();
my @translations =
@{ $db->get_TranslationAdaptor()
->fetch_all_by_Transcript($transcript) };
my $translation = shift(@translations);
if ( defined($translation) ) { if ( defined($translation) ) {
#make sure that the start and end exon are set correctly #make sure that the start and end exon are set correctly
my $start_exon = $translation->start_Exon(); my $start_exon = $translation->start_Exon();
...@@ -855,6 +861,47 @@ sub store { ...@@ -855,6 +861,47 @@ sub store {
$original_translation->adaptor( $translation->adaptor() ); $original_translation->adaptor( $translation->adaptor() );
} ## end if ( defined($translation...)) } ## end if ( defined($translation...))
#
# Store the alternative translations, if there are any.
#
foreach my $alt_translation (@translations) {
my $start_exon = $alt_translation->start_Exon();
my $end_exon = $alt_translation->end_Exon();
if ( !defined($start_exon) ) {
throw("Translation does not define a start exon.");
} elsif ( !defined($end_exon) ) {
throw("Translation does not defined an end exon.");
}
if ( !defined( $start_exon->dbID() ) ) {
my $key = $start_exon->hashkey();
($start_exon) = grep { $_->hashkey() eq $key } @{$exons};
if ( defined($start_exon) ) {
$alt_translation->start_Exon($start_exon);
} else {
throw(
"Translation's start_Exon does not appear to be one of the "
. "exons in its associated Transcript" );
}
} elsif ( !defined( $end_exon->dbID() ) ) {
my $key = $end_exon->hashkey();
($end_exon) = grep { $_->hashkey() eq $key } @$exons;
if ( defined($end_exon) ) {
$translation->end_Exon($end_exon);
} else {
throw("Translation's end_Exon does not appear to be one of the "
. "exons in its associated Transcript." );
}
}
$db->get_TranslationAdaptor()
->store( $alt_translation, $transc_dbID );
} ## end foreach my $alt_translation...
# #
# store the xrefs/object xref mapping # store the xrefs/object xref mapping
# #
...@@ -953,55 +1000,6 @@ sub store { ...@@ -953,55 +1000,6 @@ sub store {
$transcript->get_all_Attributes); $transcript->get_all_Attributes);
#
# Store the alternative translations, if there are any.
#
my $alt_translations =
$transcript->get_all_alternative_translations();
if ( defined($alt_translations)
&& scalar( @{$alt_translations} ) > 0 )
{
foreach my $alt_translation ( @{$alt_translations} ) {
my $start_exon = $alt_translation->start_Exon();
my $end_exon = $alt_translation->end_Exon();
if ( !defined($start_exon) ) {
throw("Translation does not define a start exon.");
} elsif ( !defined($end_exon) ) {
throw("Translation does not defined an end exon.");
}
if ( !defined( $start_exon->dbID() ) ) {
my $key = $start_exon->hashkey();
($start_exon) = grep { $_->hashkey() eq $key } @{$exons};
if ( defined($start_exon) ) {
$alt_translation->start_Exon($start_exon);
} else {
throw(
"Translation's start_Exon does not appear to be one of the "
. "exons in its associated Transcript" );
}
} elsif ( !defined( $end_exon->dbID() ) ) {
my $key = $end_exon->hashkey();
($end_exon) = grep { $_->hashkey() eq $key } @$exons;
if ( defined($end_exon) ) {
$translation->end_Exon($end_exon);
} else {
throw(
"Translation's end_Exon does not appear to be one of the "
. "exons in its associated Transcript." );
}
}
$db->get_TranslationAdaptor()
->store( $alt_translation, $transc_dbID );
} ## end foreach my $alt_translation...
} ## end if ( defined($alt_translations...))
#update the original transcript object - not the transfered copy that #update the original transcript object - not the transfered copy that
#we might have created #we might have created
$original->dbID($transc_dbID); $original->dbID($transc_dbID);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment