EnsEMBL/Utils/Converter/bio_ens_hit.pm untested

filter: Statementstmt 0.0% 0 / 64 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 98 CC 8 SCAR 24.3
CC
8
Cov
0%
_convert_single_hsp
30.0
_convert_single
12.0
_bio_ens_seqFeature_converter
6.0
CRAP 11.4
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 =cut
30  
31 =head1 DESCRIPTION
32  
33 Sequence alignment hits were previously stored within the core database
34 as ungapped alignments. This imposed 2 major constraints on alignments:
35  
36 a) alignments for a single hit record would require multiple rows in
37 the database, and
38 b) it was not possible to accurately retrieve the exact original alignment.
39  
40 Therefore, in the new branch sequence alignments are now stored as
41 ungapped alignments in the cigar line format (where CIGAR stands for
42 Concise Idiosyncratic Gapped Alignment Report).
43  
44 In the cigar line format alignments are sotred as follows:
45  
46 M: Match
47 D: Deletino
48 I: Insertion
49  
50 An example of an alignment for a hypthetical protein match is shown
51 below:
52  
53  
54 Query: 42 PGPAGLP----GSVGLQGPRGLRGPLP-GPLGPPL...
55 PG P G GP R PLGP
56 Sbjct: 1672 PGTP*TPLVPLGPWVPLGPSSPR--LPSGPLGPTD...
57  
58 protein_align_feature table as the following cigar line:
59  
60 7M4D12M2I2MD7M
61  
62 =cut
63  
64 package Bio::EnsEMBL::Utils::Converter::bio_ens_hit;
65 $Bio::EnsEMBL::Utils::Converter::bio_ens_hit::VERSION = '114.0.0_50'; # TRIAL
66 $Bio::EnsEMBL::Utils::Converter::bio_ens_hit::VERSION = '114.0.050';
67 use strict;
68 use vars qw(@ISA);
69 use Bio::EnsEMBL::Utils::Converter::bio_ens;
70 use Bio::EnsEMBL::DnaDnaAlignFeature;
71 use Bio::EnsEMBL::DnaPepAlignFeature;
72 use Bio::EnsEMBL::PepDnaAlignFeature;
73 use Bio::EnsEMBL::ProteinFeature;
74  
75 @ISA = qw(Bio::EnsEMBL::Utils::Converter::bio_ens);
76  
77 sub _initialize {
78 my ($self, @args) = @_;
79 $self->SUPER::_initialize(@args);
80  
81 # After super initialized, analysis and contig are ready.
82 my $bio_ens_seqFeature_converter = new Bio::EnsEMBL::Utils::Converter(
83 -in => 'Bio::SeqFeature::Generic',
84 -out => 'Bio::EnsEMBL::SeqFeature',
85 -analysis => $self->analysis,
86 -contig => $self->contig
87 );
88 $self->_bio_ens_seqFeature_converter($bio_ens_seqFeature_converter);
89  
90 }
91  
92 sub _convert_single {
93 my ($self, $input) = @_;
94
95 my $in = $self->in;
96 my $out = $self->out;
97
98 if($in =~ /Bio::Search::Hit::GenericHit/){
99 return $self->_convert_single_hit($input);
100 }elsif($in =~ /Bio::Search::HSP::GenericHSP/){
101 return $self->_convert_single_hsp($input);
102 }else{
103 $self->throw("[$in]->[$out], not implemented");
104 }
105 }
106  
107 sub _convert_single_hit {
108  
109  
110 }
111  
112 sub _convert_single_hsp {
113 my ($self, $hsp) = @_;
114  
115 unless(ref($hsp) && $hsp->isa('Bio::Search::HSP::GenericHSP')){
116 $self->throw("a GenericHSP object needed");
117 }
118  
119 my $bio_ens_seqFeature_converter = $self->_bio_ens_seqFeature_converter;
120 my $ens_feature1 = $bio_ens_seqFeature_converter->_convert_single(
121 $hsp->feature1);
122 my $ens_feature2 = $bio_ens_seqFeature_converter->_convert_single(
123 $hsp->feature2);
124  
125 $ens_feature1->p_value($hsp->evalue);
126 $ens_feature1->score($hsp->score);
127 $ens_feature1->percent_id($hsp->percent_identity);
128 $ens_feature2->p_value($hsp->evalue);
129 $ens_feature2->score($hsp->score);
130 $ens_feature2->percent_id($hsp->percent_identity);
131
132 my $cigar_string = $hsp->cigar_string;
133 my @args = (
134 -feature1 => $ens_feature1,
135 -feature2 => $ens_feature2,
136 -cigar_string => $cigar_string
137 );
138  
139 my $contig = $self->contig;
140 # choose the AlignFeature based on the blast program
141 my $program = $hsp->algorithm;
142  
143 $self->throw("HSP does not have algorithm value") unless(defined($program));
144 my $align_feature;
145
146 if($program =~ /blastn/i){
147 $align_feature = new Bio::EnsEMBL::DnaDnaAlignFeature(@args);
148 $align_feature->attach_seq($contig);
149 }elsif($program =~ /blastx/i){
150 $align_feature = new Bio::EnsEMBL::DnaPepAlignFeature(@args);
151 $align_feature->attach_seq($contig);
152 }else{
153 $self->throw("$program is not supported yet");
154 }
155
156 return $align_feature;
157 }
158  
159 # an internal getter/setter for a converter used for seq feature conversion.
160  
161 sub _bio_ens_seqFeature_converter {
162 my ($self, $arg) = @_;
163 if(defined $arg){
164 $self->{_bio_ens_seqFeature_converter} = $arg;
165 }
166 return $self->{_bio_ens_seqFeature_converter};
167 }
168  
169 1;