| 1 |
|
| 2 |
=head1 LICENSE |
| 3 |
|
| 4 |
Copyright [2015-2024] EMBL-European Bioinformatics Institute |
| 5 |
|
| 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 |
| 9 |
|
| 10 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
|
| 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. |
| 17 |
|
| 18 |
=head1 NAME |
| 19 |
|
| 20 |
Bio::DB::HTS::PileupWrapper -- Add high-level methods to Bio::DB::HTS::Pileup |
| 21 |
|
| 22 |
=head1 SYNOPSIS |
| 23 |
|
| 24 |
See L<Bio::DB::HTS/The generic fetch() and pileup() methods> for usage of the pileup() method. |
| 25 |
|
| 26 |
=head1 DESCRIPTION |
| 27 |
|
| 28 |
See L<Bio::DB::HTS::Pileup> for documentation of this object's |
| 29 |
methods. This class is used by the high-level API to return |
| 30 |
Bio::DB::HTS::AlignWrapper objects from the call to alignment() rather |
| 31 |
than Bio::DB::HTS::Alignment. |
| 32 |
|
| 33 |
=head1 AUTHOR |
| 34 |
|
| 35 |
Rishi Nag E<lt>[email protected]<gt> |
| 36 |
|
| 37 |
=head1 SEE ALSO |
| 38 |
|
| 39 |
L<Bio::Perl>, L<Bio::DB::HTS>, L<Bio::DB::HTS::Constants> |
| 40 |
|
| 41 |
=cut |
| 42 |
|
| 43 |
package Bio::DB::HTS::PileupWrapper; |
| 44 |
$Bio::DB::HTS::PileupWrapper::VERSION = '3.02'; |
| 45 |
|
| 46 |
use strict; |
| 47 |
use warnings; |
| 48 |
|
| 49 |
use Bio::DB::HTS::AlignWrapper; |
| 50 |
|
| 51 |
our $AUTOLOAD; |
| 52 |
use Carp 'croak'; |
| 53 |
|
| 54 |
sub new { |
| 55 |
my $package = shift; |
| 56 |
my ( $align, $sam ) = @_; |
| 57 |
return bless { sam => $sam, pileup => $align }, ref $package || $package; |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
sub AUTOLOAD { |
| 62 |
my ( $pack, $func_name ) = $AUTOLOAD =~ /(.+)::([^:]+)$/; |
| 63 |
return if $func_name eq 'DESTROY'; |
| 64 |
|
| 65 |
no strict 'refs'; |
| 66 |
$_[0] or die "autoload called for non-object symbol $func_name"; |
| 67 |
croak qq(Can't locate object method "$func_name" via package "$pack") |
| 68 |
unless $_[0]->{pileup}->can($func_name); |
| 69 |
|
| 70 |
*{"${pack}::${func_name}"} = sub { shift->{pileup}->$func_name(@_) }; |
| 71 |
|
| 72 |
shift->$func_name(@_); |
| 73 |
} |
| 74 |
|
| 75 |
sub can { |
| 76 |
my $self = shift; |
| 77 |
return 1 if $self->SUPER::can(@_); |
| 78 |
return $self->{pileup}->can(@_); |
| 79 |
} |
| 80 |
|
| 81 |
sub alignment { |
| 82 |
my $self = shift; |
| 83 |
return Bio::DB::HTS::AlignWrapper->new( $self->{pileup}->b, $self->{sam} ); |
| 84 |
} |
| 85 |
|
| 86 |
1; |