3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
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
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.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
33 Sequence alignment hits were previously stored within the core database
34 as ungapped alignments. This imposed 2 major constraints on alignments:
36 a) alignments
for a single hit record would require multiple rows in
38 b) it was not possible to accurately retrieve the exact original alignment.
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).
44 In the cigar line format alignments are sotred as follows:
50 An example of an alignment
for a hypthetical protein match is shown
54 Query: 42 PGPAGLP----GSVGLQGPRGLRGPLP-GPLGPPL...
56 Sbjct: 1672 PGTP*TPLVPLGPWVPLGPSSPR--LPSGPLGPTD...
58 protein_align_feature table as the following cigar line:
64 package Bio::EnsEMBL::Utils::Converter::bio_ens_hit;
77 my ($self, @args) = @_;
78 $self->SUPER::_initialize(@args);
80 # After super initialized, analysis and contig are ready.
82 -in =>
'Bio::SeqFeature::Generic',
83 -out =>
'Bio::EnsEMBL::SeqFeature',
84 -analysis => $self->analysis,
85 -contig => $self->contig
87 $self->_bio_ens_seqFeature_converter($bio_ens_seqFeature_converter);
92 my ($self, $input) = @_;
97 if($in =~ /Bio::Search::Hit::GenericHit/){
98 return $self->_convert_single_hit($input);
99 }elsif($in =~ /Bio::Search::HSP::GenericHSP/){
100 return $self->_convert_single_hsp($input);
102 $self->throw(
"[$in]->[$out], not implemented");
106 sub _convert_single_hit {
111 sub _convert_single_hsp {
112 my ($self, $hsp) = @_;
114 unless(ref($hsp) && $hsp->isa(
'Bio::Search::HSP::GenericHSP')){
115 $self->throw(
"a GenericHSP object needed");
118 my $bio_ens_seqFeature_converter = $self->_bio_ens_seqFeature_converter;
119 my $ens_feature1 = $bio_ens_seqFeature_converter->_convert_single(
121 my $ens_feature2 = $bio_ens_seqFeature_converter->_convert_single(
124 $ens_feature1->p_value($hsp->evalue);
125 $ens_feature1->score($hsp->score);
126 $ens_feature1->percent_id($hsp->percent_identity);
127 $ens_feature2->p_value($hsp->evalue);
128 $ens_feature2->score($hsp->score);
129 $ens_feature2->percent_id($hsp->percent_identity);
131 my $cigar_string = $hsp->cigar_string;
133 -feature1 => $ens_feature1,
134 -feature2 => $ens_feature2,
135 -cigar_string => $cigar_string
138 my $contig = $self->contig;
139 # choose the AlignFeature based on the blast program
140 my $program = $hsp->algorithm;
142 $self->throw(
"HSP does not have algorithm value") unless(defined($program));
145 if($program =~ /blastn/i){
147 $align_feature->attach_seq($contig);
148 }elsif($program =~ /blastx/i){
150 $align_feature->attach_seq($contig);
152 $self->throw(
"$program is not supported yet");
155 return $align_feature;
158 # an internal getter/setter for a converter used for seq feature conversion.
160 sub _bio_ens_seqFeature_converter {
161 my ($self, $arg) = @_;
163 $self->{_bio_ens_seqFeature_converter} = $arg;
165 return $self->{_bio_ens_seqFeature_converter};