EnsEMBL/Utils/Converter/bio_ens_seqFeature.pm untested

filter: Statementstmt 0.0% 0 / 55 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 15 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 98 CC 11 SCAR 44.6
CC
11
Cov
0%
_convert_single
132.0
BEGIN
2.0
BEGIN
2.0
CRAP 86.1
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_seqFeature
38  
39 =head1 SYNOPISIS
40  
41 Please read Bio::EnsEMBL::Utils::Converter
42  
43 =head1 DESCRIPTION
44  
45 =head1 METHODS
46  
47 =cut
48  
49 package Bio::EnsEMBL::Utils::Converter::bio_ens_seqFeature;
50 $Bio::EnsEMBL::Utils::Converter::bio_ens_seqFeature::VERSION = '114.0.0_50'; # TRIAL
51 $Bio::EnsEMBL::Utils::Converter::bio_ens_seqFeature::VERSION = '114.0.050';
52 use strict;
53 use vars qw(@ISA);
54 use Bio::EnsEMBL::SeqFeature;
55 use Bio::EnsEMBL::SimpleFeature;
56 use Bio::EnsEMBL::Exon;
57 use Bio::EnsEMBL::Utils::Converter::bio_ens;
58 @ISA = qw(Bio::EnsEMBL::Utils::Converter::bio_ens);
59  
60 sub _convert_single {
61 my ($self, $in) = @_;
62
63 unless($in && defined($in) && $in->isa('Bio::SeqFeature::Generic')){
64 $self->throw("a Bio::SeqFeature::Generic object needed");
65 }
66
67 my $seqFeature = $in;
68 my $seq_id = $seqFeature->seq_id;
69 unless(defined($seq_id) && $seq_id){
70 $self->warn("No seq_id value. EnsEMBL SeqFeature will validate it");
71 $seq_id = 'Unknown';
72 }
73
74 # Debated issue here. There are p_value and percent_id in EnsEMBL API and DB
75 # schema, but not in bioperl. If in bioperl there are tags called p_value or
76 # percent_id, then the values are passed, otherwise set the default 1.
77 #
78 # the problem arise when I try to converter the seqfeature for tmhmm to
79 # EnsEMBL seqFeature.
80 # -- Juguang, 11 July '03
81 my $score = $in->score || 0;
82 my $percent_id;
83 if($in->has_tag('percent_id')){
84 ($percent_id) = $in->get_tag_values('percent_id');
85 }else{
86 $percent_id ||= 0;
87 }
88 my $p_value;
89 if($in->has_tag('p_value')){
90 ($p_value) = $in->get_tag_values('p_value');
91 }elsif($in->has_tag('evalue')){
92 ($p_value) = $in->get_tag_values('evalue');
93 }else{
94 $p_value ||= 1;
95 }
96 my $ens_seqFeature;
97 my %args = (
98 -start => $in->start,
99 -end => $in->end,
100 -strand => $in->strand,
101 -score => $score,
102 -analysis => $self->analysis,
103 -source_tag => $in->source_tag,
104 -seqname => $seq_id,
105 -percent_id => $percent_id,
106 -p_value => $p_value
107 );
108  
109 my $output_module = $self->out;
110
111 if($output_module eq 'Bio::EnsEMBL::SeqFeature'){
112
113 $ens_seqFeature = new Bio::EnsEMBL::SeqFeature(%args);
114 }elsif($self->out eq 'Bio::EnsEMBL::SimpleFeature'){
115 $ens_seqFeature = new Bio::EnsEMBL::SimpleFeature(%args);
116 # The field that there is in SimpleFeature, but not in SeqFeature.
117 $ens_seqFeature->display_label('__NONE__');
118 }elsif($self->out eq 'Bio::EnsEMBL::Exon'){
119 $ens_seqFeature = Bio::EnsEMBL::Exon->new_fast(
120 $self->contig, $seqFeature->start, $seqFeature->end,
121 $seqFeature->strand);
122 }elsif($self->out eq 'Bio::EnsEMBL::ProteinFeature'){
123 my $seq_id2 = $self->analysis->logic_name;
124 unless(defined $self->translation_id){
125 $self->throw('translation_id unset, in ProteinFeature conversion');
126 }
127 $args{'-seqname'} = $self->translation_id;
128 $ens_seqFeature = Bio::EnsEMBL::ProteinFeature->new(
129 -feature1 => Bio::EnsEMBL::SeqFeature->new(%args),
130 -feature2 => Bio::EnsEMBL::SeqFeature->new(
131 -start => 0,
132 -end => 0,
133 -seqname => $seq_id2
134 )
135 );
136 }else{
137 $self->throw("[$output_module] as -out, not supported");
138 }
139
140 $ens_seqFeature->attach_seq($self->contig);
141 return $ens_seqFeature;
142 }
143  
144 1;