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
38 -XREF_IDENTITY => 80.4,
39 -ENSEMBL_IDENTITY => 90.1,
42 -CIGAR_LINE =>
'23MD3M2I40M',
48 -PRIMARY_ID => $primary_id,
49 -DBNAME =>
'SwissProt'
56 package Bio::EnsEMBL::IdentityXref;
58 use vars qw(@ISA $AUTOLOAD);
67 Arg [...] : XREF_IDENTITY ENSEMBL_IDENTITY SCORE EVALUE CIGAR_LINE
68 : XREF_START XREF_END ENSEMBL_START ENSEMBL_END
70 Example : see synopsis
82 my ($class, @args) = @_;
83 my $self = $class->SUPER::new(@args);
84 my ($query_identity, $target_identity, $score, $evalue,
85 $cigar_line, $query_start, $query_end, $translation_start,
86 $translation_end, $analysis, $xref_identity, $ensembl_identity,
87 $xref_start, $xref_end, $ensembl_start, $ensembl_end) = rearrange(
88 [qw(QUERY_IDENTITY TARGET_IDENTITY SCORE EVALUE CIGAR_LINE
89 QUERY_START QUERY_END TRANSLATION_START TRANSLATION_END
90 ANALYSIS XREF_IDENTITY ENSEMBL_IDENTITY XREF_START XREF_END ENSEMBL_START ENSEMBL_END)], @args);
92 if((defined($query_identity) or defined($target_identity) or defined($query_start) or defined ($query_end) or
93 defined($translation_start) or defined($translation_end)) and !$error_shown){
94 print STDERR
"Arguments have now been changed to stop confusion so please replace the following\n";
95 print STDERR
"\tQUERY_IDENTITY\t->\tXREF_IDENTITY\n";
96 print STDERR
"\tTARGET_IDENTITY\t->\tENSEMBL_IDENTITY\n";
97 print STDERR
"\tQUERY_START\t->\tXREF_START\n";
98 print STDERR
"\tQUERY_END\t->\tXREF_END\n";
99 print STDERR
"\tTRANSLATION_START\t->\tENSEMBL_START\n";
100 print STDERR
"\tTRANSLATION_END\t->\tENSEMBL_END\n";
101 print STDERR
"The old arguments will be removed in a futute release so please change your code to the new names\n";
104 $self->{
'xref_identity'} = $query_identity || $xref_identity;
105 $self->{
'ensembl_identity'} = $target_identity || $ensembl_identity;
106 $self->{
'score'} = $score;
107 $self->{
'evalue'} = $evalue;
108 $self->{
'cigar_line'} = $cigar_line;
109 $self->{
'xref_start'} = $query_start || $xref_start;
110 $self->{
'xref_end'} = $query_end || $xref_end;
111 $self->{
'ensembl_start'} = $translation_start || $ensembl_start;
112 $self->{
'ensembl_end'} = $translation_end || $ensembl_end;
113 $self->{
'analysis'} = $analysis;
120 Arg [1] : (optional)
string $value
121 Example : $xref_identity = $id_xref->xref_identity;
122 Description: Getter/Setter
for xref identity
134 $obj->{
'xref_identity'} = $value;
136 return $obj->{
'xref_identity'};
141 =head2 ensembl_identity
143 Arg [1] : (optional)
string $value
144 Example : $ensembl_identity = $id_xref->ensembl_identity;
145 Description: Getter/Setter
for ensembl identity
153 sub ensembl_identity{
157 $obj->{
'ensembl_identity'} = $value;
159 return $obj->{
'ensembl_identity'};
167 Arg [1] :
string $cigar_line
169 Description: get/set
for attribute cigar_line
179 $self->{
'cigar_line'} = shift
if( @_ );
180 return $self->{
'cigar_line'};
186 Arg [1] :
string $ensembl_start
188 Description: get/set
for attribute ensembl_start
198 $self->{
'ensembl_start'} = shift
if( @_ );
199 return $self->{
'ensembl_start'};
205 Arg [1] :
string $ensembl_end
207 Description: get/set
for attribute ensembl_end
217 $self->{
'ensembl_end'} = shift
if( @_ );
218 return $self->{
'ensembl_end'};
224 Arg [1] :
string $xref_start
226 Description: get/set
for attribute xref_start
236 $self->{
'xref_start'} = shift
if( @_ );
237 return $self->{
'xref_start'};
243 Arg [1] :
string $xref_end
245 Description: get/set
for attribute xref_end
255 $self->{
'xref_end'} = shift
if( @_ );
256 return $self->{
'xref_end'};
262 Arg [1] :
string $score
264 Description: get/set
for attribute score
274 $self->{
'score'} = shift
if( @_ );
275 return $self->{
'score'};
281 Arg [1] :
string $evalue
283 Description: get/set
for attribute evalue
293 $self->{
'evalue'} = shift
if( @_ );
294 return $self->{
'evalue'};
304 Description: produces a mapper
object that takes coordinates from one side
305 of the alignment to the other side.
"ensembl" and
"external"
306 are the two coordinate systems contained.
309 Caller : general, ProteinDAS subsystem
317 # parse the cigar_line and create a mapper ...
318 if( exists $self->{
'_cached_mapper'} ) {
319 return $self->{
'_cached_mapper'};
322 my ( @lens, @chars );
324 # if there is no cigar line, nothing is going to be loaded
325 if( $self->cigar_line() ) {
326 my @pre_lens = split(
'[DMI]', $self->cigar_line() );
327 @lens =
map {
if( ! $_ ) { 1 }
else { $_ }} @pre_lens;
328 @chars = grep { /[DMI]/ } split(
330 my $translation_start = $self->ensembl_start();
331 my $translation_end = $self->ensembl_end();
332 my $query_start = $self->xref_start();
333 my $query_end = $self->xref_end();
335 # my $hit_id = $self->display_id();
336 my $ensembl_id =
"ensembl_id";
337 my $external_id =
"external_id";
338 # now build the mapper
342 for( my $i=0; $i<=$#lens; $i++ ) {
343 my $length = $lens[$i];
344 my $char = $chars[$i];
346 $mapper->add_map_coordinates( $external_id, $query_start,
347 $query_start + $length - 1, 1,
348 $ensembl_id, $translation_start,
349 $translation_start + $length - 1);
350 $query_start += $length;
351 $translation_start += $length;
353 } elsif( $char eq
"D" ) {
354 $translation_start += $length;
355 } elsif( $char eq
"I" ) {
356 $query_start += $length;
360 $self->{
'_cached_mapper'} = $mapper;
367 =head2 transform_feature
369 Arg [1] : a feature type with start and end $feature
371 need an attached slice. We may have to introduce an appropriate
373 Example : my $ens_prot_feature_list =
374 $ident_xref->transform_feature( $swiss_prot_feature );
375 Description: a list of potential partial features which represent all
377 of the original feature in ensembl translation coordinates.
378 Returntype : listref of whatever was put in
380 Caller : general, ProteinDAS subsystem
386 sub transform_feature {
390 my $fstart = $feature->
start();
391 my $fend = $feature->end();
393 my $mapper = $self->get_mapper();
396 my @coords = $mapper->map_coordinates(
"external_id", $fstart, $fend,
399 for my $coord ( @coords ) {
400 if( $coord->isa(
"Bio::EnsEMBL::Mapper::Coordinate" )) {
402 %{$new_feature} = %$feature;
403 bless $new_feature, ref( $feature );
404 $new_feature->start( $coord->start() );
405 $new_feature->end( $coord->end() );
407 push( @result, $new_feature );
418 Arg [1] : a start,end capable feature
object
421 Returntype : list of Coordinates/Gaps which represents the mapping
423 Caller : another way of doing ProteinDAS
433 my $fstart = $feature->start();
434 my $fend = $feature->end();
436 my $mapper = $self->get_mapper();
437 my @coords = $mapper->map_coordinates(
"external_id", $fstart, $fend, 1,