Skip to content
Snippets Groups Projects
Commit 3153564f authored by Graham McVicker's avatar Graham McVicker
Browse files

changed selenocystein implementation to use SeqEdits and be more consistant...

changed selenocystein implementation to use SeqEdits and be more consistant with Transcript implementatin
parent 861c67a7
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ transcript ...@@ -16,7 +16,7 @@ transcript
=head1 DESCRIPTION =head1 DESCRIPTION
A transcript''s translation defines the CDS and UTR regions of the transcript A Translation object defines the CDS and UTR regions of a Transcript
through the use of start_Exon/end_Exon, and start/end attributes. through the use of start_Exon/end_Exon, and start/end attributes.
=head1 CONTACT =head1 CONTACT
...@@ -40,6 +40,34 @@ use Bio::EnsEMBL::Storable; ...@@ -40,6 +40,34 @@ use Bio::EnsEMBL::Storable;
@ISA = qw(Bio::EnsEMBL::Storable); @ISA = qw(Bio::EnsEMBL::Storable);
=head2 new
Arg [-START_EXON] : The Exon object in which the translation (CDS) starts
Arg [-END_EXON] : The Exon object in which the translation (CDS) ends
Arg [-SEQ_START] : The offset in the start_Exon indicating the start
position of the CDS.
Arg [-SEQ_END] : The offset in the end_Exon indicating the end
position of the CDS.
Arg [-STABLE_ID] : The stable identifier for this Translation
Arg [-VERSION] : The version of the stable identifier
Arg [-DBID] : The internal identifier of this Translation
Arg [-ADAPTOR] : The TranslationAdaptor for this Translation
Arg [-SEQ] : Manually sets the peptide sequence of this translation.
May be useful if this translation is not stored in
a database.
Example : my $tl = Bio::EnsEMBL::Translation->new
(-START_EXON => $ex1,
-END_EXON => $ex2,
-SEQ_START => 98,
-SEQ_END => 39);
Description: Constructor. Creates a new Translation object
Returntype : Bio::EnsEMBL::Translation
Exceptions : none
Caller : general
=cut
sub new { sub new {
my $caller = shift; my $caller = shift;
...@@ -507,8 +535,8 @@ sub seq { ...@@ -507,8 +535,8 @@ sub seq {
Arg [1] : optional string $attrib_code Arg [1] : optional string $attrib_code
The code of the attribute type to retrieve values for. The code of the attribute type to retrieve values for.
Example : ($selenocystein) = @{$translation->get_all_Attributes('_selenocystein')}; Example : ($sc_attr) = @{$tl->get_all_Attributes('_selenocystein')};
@translation_attributes = @{$translation->get_all_Attributes()}; @tl_attributes = @{$translation->get_all_Attributes()};
Description: Gets a list of Attributes of this translation. Description: Gets a list of Attributes of this translation.
Optionally just get Attrubutes for given code. Optionally just get Attrubutes for given code.
Recognized attribute "_selenocystein" Recognized attribute "_selenocystein"
...@@ -529,12 +557,12 @@ sub get_all_Attributes { ...@@ -529,12 +557,12 @@ sub get_all_Attributes {
return []; return [];
} }
my $attribute_adaptor = $self->adaptor->db->get_AttributeAdaptor(); my $aa = $self->adaptor->db->get_AttributeAdaptor();
$self->{'attributes'} = $attribute_adaptor->fetch_all_by_Translation( $self ); $self->{'attributes'} = $aa->fetch_all_by_Translation( $self );
} }
if( defined $attrib_code ) { if( defined $attrib_code ) {
my @results = grep { uc($_->code()) eq uc($attrib_code) } my @results = grep { uc($_->code()) eq uc($attrib_code) }
@{$self->{'attributes'}}; @{$self->{'attributes'}};
return \@results; return \@results;
} else { } else {
...@@ -548,14 +576,12 @@ sub get_all_Attributes { ...@@ -548,14 +576,12 @@ sub get_all_Attributes {
Arg [1...] : Bio::EnsEMBL::Attribute $attribute Arg [1...] : Bio::EnsEMBL::Attribute $attribute
You can have more Attributes as arguments, all will be added. You can have more Attributes as arguments, all will be added.
Example : $translation->add_Attributes($selenocystein_attribute); Example : $translation->add_Attributes($selenocystein_attribute);
Description: Adds an Attribute to the Translation. Usefull to do _selenocystein. Description: Adds an Attribute to the Translation. Usefull to
If you add an attribute before you retrieve any from database, lazy load do _selenocystein.
will be disabled. If you add an attribute before you retrieve any from database,
Current API attributes are lazy load will be disabled.
_selenocystein num
which gives the number of the selenocystein aminoacid (U)
Returntype : none Returntype : none
Exceptions : Exceptions : throw on incorrect arguments
Caller : general Caller : general
=cut =cut
...@@ -570,56 +596,48 @@ sub add_Attributes { ...@@ -570,56 +596,48 @@ sub add_Attributes {
for my $attrib ( @attribs ) { for my $attrib ( @attribs ) {
if( ! $attrib->isa( "Bio::EnsEMBL::Attribute" )) { if( ! $attrib->isa( "Bio::EnsEMBL::Attribute" )) {
throw( "Argument to add_Attribute has to be an Bio::EnsEMBL::Attribute" ); throw( "Argument to add_Attribute must be a Bio::EnsEMBL::Attribute" );
} }
push( @{$self->{'attributes'}}, $attrib ); push( @{$self->{'attributes'}}, $attrib );
} }
} }
=head2 get_all_SeqEdits
=head2 add_selenocystein_position Arg [1] : none
Example : my @seqeds = @{$transcript->get_all_SeqEdits()};
Arg [1...] : int $num Description: Retrieves all post transcriptional sequence modifications for
The amino acid that should be a selenocystein. You can provide more this transcript.
than one. Returntype : Bio::EnsEMBL::SeqEdit
Example : $translation->add_selenocystein_position( 37 ); Exceptions : none
Description: Will create an Attribute that is attached to this Translation that causes Caller : spliced_seq()
the peptide sequence derived from it to have a U (selenocystein) in
the given position(s).
Returntype : none
Exceptions :
Caller : general
=cut =cut
sub get_all_SeqEdits {
sub add_selenocystein_position {
my $self = shift; my $self = shift;
my @args = @_;
for my $arg ( @args ) {
my $attrib = Bio::EnsEMBL::Attribute->new
(
-code => "_selenocystein",
-value => $arg,
-name => "Selenocystein position",
-description => "Position of selenocystein in peptide sequence"
);
$self->add_Attributes( $attrib );
}
}
my @seqeds;
my $attribs = $self->get_all_Attributes('_selenocystein');
# convert attributes to SeqEdit objects
foreach my $a (@$attribs) {
push @seqeds, Bio::EnsEMBL::SeqEdit->new(-ATTRIB => $a);
}
return \@seqeds;
}
=head2 modify_translation =head2 modify_translation
Arg 1 : Bio::Seq $peptide Arg 1 : Bio::Seq $peptide
Example : Example : my $seq = Bio::Seq->new(-SEQ => $dna)->translate();
Description: Applies selenocysteins to the Bio::Seq peptide thats passed in $translation->modify_translation($seq);
Description: Applies sequence edits such as selenocysteins to the Bio::Seq
peptide thats passed in
Returntype : Bio::Seq Returntype : Bio::Seq
Exceptions : Exceptions :
Caller : Bio::EnsEMBL::Transcript->translate Caller : Bio::EnsEMBL::Transcript->translate
=cut =cut
...@@ -627,28 +645,23 @@ sub add_selenocystein_position { ...@@ -627,28 +645,23 @@ sub add_selenocystein_position {
sub modify_translation { sub modify_translation {
my ($self, $seq) = @_; my ($self, $seq) = @_;
my $attribs = $self->get_all_Attributes( "_selenocystein" ); my @seqeds = @{$self->get_all_SeqEdits()};
if( ! @$attribs ) { # sort in reverse order to avoid complication of adjusting downstream edits
return $seq; @seqeds = sort {$b <=> $a} @seqeds;
}
# into bioperl (sigh)
my $peptide = $seq->seq();
for my $attrib ( @$attribs ) { # apply all edits
my $pos = $attrib->value(); my $peptide = $seq->seq();
substr( $peptide, $pos-1, 1 ) = "U"; foreach my $se (@seqeds) {
$se->apply_edit(\$peptide);
} }
$seq->seq($peptide);
$seq->seq( $peptide );
return $seq; return $seq;
} }
=head1 DEPRECATED METHODS =head1 DEPRECATED METHODS
=cut =cut
......
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