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
32 package Bio::EnsEMBL::Utils::Converter::bio_ens_hsp;
42 my ($self, @args) = @_;
43 $self->SUPER::_initialize(@args);
45 # After super initialized, analysis and contig are ready.
47 -in =>
'Bio::SeqFeature::Generic',
48 -out =>
'Bio::EnsEMBL::SeqFeature',
49 -analysis => $self->analysis,
50 -contig => $self->contig
52 $self->_bio_ens_seqFeature_converter($bio_ens_seqFeature_converter);
57 my ($self, $hsp) = @_;
59 unless(ref($hsp) && $hsp->isa(
'Bio::Search::HSP::GenericHSP')){
60 $self->throw(
"a GenericHSP object needed");
67 return $self->_convert_single_to_proteinFeature($hsp);
68 }elsif($out =~/^
Bio::EnsEMBL::(DnaDna|DnaPep|PepDna)AlignFeature/){
69 return $self->_convert_single_to_alignFeature($hsp);
71 $self->throw(
"[$in]->[$out], not implemented");
75 sub _convert_single_to_featurePair {
76 my ($self, $hsp) = @_;
78 my $bio_ens_seqFeature_converter = $self->_bio_ens_seqFeature_converter;
79 my $ens_feature1 = $bio_ens_seqFeature_converter->_convert_single(
81 my $ens_feature2 = $bio_ens_seqFeature_converter->_convert_single(
84 $ens_feature1->p_value($hsp->evalue);
85 $ens_feature1->score($hsp->score);
86 $ens_feature1->percent_id($hsp->percent_identity);
87 $ens_feature2->p_value($hsp->evalue);
88 $ens_feature2->score($hsp->score);
89 $ens_feature2->percent_id($hsp->percent_identity);
92 -feature1 => $ens_feature1,
93 -feature2 => $ens_feature2
99 sub _convert_single_to_proteinFeature {
100 my ($self, $hsp) = @_;
102 my $ens_featurePair = $self->_convert_single_to_featurePair($hsp);
104 -feature1 => $ens_featurePair->feature1,
105 -feature2 => $ens_featurePair->feature2
107 $ens_proteinFeature->
seqname($self->translation_id);
108 return $ens_proteinFeature;
111 sub _convert_single_to_alignFeature {
112 my ($self, $hsp) = @_;
113 my $ens_featurePair = $self->_convert_single_to_featurePair($hsp);
114 my $cigar_string = $hsp->cigar_string;
116 -feature1 => $ens_featurePair->feature1,
117 -feature2 => $ens_featurePair->feature2,
118 -cigar_string => $hsp->cigar_string
120 my $contig = $self->contig;
121 # choose the AlignFeature based on the blast program
122 my $program = $hsp->algorithm;
124 $self->throw(
"HSP does not have algorithm value") unless(defined($program));
126 if($program =~ /blastn/i){
128 # $align_feature->attach_seq($contig);
129 }elsif($program =~ /blastx/i){
131 # $align_feature->attach_seq($contig);
133 $self->throw(
"\[$program\] is not supported yet");
135 return $align_feature;
138 sub _bio_ens_seqFeature_converter {
140 return $self->{_bio_ens_seqFeature_converter} = shift
if(@_);
141 return $self->{_bio_ens_seqFeature_converter};