Debian Codegraph @

lib/Bio/DB/HTS/Target.pm

raw
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::Target -- Object representing the query portion of a BAM/SAM alignment in NATIVE alignment
21
22 =head1 SYNOPSIS
23
24 This is identical to Bio::DB::HTS::Query, except that the dna, qscores
25 and start and end positions are all given in the orientation in which
26 the read was sequenced, not in the oreintation in which it was
27 aligned.
28
29 =head1 AUTHOR
30
31 Rishi Nag E<lt>[email protected]<gt>
32
33 =cut
34
35 package Bio::DB::HTS::Target;
36 $Bio::DB::HTS::Target::VERSION = '3.02';
37
38 use strict;
39 use warnings;
40
41 use base 'Bio::DB::HTS::Query';
42
43 sub dna {
44 my $self = shift;
45 my $qseq = $self->SUPER::dna;
46 return $$self->strand > 0 ? $qseq : reversec($qseq);
47 }
48
49 sub qscore {
50 my $self = shift;
51 my @qscore = $$self->qscore;
52 @qscore = reverse @qscore if $$self->strand < 0;
53 return wantarray ? @qscore : \@qscore;
54 }
55
56 sub start {
57 my $self = shift;
58 return $self->strand > 0 ? $self->low : $self->high;
59 }
60
61 sub end {
62 my $self = shift;
63 return $self->strand > 0 ? $self->high : $self->low;
64 }
65
66 # sub strand { 1 }
67
68 sub reversec {
69 my $dna = shift;
70 $dna =~ tr/gatcGATC/ctagCTAG/;
71 return scalar reverse $dna;
72 }
73
74 1;