Skip to content
Snippets Groups Projects
Commit 2b02d554 authored by Kevin Howe's avatar Kevin Howe
Browse files

When Transcripts are removed, ensure transcript attributes, transcript

supporting features and translation attributes are removed
parent dabc460e
No related branches found
No related tags found
No related merge requests found
......@@ -475,6 +475,8 @@ sub store_on_Translation {
Arg [1] : Bio::EnsEMBL::Slice $slice
The Slice to remove attributes from
Arg [2] : (optional) dbID $attrib_type_id
Database id of attributes to remove
Example : $attribute_adaptor->remove_from_Slice($slice);
Description: Removes all attributes which are stored in the database on
the provided Slice.
......@@ -557,6 +559,106 @@ sub remove_from_MiscFeature {
}
=head2 remove_from_Transcript
Arg [1] : Bio::EnsEMBL::Transcript $transcript
The Transcript to remove attributes from
Arg [2] : (optional) dbID $attrib_type_id
Database id of attributes to remove
Example : $attribute_adaptor->remove_from_Transcript($transcript);
Description: Removes all attributes which are stored in the database on
the provided Transcript.
Returntype : none
Exceptions : throw on incorrect arguments
throw if transcript not stored
Caller : general
Status : Stable
=cut
sub remove_from_Transcript {
my $self = shift;
my $transcript = shift;
my $attrib_type_id = shift;
if(!ref($transcript) || !$transcript->isa('Bio::EnsEMBL::Transcript')) {
throw("Bio::EnsEMBL::Transcript argument expected.");
}
my $db = $self->db();
if (! $transcript->is_stored($db)) {
throw("Transcript is not stored in the database.");
}
if (defined $attrib_type_id) {
my $sth = $self->prepare("DELETE FROM transcript_attrib " .
"WHERE transcript_id = ? AND attrib_type_id = ?");
$sth->execute($transcript->dbID, $attrib_type_id);
$sth->finish;
} else {
my $sth = $self->prepare("DELETE FROM transcript_attrib " .
"WHERE transcript_id = ?");
$sth->execute($transcript->dbID);
$sth->finish();
}
return;
}
=head2 remove_from_Translation
Arg [1] : Bio::EnsEMBL::Translation $translation
The Translation to remove attributes from
Arg [2] : (optional) dbID $attrib_type_id
Database id of attributes to remove
Example : $attribute_adaptor->remove_from_Transcript($transcript);
Description: Removes all attributes which are stored in the database on
the provided Transcript.
Returntype : none
Exceptions : throw on incorrect arguments
throw if transcript not stored
Caller : general
Status : Stable
=cut
sub remove_from_Translation {
my $self = shift;
my $translation = shift;
my $attrib_type_id = shift;
if(!ref($translation) || !$translation->isa('Bio::EnsEMBL::Translation')) {
throw("Bio::EnsEMBL::Translation argument expected.");
}
my $db = $self->db();
if (! $translation->is_stored($db)) {
throw("Transcript is not stored in the database.");
}
if (defined $attrib_type_id) {
my $sth = $self->prepare("DELETE FROM translation_attrib " .
"WHERE translation_id = ? AND attrib_type_id = ?");
$sth->execute($translation->dbID, $attrib_type_id);
$sth->finish;
} else {
my $sth = $self->prepare("DELETE FROM translation_attrib " .
"WHERE translation_id = ?");
$sth->execute($translation->dbID);
$sth->finish();
}
return;
}
# _store_type
......
......@@ -838,6 +838,36 @@ sub remove {
return;
}
# remove the supporting features of this transcript
my $prot_adp = $self->db->get_ProteinAlignFeatureAdaptor;
my $dna_adp = $self->db->get_DnaAlignFeatureAdaptor;
my $sfsth = $self->prepare("SELECT feature_type, feature_id " .
"FROM transcript_supporting_feature " .
"WHERE transcript_id = ?");
$sfsth->execute($transcript->dbID);
while(my ($type, $feature_id) = $sfsth->fetchrow()){
if($type eq 'protein_align_feature'){
my $f = $prot_adp->fetch_by_dbID($feature_id);
$prot_adp->remove($f);
}
elsif($type eq 'dna_align_feature'){
my $f = $dna_adp->fetch_by_dbID($feature_id);
$dna_adp->remove($f);
}
else {
warning("Unknown supporting feature type $type. Not removing feature.");
}
}
$sfsth->finish();
# delete the association to supporting features
$sfsth = $self->prepare("DELETE FROM transcript_supporting_feature WHERE transcript_id = ?");
$sfsth->execute( $transcript->dbID );
$sfsth->finish();
# remove all xref linkages to this transcript
my $dbeAdaptor = $self->db->get_DBEntryAdaptor();
......@@ -845,17 +875,21 @@ sub remove {
$dbeAdaptor->remove_from_object($dbe, $transcript, 'Transcript');
}
my $exonAdaptor = $self->db->get_ExonAdaptor();
my $translationAdaptor = $self->db->get_TranslationAdaptor();
# remove the attributes associated with this transcript
$attrib_adp->remove_from_Transcript($transcript);
my $attrib_adp = $self->db->get_AttributeAdaptor;
# remove the translation associated with this transcript
my $translationAdaptor = $self->db->get_TranslationAdaptor();
if( defined($transcript->translation()) ) {
$translationAdaptor->remove( $transcript->translation );
}
# remove exon associations to this transcript
my $exonAdaptor = $self->db->get_ExonAdaptor();
foreach my $exon ( @{$transcript->get_all_Exons()} ) {
# get the number of transcript references to this exon
# only remove the exon if this is the last transcript to
......
......@@ -314,6 +314,10 @@ sub remove {
return;
}
# remove athe attributes associated with this translation
my $attrib_adp = $self->db->get_AttributeAdaptor;
$attrib_adp->remove_from_Translation($translation);
# remove all xref associations to this translation
my $dbe_adaptor = $self->db()->get_DBEntryAdaptor();
foreach my $dbe (@{$translation->get_all_DBEntries()}) {
......
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