0
|
1 =head1 LICENSE
|
|
2
|
|
3 Copyright (c) 1999-2012 The European Bioinformatics Institute and
|
|
4 Genome Research Limited. All rights reserved.
|
|
5
|
|
6 This software is distributed under a modified Apache license.
|
|
7 For license details, please see
|
|
8
|
|
9 http://www.ensembl.org/info/about/code_licence.html
|
|
10
|
|
11 =head1 CONTACT
|
|
12
|
|
13 Please email comments or questions to the public Ensembl
|
|
14 developers list at <dev@ensembl.org>.
|
|
15
|
|
16 Questions may also be sent to the Ensembl help desk at
|
|
17 <helpdesk@ensembl.org>.
|
|
18
|
|
19 =cut
|
|
20
|
|
21 =head1 NAME
|
|
22
|
|
23 Bio::EnsEMBL::IdentityXref
|
|
24
|
|
25 =head1 SYNOPSIS
|
|
26
|
|
27 my $xref = Bio::EnsEMBL::IdentityXref->new(
|
|
28 -XREF_IDENTITY => 80.4,
|
|
29 -ENSEMBL_IDENTITY => 90.1,
|
|
30 -SCORE => 90,
|
|
31 -EVALUE => 12,
|
|
32 -CIGAR_LINE => '23MD3M2I40M',
|
|
33 -XREF_START => 1,
|
|
34 -XREF_END => 68,
|
|
35 -ENSEMBL_START => 10,
|
|
36 -ENSEMBL_END => 77,
|
|
37 -ADAPTOR => $adaptor,
|
|
38 -PRIMARY_ID => $primary_id,
|
|
39 -DBNAME => 'SwissProt'
|
|
40 );
|
|
41
|
|
42 =head1 METHODS
|
|
43
|
|
44 =cut
|
|
45
|
|
46 package Bio::EnsEMBL::IdentityXref;
|
|
47 use vars qw(@ISA $AUTOLOAD);
|
|
48 use strict;
|
|
49 use Bio::EnsEMBL::Utils::Argument qw( rearrange );
|
|
50 use Bio::EnsEMBL::Utils::Exception qw( deprecate );
|
|
51
|
|
52 @ISA = qw( Bio::EnsEMBL::DBEntry );
|
|
53
|
|
54
|
|
55 =head2 new
|
|
56
|
|
57 Arg [...] : XREF_IDENTITY ENSEMBL_IDENTITY SCORE EVALUE CIGAR_LINE
|
|
58 : XREF_START XREF_END ENSEMBL_START ENSEMBL_END
|
|
59 : ANALYSIS pairs
|
|
60 Example : see synopsis
|
|
61 Description: Create a new Bio::EnsEMBL::IdentityXref object
|
|
62 Returntype : Bio::EnsEMBL::IdentityXref
|
|
63 Exceptions : none
|
|
64 Caller : general
|
|
65 Status : Stable
|
|
66
|
|
67 =cut
|
|
68
|
|
69 my $error_shown = 0;
|
|
70
|
|
71 sub new {
|
|
72 my ($class, @args) = @_;
|
|
73 my $self = $class->SUPER::new(@args);
|
|
74 my ($query_identity, $target_identity, $score, $evalue,
|
|
75 $cigar_line, $query_start, $query_end, $translation_start,
|
|
76 $translation_end, $analysis, $xref_identity, $ensembl_identity,
|
|
77 $xref_start, $xref_end, $ensembl_start, $ensembl_end) = rearrange(
|
|
78 [qw(QUERY_IDENTITY TARGET_IDENTITY SCORE EVALUE CIGAR_LINE
|
|
79 QUERY_START QUERY_END TRANSLATION_START TRANSLATION_END
|
|
80 ANALYSIS XREF_IDENTITY ENSEMBL_IDENTITY XREF_START XREF_END ENSEMBL_START ENSEMBL_END)], @args);
|
|
81
|
|
82 if((defined($query_identity) or defined($target_identity) or defined($query_start) or defined ($query_end) or
|
|
83 defined($translation_start) or defined($translation_end)) and !$error_shown){
|
|
84 print STDERR "Arguments have now been changed to stop confusion so please replace the following\n";
|
|
85 print STDERR "\tQUERY_IDENTITY\t->\tXREF_IDENTITY\n";
|
|
86 print STDERR "\tTARGET_IDENTITY\t->\tENSEMBL_IDENTITY\n";
|
|
87 print STDERR "\tQUERY_START\t->\tXREF_START\n";
|
|
88 print STDERR "\tQUERY_END\t->\tXREF_END\n";
|
|
89 print STDERR "\tTRANSLATION_START\t->\tENSEMBL_START\n";
|
|
90 print STDERR "\tTRANSLATION_END\t->\tENSEMBL_END\n";
|
|
91 print STDERR "The old arguments will be removed in a futute release so please change your code to the new names\n";
|
|
92 $error_shown = 1;
|
|
93 }
|
|
94 $self->{'xref_identity'} = $query_identity || $xref_identity;
|
|
95 $self->{'ensembl_identity'} = $target_identity || $ensembl_identity;
|
|
96 $self->{'score'} = $score;
|
|
97 $self->{'evalue'} = $evalue;
|
|
98 $self->{'cigar_line'} = $cigar_line;
|
|
99 $self->{'xref_start'} = $query_start || $xref_start;
|
|
100 $self->{'xref_end'} = $query_end || $xref_start;
|
|
101 $self->{'ensembl_start'} = $translation_start || $ensembl_start;
|
|
102 $self->{'ensembl_end'} = $translation_end || $ensembl_end;
|
|
103 $self->{'analysis'} = $analysis;
|
|
104
|
|
105 return $self;
|
|
106 }
|
|
107
|
|
108 =head2 xref_identity
|
|
109
|
|
110 Arg [1] : (optional) string $value
|
|
111 Example : $xref_identity = $id_xref->xref_identity;
|
|
112 Description: Getter/Setter for xref identity
|
|
113 Returntype : string
|
|
114 Exceptions : none
|
|
115 Caller : general
|
|
116 Status : Stable
|
|
117
|
|
118 =cut
|
|
119
|
|
120 sub xref_identity{
|
|
121 my $obj = shift;
|
|
122 if( @_ ) {
|
|
123 my $value = shift;
|
|
124 $obj->{'xref_identity'} = $value;
|
|
125 }
|
|
126 return $obj->{'xref_identity'};
|
|
127
|
|
128 }
|
|
129
|
|
130
|
|
131 =head2 ensembl_identity
|
|
132
|
|
133 Arg [1] : (optional) string $value
|
|
134 Example : $ensembl_identity = $id_xref->ensembl_identity;
|
|
135 Description: Getter/Setter for ensembl identity
|
|
136 Returntype : string
|
|
137 Exceptions : none
|
|
138 Caller : general
|
|
139 Status : Stable
|
|
140
|
|
141 =cut
|
|
142
|
|
143 sub ensembl_identity{
|
|
144 my $obj = shift;
|
|
145 if( @_ ) {
|
|
146 my $value = shift;
|
|
147 $obj->{'ensembl_identity'} = $value;
|
|
148 }
|
|
149 return $obj->{'ensembl_identity'};
|
|
150
|
|
151 }
|
|
152
|
|
153
|
|
154
|
|
155 =head2 cigar_line
|
|
156
|
|
157 Arg [1] : string $cigar_line
|
|
158 Example : none
|
|
159 Description: get/set for attribute cigar_line
|
|
160 Returntype : string
|
|
161 Exceptions : none
|
|
162 Caller : general
|
|
163 Status : Stable
|
|
164
|
|
165 =cut
|
|
166
|
|
167 sub cigar_line {
|
|
168 my $self = shift;
|
|
169 $self->{'cigar_line'} = shift if( @_ );
|
|
170 return $self->{'cigar_line'};
|
|
171 }
|
|
172
|
|
173
|
|
174 =head2 ensembl_start
|
|
175
|
|
176 Arg [1] : string $ensembl_start
|
|
177 Example : none
|
|
178 Description: get/set for attribute ensembl_start
|
|
179 Returntype : string
|
|
180 Exceptions : none
|
|
181 Caller : general
|
|
182 Status : Stable
|
|
183
|
|
184 =cut
|
|
185
|
|
186 sub ensembl_start {
|
|
187 my $self = shift;
|
|
188 $self->{'ensembl_start'} = shift if( @_ );
|
|
189 return $self->{'ensembl_start'};
|
|
190 }
|
|
191
|
|
192
|
|
193 =head2 ensembl_end
|
|
194
|
|
195 Arg [1] : string $ensembl_end
|
|
196 Example : none
|
|
197 Description: get/set for attribute ensembl_end
|
|
198 Returntype : string
|
|
199 Exceptions : none
|
|
200 Caller : general
|
|
201 Status : Stable
|
|
202
|
|
203 =cut
|
|
204
|
|
205 sub ensembl_end {
|
|
206 my $self = shift;
|
|
207 $self->{'ensembl_end'} = shift if( @_ );
|
|
208 return $self->{'ensembl_end'};
|
|
209 }
|
|
210
|
|
211
|
|
212 =head2 xref_start
|
|
213
|
|
214 Arg [1] : string $xref_start
|
|
215 Example : none
|
|
216 Description: get/set for attribute xref_start
|
|
217 Returntype : string
|
|
218 Exceptions : none
|
|
219 Caller : general
|
|
220 Status : Stable
|
|
221
|
|
222 =cut
|
|
223
|
|
224 sub xref_start {
|
|
225 my $self = shift;
|
|
226 $self->{'xref_start'} = shift if( @_ );
|
|
227 return $self->{'xref_start'};
|
|
228 }
|
|
229
|
|
230
|
|
231 =head2 xref_end
|
|
232
|
|
233 Arg [1] : string $xref_end
|
|
234 Example : none
|
|
235 Description: get/set for attribute xref_end
|
|
236 Returntype : string
|
|
237 Exceptions : none
|
|
238 Caller : general
|
|
239 Status : Stable
|
|
240
|
|
241 =cut
|
|
242
|
|
243 sub xref_end {
|
|
244 my $self = shift;
|
|
245 $self->{'xref_end'} = shift if( @_ );
|
|
246 return $self->{'xref_end'};
|
|
247 }
|
|
248
|
|
249
|
|
250 =head2 score
|
|
251
|
|
252 Arg [1] : string $score
|
|
253 Example : none
|
|
254 Description: get/set for attribute score
|
|
255 Returntype : string
|
|
256 Exceptions : none
|
|
257 Caller : general
|
|
258 Status : Stable
|
|
259
|
|
260 =cut
|
|
261
|
|
262 sub score {
|
|
263 my $self = shift;
|
|
264 $self->{'score'} = shift if( @_ );
|
|
265 return $self->{'score'};
|
|
266 }
|
|
267
|
|
268
|
|
269 =head2 evalue
|
|
270
|
|
271 Arg [1] : string $evalue
|
|
272 Example : none
|
|
273 Description: get/set for attribute evalue
|
|
274 Returntype : string
|
|
275 Exceptions : none
|
|
276 Caller : general
|
|
277 Status : Stable
|
|
278
|
|
279 =cut
|
|
280
|
|
281 sub evalue {
|
|
282 my $self = shift;
|
|
283 $self->{'evalue'} = shift if( @_ );
|
|
284 return $self->{'evalue'};
|
|
285 }
|
|
286
|
|
287
|
|
288
|
|
289
|
|
290 =head2 get_mapper
|
|
291
|
|
292 Args : none
|
|
293 Example : none
|
|
294 Description: produces a mapper object that takes coordinates from one side
|
|
295 of the alignment to the other side. "ensembl" and "external"
|
|
296 are the two coordinate systems contained.
|
|
297 Returntype : Bio::EnsEMBL::Mapper
|
|
298 Exceptions : none
|
|
299 Caller : general, ProteinDAS subsystem
|
|
300 Status : Stable
|
|
301
|
|
302 =cut
|
|
303
|
|
304
|
|
305 sub get_mapper {
|
|
306 my ( $self ) = @_;
|
|
307 # parse the cigar_line and create a mapper ...
|
|
308 if( exists $self->{'_cached_mapper'} ) {
|
|
309 return $self->{'_cached_mapper'};
|
|
310 }
|
|
311
|
|
312 my ( @lens, @chars );
|
|
313
|
|
314 # if there is no cigar line, nothing is going to be loaded
|
|
315 if( $self->cigar_line() ) {
|
|
316 my @pre_lens = split( '[DMI]', $self->cigar_line() );
|
|
317 @lens = map { if( ! $_ ) { 1 } else { $_ }} @pre_lens;
|
|
318 @chars = grep { /[DMI]/ } split( //, $self->cigar_line() );
|
|
319 }
|
|
320 my $translation_start = $self->ensembl_start();
|
|
321 my $translation_end = $self->ensembl_end();
|
|
322 my $query_start = $self->xref_start();
|
|
323 my $query_end = $self->xref_end();
|
|
324
|
|
325 # my $hit_id = $self->display_id();
|
|
326 my $ensembl_id = "ensembl_id";
|
|
327 my $external_id = "external_id";
|
|
328 # now build the mapper
|
|
329 my $mapper = Bio::EnsEMBL::Mapper->new( "external", "ensembl" );
|
|
330
|
|
331
|
|
332 for( my $i=0; $i<=$#lens; $i++ ) {
|
|
333 my $length = $lens[$i];
|
|
334 my $char = $chars[$i];
|
|
335 if( $char eq "M" ) {
|
|
336 $mapper->add_map_coordinates( $external_id, $query_start,
|
|
337 $query_start + $length - 1, 1,
|
|
338 $ensembl_id, $translation_start,
|
|
339 $translation_start + $length - 1);
|
|
340 $query_start += $length;
|
|
341 $translation_start += $length;
|
|
342
|
|
343 } elsif( $char eq "D" ) {
|
|
344 $translation_start += $length;
|
|
345 } elsif( $char eq "I" ) {
|
|
346 $query_start += $length;
|
|
347 }
|
|
348 }
|
|
349
|
|
350 $self->{'_cached_mapper'} = $mapper;
|
|
351
|
|
352 return $mapper;
|
|
353 }
|
|
354
|
|
355
|
|
356
|
|
357 =head2 transform_feature
|
|
358
|
|
359 Arg [1] : a feature type with start and end $feature
|
|
360 This doesnt need to be a Bio::EnsEMBL::Feature as it doesnt
|
|
361 need an attached slice. We may have to introduce an appropriate
|
|
362 object type.
|
|
363 Example : my $ens_prot_feature_list =
|
|
364 $ident_xref->transform_feature( $swiss_prot_feature );
|
|
365 Description: a list of potential partial features which represent all
|
|
366 mappable places
|
|
367 of the original feature in ensembl translation coordinates.
|
|
368 Returntype : listref of whatever was put in
|
|
369 Exceptions : none
|
|
370 Caller : general, ProteinDAS subsystem
|
|
371 Status : Stable
|
|
372
|
|
373 =cut
|
|
374
|
|
375
|
|
376 sub transform_feature {
|
|
377 my $self= shift;
|
|
378 my $feature = shift;
|
|
379
|
|
380 my $fstart = $feature->start();
|
|
381 my $fend = $feature->end();
|
|
382
|
|
383 my $mapper = $self->get_mapper();
|
|
384 my @result;
|
|
385
|
|
386 my @coords = $mapper->map_coordinates( "external_id", $fstart, $fend,
|
|
387 1, "external" );
|
|
388
|
|
389 for my $coord ( @coords ) {
|
|
390 if( $coord->isa( "Bio::EnsEMBL::Mapper::Coordinate" )) {
|
|
391 my $new_feature;
|
|
392 %{$new_feature} = %$feature;
|
|
393 bless $new_feature, ref( $feature );
|
|
394 $new_feature->start( $coord->start() );
|
|
395 $new_feature->end( $coord->end() );
|
|
396
|
|
397 push( @result, $new_feature );
|
|
398 }
|
|
399 }
|
|
400
|
|
401 return \@result;
|
|
402 }
|
|
403
|
|
404
|
|
405
|
|
406 =head2 map_feature
|
|
407
|
|
408 Arg [1] : a start,end capable feature object
|
|
409 Example : none
|
|
410 Description:
|
|
411 Returntype : list of Coordinates/Gaps which represents the mapping
|
|
412 Exceptions : none
|
|
413 Caller : another way of doing ProteinDAS
|
|
414 Status : Stable
|
|
415
|
|
416 =cut
|
|
417
|
|
418 sub map_feature {
|
|
419 my $self = shift;
|
|
420 my $feature = shift;
|
|
421
|
|
422
|
|
423 my $fstart = $feature->start();
|
|
424 my $fend = $feature->end();
|
|
425
|
|
426 my $mapper = $self->get_mapper();
|
|
427 my @coords = $mapper->map_coordinates( "external_id", $fstart, $fend, 1,
|
|
428 "external" );
|
|
429
|
|
430 return @coords;
|
|
431 }
|
|
432
|
|
433
|
|
434 ###########################
|
|
435 # DEPRECATED METHODS FOLLOW
|
|
436 ###########################
|
|
437
|
|
438 =head2 query_identity
|
|
439
|
|
440 Description: DEPRECATED. Use xref_identity() instead.
|
|
441 Status : At Risk
|
|
442
|
|
443 =cut
|
|
444
|
|
445 sub query_identity{
|
|
446 deprecate("Use xref_identity instead");
|
|
447 xref_identity(@_);
|
|
448 }
|
|
449
|
|
450
|
|
451 =head2 target_identity
|
|
452
|
|
453 Description: DEPRECATED. Use ensembl_identity() instead.
|
|
454 Status : At Risk
|
|
455
|
|
456 =cut
|
|
457
|
|
458 sub target_identity{
|
|
459 deprecate("Use ensembl_identity instead");
|
|
460 ensembl_identity(@_);
|
|
461 }
|
|
462
|
|
463
|
|
464
|
|
465 =head2 translation_start
|
|
466
|
|
467 Description: DEPRECATED. Use ensembl_start() instead.
|
|
468 Status : At Risk
|
|
469
|
|
470 =cut
|
|
471
|
|
472 sub translation_start {
|
|
473 deprecate("Use ensembl_start instead");
|
|
474 ensembl_start(@_);
|
|
475
|
|
476 }
|
|
477
|
|
478
|
|
479 =head2 translation_end
|
|
480
|
|
481 Description: DEPRECATED. Use ensembl_end() instead.
|
|
482 Status : At Risk
|
|
483
|
|
484 =cut
|
|
485
|
|
486 sub translation_end {
|
|
487 deprecate("Use ensembl_end instead");
|
|
488 ensembl_end(@_);
|
|
489 }
|
|
490
|
|
491
|
|
492
|
|
493 =head2 query_start
|
|
494
|
|
495 Description: DEPRECATED. Use xref_start() instead.
|
|
496 Status : At Risk
|
|
497
|
|
498 =cut
|
|
499
|
|
500 sub query_start {
|
|
501 deprecate("Use xref_start instead");
|
|
502 xref_start(@_);
|
|
503
|
|
504 }
|
|
505
|
|
506
|
|
507
|
|
508 =head2 query_end
|
|
509
|
|
510 Description: DEPRECATED. Use xref_end() instead.
|
|
511 Status : At Risk
|
|
512
|
|
513 =cut
|
|
514
|
|
515 sub query_end {
|
|
516 deprecate("Use xref_end instead");
|
|
517 xref_end(@_);
|
|
518
|
|
519 }
|
|
520
|
|
521
|
|
522 1;
|