EnsEMBL/Utils/Converter/bio_ens_exon.pm untested

filter: Statementstmt 0.0% 0 / 56 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 85 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';
49 use strict;
50 use vars qw(@ISA %GTF_ENS_PHASE);
51 use Bio::EnsEMBL::Utils::Converter;
52 use Bio::EnsEMBL::Exon;
53 use Bio::EnsEMBL::DnaPepAlignFeature;
54 use Bio::EnsEMBL::Utils::Converter::bio_ens;
55 @ISA = qw(Bio::EnsEMBL::Utils::Converter::bio_ens);
56  
57 BEGIN {
58 %GTF_ENS_PHASE = (
59 0 => 0,
60 1 => 2,
61 2 => 1,
62 '.' => -1
63 );
64 }
65  
66 sub _initialize {
67 my ($self, @args) = @_;
68 $self->SUPER::_initialize(@args);
69  
70 $self->{_bio_ens_seqFeature} = new Bio::EnsEMBL::Utils::Converter (
71 -in => 'Bio::SeqFeature::Generic',
72 -out => 'Bio::EnsEMBL::SeqFeature',
73 );
74  
75 $self->{_bio_ens_featurePair} = new Bio::EnsEMBL::Utils::Converter (
76 -in => 'Bio::SeqFeature::FeaturePair',
77 -out => 'Bio::EnsEMBL::FeaturePair'
78 );
79 }
80  
81 sub _attach_supporting_feature {
82 my ($self, $exon, $ens_exon) = @_;
83 unless($exon->has_tag('supporting_feature')){
84 return;
85 }
86 my ($sf) = $exon->each_tag_value('supporting_feature');
87 unless(defined $sf){
88 $self->warn("no supporting feature is attached in exon");
89 return;
90 }
91 # $self->{_bio_ens_seqFeature}->contig($self->contig);
92 $self->{_bio_ens_seqFeature}->analysis($self->analysis);
93 my $ens_f1 = $self->{_bio_ens_seqFeature}->_convert_single($sf->feature1);
94 my $ens_f2 = $self->{_bio_ens_seqFeature}->_convert_single($sf->feature2);
95 $self->{_bio_ens_featurePair}->contig($self->contig);
96 $self->{_bio_ens_featurePair}->analysis($self->analysis);
97 my $ens_sf = $self->{_bio_ens_featurePair}->_convert_single($sf);
98 my @align_feautre_args = (
99 -feature1 => $ens_f1,
100 -feature2 => $ens_f2,
101 -features => [$ens_sf]
102 );
103
104 my $ens_supporting_feature =
105 Bio::EnsEMBL::DnaPepAlignFeature->new(@align_feautre_args);
106
107 $ens_exon->add_supporting_features($ens_supporting_feature);
108 }
109  
110 sub _convert_single {
111 my ($self, $arg) = @_;
112 unless($arg && $arg->isa('Bio::SeqFeature::Gene::Exon')){
113 $self->throw("a Bio::SeqFeature::Gene::Exon object needed");
114 }
115 my $exon = $arg;
116 my $ens_exon = Bio::EnsEMBL::Exon->new_fast(
117 $self->contig, $exon->start, $exon->end, $exon->strand);
118  
119 my ($phase) = $exon->each_tag_value('phase');
120 $ens_exon->phase($GTF_ENS_PHASE{$phase});
121 my $ens_end_phase = 3 - ($exon->length - $phase) % 3;
122 $ens_end_phase = 0 if $ens_end_phase == 3;
123 $ens_exon->end_phase($ens_end_phase);
124 if($self->contig->isa('Bio::EnsEMBL::RawContig')){
125 $ens_exon->sticky_rank(1);
126 }
127 $self->_attach_supporting_feature($exon, $ens_exon);
128 return $ens_exon;
129 }
130  
131  
132 1;