EnsEMBL/Utils/Converter/bio_ens_seqFeature.pm untested

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