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;
57 use vars qw(@ISA $AUTOLOAD);
66 Arg [...] : XREF_IDENTITY ENSEMBL_IDENTITY SCORE EVALUE CIGAR_LINE
67 : XREF_START XREF_END ENSEMBL_START ENSEMBL_END
69 Example : see synopsis
81 my ($class, @args) = @_;
82 my $self = $class->SUPER::new(@args);
83 my ($query_identity, $target_identity, $score, $evalue,
84 $cigar_line, $query_start, $query_end, $translation_start,
85 $translation_end, $analysis, $xref_identity, $ensembl_identity,
86 $xref_start, $xref_end, $ensembl_start, $ensembl_end) = rearrange(
87 [qw(QUERY_IDENTITY TARGET_IDENTITY SCORE EVALUE CIGAR_LINE
88 QUERY_START QUERY_END TRANSLATION_START TRANSLATION_END
89 ANALYSIS XREF_IDENTITY ENSEMBL_IDENTITY XREF_START XREF_END ENSEMBL_START ENSEMBL_END)], @args);
91 if((defined($query_identity) or defined($target_identity) or defined($query_start) or defined ($query_end) or
92 defined($translation_start) or defined($translation_end)) and !$error_shown){
93 print STDERR
"Arguments have now been changed to stop confusion so please replace the following\n";
94 print STDERR
"\tQUERY_IDENTITY\t->\tXREF_IDENTITY\n";
95 print STDERR
"\tTARGET_IDENTITY\t->\tENSEMBL_IDENTITY\n";
96 print STDERR
"\tQUERY_START\t->\tXREF_START\n";
97 print STDERR
"\tQUERY_END\t->\tXREF_END\n";
98 print STDERR
"\tTRANSLATION_START\t->\tENSEMBL_START\n";
99 print STDERR
"\tTRANSLATION_END\t->\tENSEMBL_END\n";
100 print STDERR
"The old arguments will be removed in a futute release so please change your code to the new names\n";
103 $self->{
'xref_identity'} = $query_identity || $xref_identity;
104 $self->{
'ensembl_identity'} = $target_identity || $ensembl_identity;
105 $self->{
'score'} = $score;
106 $self->{
'evalue'} = $evalue;
107 $self->{
'cigar_line'} = $cigar_line;
108 $self->{
'xref_start'} = $query_start || $xref_start;
109 $self->{
'xref_end'} = $query_end || $xref_end;
110 $self->{
'ensembl_start'} = $translation_start || $ensembl_start;
111 $self->{
'ensembl_end'} = $translation_end || $ensembl_end;
112 $self->{
'analysis'} = $analysis;
119 Arg [1] : (optional)
string $value
120 Example : $xref_identity = $id_xref->xref_identity;
121 Description: Getter/Setter
for xref identity
133 $obj->{
'xref_identity'} = $value;
135 return $obj->{
'xref_identity'};
140 =head2 ensembl_identity
142 Arg [1] : (optional)
string $value
143 Example : $ensembl_identity = $id_xref->ensembl_identity;
144 Description: Getter/Setter
for ensembl identity
152 sub ensembl_identity{
156 $obj->{
'ensembl_identity'} = $value;
158 return $obj->{
'ensembl_identity'};
166 Arg [1] :
string $cigar_line
168 Description: get/set
for attribute cigar_line
178 $self->{
'cigar_line'} = shift
if( @_ );
179 return $self->{
'cigar_line'};
185 Arg [1] :
string $ensembl_start
187 Description: get/set
for attribute ensembl_start
197 $self->{
'ensembl_start'} = shift
if( @_ );
198 return $self->{
'ensembl_start'};
204 Arg [1] :
string $ensembl_end
206 Description: get/set
for attribute ensembl_end
216 $self->{
'ensembl_end'} = shift
if( @_ );
217 return $self->{
'ensembl_end'};
223 Arg [1] :
string $xref_start
225 Description: get/set
for attribute xref_start
235 $self->{
'xref_start'} = shift
if( @_ );
236 return $self->{
'xref_start'};
242 Arg [1] :
string $xref_end
244 Description: get/set
for attribute xref_end
254 $self->{
'xref_end'} = shift
if( @_ );
255 return $self->{
'xref_end'};
261 Arg [1] :
string $score
263 Description: get/set
for attribute score
273 $self->{
'score'} = shift
if( @_ );
274 return $self->{
'score'};
280 Arg [1] :
string $evalue
282 Description: get/set
for attribute evalue
292 $self->{
'evalue'} = shift
if( @_ );
293 return $self->{
'evalue'};
303 Description: produces a mapper
object that takes coordinates from one side
304 of the alignment to the other side.
"ensembl" and
"external"
305 are the two coordinate systems contained.
308 Caller : general, ProteinDAS subsystem
316 # parse the cigar_line and create a mapper ...
317 if( exists $self->{
'_cached_mapper'} ) {
318 return $self->{
'_cached_mapper'};
321 my ( @lens, @chars );
323 # if there is no cigar line, nothing is going to be loaded
324 if( $self->cigar_line() ) {
325 my @pre_lens = split(
'[DMI]', $self->cigar_line() );
326 @lens =
map {
if( ! $_ ) { 1 }
else { $_ }} @pre_lens;
327 @chars = grep { /[DMI]/ } split(
329 my $translation_start = $self->ensembl_start();
330 my $translation_end = $self->ensembl_end();
331 my $query_start = $self->xref_start();
332 my $query_end = $self->xref_end();
334 # my $hit_id = $self->display_id();
335 my $ensembl_id =
"ensembl_id";
336 my $external_id =
"external_id";
337 # now build the mapper
341 for( my $i=0; $i<=$#lens; $i++ ) {
342 my $length = $lens[$i];
343 my $char = $chars[$i];
345 $mapper->add_map_coordinates( $external_id, $query_start,
346 $query_start + $length - 1, 1,
347 $ensembl_id, $translation_start,
348 $translation_start + $length - 1);
349 $query_start += $length;
350 $translation_start += $length;
352 } elsif( $char eq
"D" ) {
353 $translation_start += $length;
354 } elsif( $char eq
"I" ) {
355 $query_start += $length;
359 $self->{
'_cached_mapper'} = $mapper;
366 =head2 transform_feature
368 Arg [1] : a feature type with start and end $feature
370 need an attached slice. We may have to introduce an appropriate
372 Example : my $ens_prot_feature_list =
373 $ident_xref->transform_feature( $swiss_prot_feature );
374 Description: a list of potential partial features which represent all
376 of the original feature in ensembl translation coordinates.
377 Returntype : listref of whatever was put in
379 Caller : general, ProteinDAS subsystem
385 sub transform_feature {
389 my $fstart = $feature->
start();
390 my $fend = $feature->end();
392 my $mapper = $self->get_mapper();
395 my @coords = $mapper->map_coordinates(
"external_id", $fstart, $fend,
398 for my $coord ( @coords ) {
399 if( $coord->isa(
"Bio::EnsEMBL::Mapper::Coordinate" )) {
401 %{$new_feature} = %$feature;
402 bless $new_feature, ref( $feature );
403 $new_feature->start( $coord->start() );
404 $new_feature->end( $coord->end() );
406 push( @result, $new_feature );
417 Arg [1] : a start,end capable feature
object
420 Returntype : list of Coordinates/Gaps which represents the mapping
422 Caller : another way of doing ProteinDAS
432 my $fstart = $feature->start();
433 my $fend = $feature->end();
435 my $mapper = $self->get_mapper();
436 my @coords = $mapper->map_coordinates(
"external_id", $fstart, $fend, 1,