EnsEMBL/Utils/Converter/bio_ens_exon.pm untested

filter: Statementstmt 0.0% 0 / 57 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 84 CC 6 SCAR 21.7
CC
6
Cov
0%
_convert_single
20.0
_attach_supporting_feature
12.0
BEGIN
2.0
CRAP 8.8
1 =head1 LICENSE
2  
3 See the NOTICE file distributed with this work for additional information
4 regarding copyright ownership.
5  
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9  
10 http://www.apache.org/licenses/LICENSE-2.0
11  
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17  
18 =cut
19  
20  
21 =head1 CONTACT
22  
23 Please email comments or questions to the public Ensembl
24 developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
25  
26 Questions may also be sent to the Ensembl help desk at
27 <http://www.ensembl.org/Help/Contact>.
28  
29 =head1 AUTHOR
30  
31 Juguang Xiao <juguang@tll.org.sg>
32  
33 =cut
34  
35 =head1 NAME
36  
37 Bio::EnsEMBL::Utils::Converter::bio_ens_exon
38  
39 =head1 SYNOPISIS
40  
41 =head1 DESCRIPTION
42  
43 =head1 METHODS
44  
45 =cut
46  
47 package Bio::EnsEMBL::Utils::Converter::bio_ens_exon;
48 $Bio::EnsEMBL::Utils::Converter::bio_ens_exon::VERSION = '114.0.0_50'; # TRIAL
49 $Bio::EnsEMBL::Utils::Converter::bio_ens_exon::VERSION = '114.0.050';
50 use strict;
51 use vars qw(@ISA %GTF_ENS_PHASE);
52 use Bio::EnsEMBL::Utils::Converter;
53 use Bio::EnsEMBL::Exon;
54 use Bio::EnsEMBL::DnaPepAlignFeature;
55 use Bio::EnsEMBL::Utils::Converter::bio_ens;
56 @ISA = qw(Bio::EnsEMBL::Utils::Converter::bio_ens);
57  
58 BEGIN {
59 %GTF_ENS_PHASE = (
60 0 => 0,
61 1 => 2,
62 2 => 1,
63 '.' => -1
64 );
65 }
66  
67 sub _initialize {
68 my ($self, @args) = @_;
69 $self->SUPER::_initialize(@args);
70  
71 $self->{_bio_ens_seqFeature} = new Bio::EnsEMBL::Utils::Converter (
72 -in => 'Bio::SeqFeature::Generic',
73 -out => 'Bio::EnsEMBL::SeqFeature',
74 );
75  
76 $self->{_bio_ens_featurePair} = new Bio::EnsEMBL::Utils::Converter (
77 -in => 'Bio::SeqFeature::FeaturePair',
78 -out => 'Bio::EnsEMBL::FeaturePair'
79 );
80 }
81  
82 sub _attach_supporting_feature {
83 my ($self, $exon, $ens_exon) = @_;
84 unless($exon->has_tag('supporting_feature')){
85 return;
86 }
87 my ($sf) = $exon->each_tag_value('supporting_feature');
88 unless(defined $sf){
89 $self->warn("no supporting feature is attached in exon");
90 return;
91 }
92 # $self->{_bio_ens_seqFeature}->contig($self->contig);
93 $self->{_bio_ens_seqFeature}->analysis($self->analysis);
94 my $ens_f1 = $self->{_bio_ens_seqFeature}->_convert_single($sf->feature1);
95 my $ens_f2 = $self->{_bio_ens_seqFeature}->_convert_single($sf->feature2);
96 $self->{_bio_ens_featurePair}->contig($self->contig);
97 $self->{_bio_ens_featurePair}->analysis($self->analysis);
98 my $ens_sf = $self->{_bio_ens_featurePair}->_convert_single($sf);
99 my @align_feautre_args = (
100 -feature1 => $ens_f1,
101 -feature2 => $ens_f2,
102 -features => [$ens_sf]
103 );
104
105 my $ens_supporting_feature =
106 Bio::EnsEMBL::DnaPepAlignFeature->new(@align_feautre_args);
107
108 $ens_exon->add_supporting_features($ens_supporting_feature);
109 }
110  
111 sub _convert_single {
112 my ($self, $arg) = @_;
113 unless($arg && $arg->isa('Bio::SeqFeature::Gene::Exon')){
114 $self->throw("a Bio::SeqFeature::Gene::Exon object needed");
115 }
116 my $exon = $arg;
117 my $ens_exon = Bio::EnsEMBL::Exon->new_fast(
118 $self->contig, $exon->start, $exon->end, $exon->strand);
119  
120 my ($phase) = $exon->each_tag_value('phase');
121 $ens_exon->phase($GTF_ENS_PHASE{$phase});
122 my $ens_end_phase = 3 - ($exon->length - $phase) % 3;
123 $ens_end_phase = 0 if $ens_end_phase == 3;
124 $ens_exon->end_phase($ens_end_phase);
125 if($self->contig->isa('Bio::EnsEMBL::RawContig')){
126 $ens_exon->sticky_rank(1);
127 }
128 $self->_attach_supporting_feature($exon, $ens_exon);
129 return $ens_exon;
130 }
131  
132  
133 1;