Commit 94e719fd authored by Magali Ruffier's avatar Magali Ruffier
Browse files

ENSCORESW-3737: new MANE object inherit from transcript

parent 5b3e0ee7
Pipeline #161830 failed with stage
in 19 minutes and 29 seconds
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016-2021] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
=head1 CONTACT
Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.
=cut
=head1 NAME
Bio::EnsEMBL::MANE - Object representing a MANE transcript
=head1 SYNOPSIS
use Bio::EnsEMBL::MANE;
$mane_transcript = Bio::EnsEMBL::MANE->new(
-transcript => $transcript
);
=head1 DESCRIPTION
This is a MANE transcript
It represents an Ensembl transcript that has a matching RefSeq equivalent
=head1 METHODS
=cut
use strict;
package Bio::EnsEMBL::MANE;
use vars qw(@ISA);
use Bio::EnsEMBL::Feature;
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Scalar::Util qw(weaken isweak);
@ISA = qw(Bio::EnsEMBL::Feature);
use constant SEQUENCE_ONTOLOGY => {
acc => 'SO:0000673',
term => 'transcript',
};
=head2 new
Arg [...] : Named arguments passed to superclass
Example : $feature = Bio::EnsEMBL::MANE->new
(-transcript => $transcript);
Description: Constructs a new Bio::EnsEMBL::MANE.
Returntype : Bio::EnsEMBL::MANE
Exceptions :
Caller : general, subclass constructors
Status : Stable
=cut
sub new {
my $caller = shift;
#allow this to be called as class or object method
my $class = ref($caller) || $caller;
my $self = $class->SUPER::new(@_);
my ($transcript, $stable_id, $seq_region_start, $seq_region_end) = rearrange(['TRANSCRIPT', 'STABLE_ID', 'SEQ_REGION_START', 'SEQ_REGION_END'],@_);
$self->{'transcript'} = $transcript;
$self->{'stable_id'} = $stable_id;
$self->{'seq_region_start'} = $seq_region_start;
$self->{'seq_region_end'} = $seq_region_end;
return $self;
}
=head2 transcript
Arg [1] : Fetch the original transcript object
Example : $transcript = $mane->transcript();
Description: Getter/Setter for the transcript object
Returntype : Bio::EnsEMBL::Transcript
Exceptions : none
Caller : general
Status : Stable
=cut
sub transcript {
my $self = shift;
$self->{'transcript'} = shift if(@_);
return $self->{'transcript'};
}
=head2 stable_id
Arg [1] : (optional) string $stable_id
Example : $stable_id = $mane->stable_id();
Description: Getter/Setter for the stable_id for
the transcript associated with this MANE transcript
Returntype : String
Exceptions : none
Caller : general
Status : Stable
=cut
sub stable_id {
my $self = shift;
$self->{'stable_id'} = shift if(@_);
return $self->{'stable_id'};
}
=head2 refseq
Arg [1] : Fetch the RefSeq accession associated with
this transcript
Example : $refseq = $mane->refseq();
Description: Getter/Setter for the RefSeq associated with this
MANE transcript.
Returntype : string
Exceptions : none
Caller : general
Status : Stable
=cut
sub refseq {
my $self = shift;
my $transcript = $self->transcript;
my @attributes = @{ $transcript->get_all_Attributes() };
foreach my $attribute (@attributes) {
if ($attribute->code =~ /MANE/) {
return $attribute->value;
}
}
}
=head2 type
Arg [1] : (optional) string mane class
Example : $mane = $mane->type();
Description: Getter/Setter for the class of MANE
associated with this transcript.
Returntype : String
Exceptions : none
Caller : general
Status : Stable
=cut
sub type {
my $self = shift;
my $transcript = $self->transcript;
my @attributes = @{ $transcript->get_all_Attributes() };
foreach my $attribute (@attributes) {
if ($attribute->code =~ /MANE/) {
return $attribute->code;
}
}
}
sub display_id {
my $self = shift;
my $id = $self->stable_id;
return $id;
}
=head2 summary_as_hash
Example : my $hash = $mane->summary_as_hash();
Description: Generates a HashRef compatible with GFFSerializer. Adds
Gene, RefSeq accession and MANE class to the basic feature hash
Returntype : Hash
Exceptions : none
Caller : general
Status : Stable
=cut
sub summary_as_hash {
my ($self) = @_;
my $summary_ref = $self->SUPER::summary_as_hash;
$summary_ref->{'refseq_match'} = $self->refseq();
$summary_ref->{'type'} = $self->type();
$summary_ref->{'id'} = $self->stable_id();
my $parent = $self->transcript->get_Gene();
$summary_ref->{'Parent'} = $parent->display_id if defined $parent;
$summary_ref->{'strand'} = $self->transcript->strand();
return $summary_ref;
}
1;
......@@ -68,6 +68,7 @@ use Bio::EnsEMBL::UTR;
use Bio::EnsEMBL::Intron;
use Bio::EnsEMBL::ExonTranscript;
use Bio::EnsEMBL::CDS;
use Bio::EnsEMBL::MANE;
use Bio::EnsEMBL::TranscriptMapper;
use Bio::EnsEMBL::SeqEdit;
use Bio::EnsEMBL::Biotype;
......@@ -3345,4 +3346,51 @@ sub biotype {
return $self->get_Biotype->name;
}
=head2 mane_transcript
Example : $mane = $transcript->mane_transcript();
Description: Retrieve the corresponding MANE transcript
Returntype : Bio::EnsEMBL::MANE
Exceptions : none
Caller : general
Status : Stable
=cut
sub mane_transcript {
my ($self) = @_;
if ($self->is_mane) {
my $mane = Bio::EnsEMBL::MANE->new(
-SEQ_REGION_START => $self->seq_region_start,
-SEQ_REGION_END => $self->seq_region_end,
-START => $self->start,
-END => $self->end,
-STABLE_ID => $self->stable_id,
-SLICE => $self->slice,
-TRANSCRIPT => $self
);
return $mane;
}
return undef;
}
=head2 is_mane
Example : $boolean = $transcript->is_mane();
Description: Check if a transcript is part of MANE
Returntype : boolean
Exceptions : none
Caller : general
Status : Stable
=cut
sub is_mane {
my ($self) = @_;
my $is_mane = 0;
foreach my $attribute (@{ $self->get_all_Attributes() } ) {
if ($attribute->code=~ /MANE/) {
$is_mane = 1;
}
}
return $is_mane;
}
1;
# Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
# Copyright [2016-2021] EMBL-European Bioinformatics Institute
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
use strict;
use Test::More;
use Test::Warnings;
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
require_ok('Bio::EnsEMBL::MANE');
our $verbose = 0; #set to 1 to turn on debug printouts
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new();
ok(1);
my $db = $multi->get_DBAdaptor( 'core' );
ok($db);
my $stable_id = 'ENST00000202017';
my $transcript_adaptor = $db->get_TranscriptAdaptor();
my $transcript =
$transcript_adaptor->fetch_by_stable_id($stable_id);
print "Check if transcript is part of MANE\n";
is($transcript->is_mane, 1, "$stable_id is part of mane");
my $mane_transcript = $transcript->mane_transcript();
print "Retrieve MANE attributes\n";
is($mane_transcript->stable_id, $transcript->stable_id, "MANE transcript has same stable ID as the original transcript");
is($mane_transcript->refseq, "NM_030815.3", "MANE transcript matches RefSeq accession");
is($mane_transcript->type, "MANE_Select", "MANE transcript belongs to MANE_Select");
my $stable_id2 = "ENST00000252021";
my $transcript2 = $transcript_adaptor->fetch_by_stable_id($stable_id2);
print "Check transcript is not part of MANE\n";
is($transcript2->is_mane, 0, "$stable_id2 is not part of MANE");
my $mane_transcript2 = $transcript2->mane_transcript();
is($mane_transcript2, undef, "No result when the transcript is not part of MANE");
done_testing();
......@@ -22,3 +22,4 @@
22 mirna_arm miRNA arm Hairpin arm from which this miRNA has come from
23 _stop_codon_rt Stop Codon Readthrough \N
24 appris APPRIS \N
535 MANE_Select MANE Select v0.92 MANE Select (v0.92) is the preliminary release (phase 7) of the MANE Select data set. The Matched Annotation from NCBI and EMBL-EBI project (MANE) is a collaboration between Ensembl-GENCODE and RefSeq to select a default transcript per human protein coding locus that is representative of biology, well-supported, expressed and conserved. This transcript set matches GRCh38 and is 100% identical between RefSeq and Ensembl-GENCODE for 5' UTR, CDS, splicing and 3' UTR.
21716 21 ENSG_PARENT_TRANSCRIPT
21738 24 principal1
21719 535 NM_030815.3
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