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
31 Juguang Xiao <juguang@tll.org.sg>
47 package Bio::EnsEMBL::Utils::Converter::bio_ens_featurePair;
60 my ($self, @args) = @_;
61 $self->SUPER::_initialize(@args);
62 my ($translation_id) = $self->_rearrange([qw(TRANSLATION_ID)], @args);
63 $self->translation_id($translation_id);
65 # internal converter for seqFeature
67 -in =>
'Bio::SeqFeature::Generic',
68 -out =>
'Bio::EnsEMBL::SeqFeature',
73 my ($self, $pair) = @_;
74 unless($pair && $pair->isa(
'Bio::SeqFeature::FeaturePair')){
75 $self->throw(
'a Bio::SeqFeature::FeaturePair object needed');
78 if($self->out eq
'Bio::EnsEMBL::RepeatFeature'){
79 return $self->_convert_single_to_repeatFeature($pair);
80 }elsif($self->out eq
'Bio::EnsEMBL::FeaturePair'){
81 return $self->_convert_single_to_featurePair($pair);
82 }elsif($self->out eq
'Bio::EnsEMBL::ProteinFeature'){
83 return $self->_convert_single_to_proteinFeature($pair);
85 my $output_module = $self->out;
86 $self->throw(
"Cannot covert to [$output_module]");
90 sub _convert_single_to_featurePair {
91 my ($self, $pair) = @_;
92 my $feature1 = $pair->feature1;
93 my $feature2 = $pair->feature2;
94 $self->{_bio_ens_seqFeature}->contig($self->contig);
95 $self->{_bio_ens_seqFeature}->analysis($self->analysis);
96 my $ens_f1 = $self->{_bio_ens_seqFeature}->_convert_single($feature1);
97 my $ens_f2 = $self->{_bio_ens_seqFeature}->_convert_single($feature2);
105 sub _convert_single_to_proteinFeature {
106 my ($self, $pair) = @_;
107 my $featurePair = $self->_convert_single_to_featurePair($pair);
109 -feature1 => $featurePair->feature1,
110 -feature2 => $featurePair->feature2
112 $proteinFeature->
seqname($self->translation_id);
113 return $proteinFeature;
116 sub _convert_single_to_repeatFeature {
117 my ($self, $pair) = @_;
118 my $feature1 = $pair->feature1;
119 my $feature2 = $pair->feature2;
121 -seqname => $feature1->seq_id,
122 -start => $feature1->start,
123 -end => $feature1->end,
124 -strand => $feature1->strand,
125 -source_tag => $feature1->source_tag,
128 my ($h_start, $h_end);
129 if($feature1->strand == 1){
130 $h_start = $feature2->start;
131 $h_end = $feature2->end;
132 }elsif($feature1->strand == -1){
133 $h_start = $feature2->end;
134 $h_end = $feature2->start;
136 $self->throw(
"strand cannot be outside of (1, -1)");
139 $ens_repeatfeature->hstart($h_start);
140 $ens_repeatfeature->hend($h_end);
141 my $repeat_name = $feature2->seq_id;
142 my $repeat_class = $feature1->primary_tag;
143 $repeat_class ||= $feature2->primary_tag;
144 $repeat_class ||=
"not sure";
145 my $ens_repeat_consensus =
146 $self->_create_consensus($repeat_name, $repeat_class);
147 $ens_repeatfeature->repeat_consensus($ens_repeat_consensus);
149 my($contig) = ref ($self->contig) eq 'ARRAY' ? @{$self->contig} : $self->contig;
151 $ens_repeatfeature->attach_seq($contig);
152 $ens_repeatfeature->analysis($self->analysis);
153 return $ens_repeatfeature;
156 sub _create_consensus{
157 my ($self, $repeat_name, $repeat_class) = @_;
159 $consensus->
name($repeat_name);
160 $consensus->repeat_class($repeat_class);