EnsEMBL/Utils/Converter/bio_ens_predictionGene.pm untested

filter: Statementstmt 0.0% 0 / 49 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 78 CC 5 SCAR 19.5
CC
5
Cov
0%
_convert_single
12.0
contig
12.0
_initialize
2.0
CRAP 7.0
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_predictionGene
38  
39 =head1 SYNOPISIS
40  
41 =head1 DESCRIPTION
42  
43 =head1 METHODS
44  
45 =cut
46  
47 package Bio::EnsEMBL::Utils::Converter::bio_ens_predictionGene;
48 $Bio::EnsEMBL::Utils::Converter::bio_ens_predictionGene::VERSION = '114.0.0';
49 use strict;
50 use vars qw(@ISA);
51 use Bio::EnsEMBL::Utils::Converter;
52 use Bio::EnsEMBL::PredictionTranscript;
53 use Bio::EnsEMBL::Utils::Converter::bio_ens;
54 @ISA = qw(Bio::EnsEMBL::Utils::Converter::bio_ens);
55  
56 sub _initialize {
57 my ($self, @args) = @_;
58  
59 $self->{_predictionExonConverter} = new Bio::EnsEMBL::Utils::Converter(
60 -in => 'Bio::SeqFeature::Gene::Exon',
61 -out => 'Bio::EnsEMBL::Exon',
62 );
63 $self->SUPER::_initialize(@args);
64
65 $self->{_predictionExonConverter}->contig($self->contig);
66 $self->{_predictionExonConverter}->analysis($self->analysis);
67 }
68  
69 sub _convert_single {
70 my ($self, $input) = @_;
71
72 $self->throw("one argument needed") unless($input and defined($input));
73 $self->throw("a Bio::Tools::Prediction::Gene object needed")
74 unless(ref($input) && $input->isa('Bio::Tools::Prediction::Gene'));
75  
76 my $output = Bio::EnsEMBL::PredictionTranscript->new;
77 $output->analysis($self->analysis);
78  
79 my @exons = sort {$a->start <=> $b->start} $input->exons;
80  
81 # Not sure on the correctivity of phase calculation.
82 my $previous_end_phase = -1;
83 foreach(@exons){
84 my $length = $_->length;
85 my $frame = $_->frame;
86 my $phase = ($previous_end_phase+1) %3;
87 my $end_phase = ($length-$frame) %1;
88 $previous_end_phase = $end_phase;
89 $_->add_tag_value("phase", $phase);
90 $_->add_tag_value("end_phase", $end_phase);
91 }
92  
93 my @ens_exons = @{$self->{_predictionExonConverter}->convert(\@exons)};
94  
95 $output->add_Exon($_) foreach(@ens_exons);
96  
97 return $output;
98  
99 }
100  
101 =head2 contig
102 Title : contig
103 Usage : $self->contig
104 Function: get and set for contig
105 Return : L<Bio::EnsEMBL::RawContig>
106 Args : L<Bio::EnsEMBL::RawContig>
107 =cut
108  
109 sub contig {
110 my ($self, $arg) = @_;
111 if(defined($arg)){
112 $self->throws("A Bio::EnsEMBL::RawContig object expected.") unless(defined $arg);
113 $self->{_contig} = $arg;
114 # assign it to the sub converter which converts exons
115 $self->{_predictionExonConverter}->contig($arg);
116 }
117 return $self->{_contig};
118 }
119 1;