Debian Codegraph @

lib/Bio/DB/HTS/Constants.pm

raw
1
2 =head1 LICENSE
3
4 Copyright [2015-2024] EMBL-European Bioinformatics Institute
5
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19
20 =head1 NAME
21
22 Bio::DB::HTS::Constants -- Constants for use with SAM/BAM
23
24 =head1 SYNOPSIS
25
26 use Bio::DB::HTS::Constants;
27 my $pad_flag = BAM_CPAD;
28
29 =head1 DESCRIPTION
30
31 This module exports several constants for use with the SAM/BAM
32 module. See the SAM documentation for their interpretation.
33
34 =over 4
35
36 =item Cigar operations
37
38 BAM_CIGAR_SHIFT
39 BAM_CIGAR_MASK
40 BAM_CMATCH
41 BAM_CINS
42 BAM_CDEL
43 BAM_CREF_SKIP
44 BAM_CSOFT_CLIP
45 BAM_CHARD_CLIP
46 BAM_CPAD
47
48 =item FLAGS
49
50 A hashref that maps flag values to human-readable names. For example:
51
52 FLAGS->{0x0008} == 'M_UNMAPPED'
53
54 =item RFLAGS
55
56 The reverse of FLAGS:
57
58 RFLAGS->{M_UNMAPPED} == 0x0008
59
60 =back
61
62 =head1 AUTHOR
63
64 Rishi Nag E<lt>[email protected]<gt>
65
66 =head1 SEE ALSO
67
68 L<Bio::Perl>, L<Bio::DB::HTS>, L<Bio::DB::Bam::Alignment>
69
70 =cut
71
72 package Bio::DB::HTS::Constants;
73 $Bio::DB::HTS::Constants::VERSION = '3.02';
74
75 use strict;
76 use warnings;
77
78 require Exporter;
79 our @ISA = qw(Exporter);
80 our @EXPORT = qw(CIGAR_SYMBOLS BAM_CIGAR_SHIFT BAM_CIGAR_MASK
81 BAM_CMATCH BAM_CINS BAM_CDEL BAM_CREF_SKIP
82 BAM_CSOFT_CLIP BAM_CHARD_CLIP BAM_CPAD FLAGS RFLAGS);
83 our @EXPORT_OK = @EXPORT;
84
85 use constant CIGAR_SYMBOLS => [qw(M I D N S H P = X)];
86 use constant BAM_CIGAR_SHIFT => 4;
87 use constant BAM_CIGAR_MASK => ( 1 << BAM_CIGAR_SHIFT ) - 1;
88 use constant BAM_CMATCH => 0;
89 use constant BAM_CINS => 1;
90 use constant BAM_CDEL => 2;
91 use constant BAM_CREF_SKIP => 3;
92 use constant BAM_CSOFT_CLIP => 4;
93 use constant BAM_CHARD_CLIP => 5;
94 use constant BAM_CPAD => 6;
95
96 use constant FLAGS => { 0x0001 => 'PAIRED',
97 0x0002 => 'MAP_PAIR',
98 0x0004 => 'UNMAPPED',
99 0x0008 => 'M_UNMAPPED',
100 0x0010 => 'REVERSED',
101 0x0020 => 'M_REVERSED',
102 0x0040 => 'FIRST_MATE',
103 0x0080 => 'SECOND_MATE',
104 0x0100 => 'NOT_PRIMARY',
105 0x0200 => 'QC_FAILED',
106 0x0400 => 'DUPLICATE',
107 0x0800 => 'SUPPLEMENTARY', };
108 use constant RFLAGS => { reverse %{ FLAGS() } };
109
110 1;