Commit 860bb418 authored by Kevin Howe's avatar Kevin Howe
Browse files

- Added transform method to BaseAlignFeature so that if a simple transform

fails, the feature is reconstructed from transforms of the unagpped
components of the feature
- Added some checks to Transcript/Exon transform that warns and skips
supporting features that do not transform successfully
parent 9e7b0702
......@@ -315,6 +315,67 @@ sub reverse_complement {
=head2 transform
Arg 1 : String $coordinate_system_name
Arg [2] : String $coordinate_system_version
Example : $feature = $feature->transform('contig');
$feature = $feature->transform('chromosome', 'NCBI33');
Description: Moves this AlignFeature to the given coordinate system.
If the feature cannot be transformed to the destination
coordinate system undef is returned instead.
Returntype : Bio::EnsEMBL::BaseAlignFeature;
Exceptions : wrong parameters
Caller : general
Status : Medium Risk
: deprecation needs to be removed at some time
=cut
sub transform {
my $self = shift;
# catch for old style transform calls
if( ref $_[0] eq 'HASH') {
deprecate("Calling transform with a hashref is deprecate.\n" .
'Use $feat->transfer($slice) or ' .
'$feat->transform("coordsysname") instead.');
my (undef, $new_feat) = each(%{$_[0]});
return $self->transfer($new_feat->slice);
}
my $new_feature = $self->SUPER::transform( @_ );
if( ! defined $new_feature or
$new_feature->length != $self->length) {
my @segments = $self->project( @_ );
return undef if( ! @segments );
my @ungapped;
foreach my $f ($self->ungapped_features) {
$f = $f->transform( @_ );
if (defined $f) {
push @ungapped, $f;
} else {
warning("Failed to transform alignment feature; " .
"ungapped component could not be transformed");
return undef;
}
}
eval {
$new_feature = $self->new(-features => \@ungapped );
};
if ($@) {
warning($@);
return undef;
}
}
return $new_feature;
}
=head2 _parse_cigar
Args : none
......
......@@ -437,7 +437,9 @@ sub transform {
my @new_features;
for my $old_feature ( @{$self->{'_supporting_evidence'}} ) {
my $new_feature = $old_feature->transform( @_ );
push( @new_features, $new_feature );
if (defined $new_feature) {
push( @new_features, $new_feature );
}
}
$new_exon->{'_supporting_evidence'} = \@new_features;
}
......
......@@ -1318,7 +1318,7 @@ sub get_all_translateable_Exons {
# Adjust to translation start if this is the start exon
if ($ex == $start_exon ) {
if ($t_start < 1 or $t_start > $length) {
warn("WARN: Translation start '$t_start' is outside exon $ex length=$length");
warning("WARN: Translation start '$t_start' is outside exon $ex length=$length");
return [];
}
$adjust_start = $t_start - 1;
......@@ -1802,7 +1802,7 @@ sub transform {
}
if( $order_broken && !$ignore_order ) {
warn( "Order of exons broken in transform of ".$self->dbID() );
warning( "Order of exons broken in transform of ".$self->dbID() );
return undef;
}
......@@ -1834,7 +1834,9 @@ sub transform {
my @new_features;
for my $old_feature ( @{$self->{'_supporting_evidence'}} ) {
my $new_feature = $old_feature->transform( @_ );
push( @new_features, $new_feature );
if (defined $new_feature) {
push @new_features, $new_feature;
}
}
$new_transcript->{'_supporting_evidence'} = \@new_features;
}
......
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