yat  0.21pre
Cigar.h
1 #ifndef theplu_yat_utility_cigar
2 #define theplu_yat_utility_cigar
3 
4 // $Id: Cigar.h 4005 2020-10-15 12:50:01Z peter $
5 
6 /*
7  Copyright (C) 2014, 2015, 2018, 2020 Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 // This file defines some PP macro for CIGAR
26 
27 
28 #include "config_public.h"
29 
30 // allow inclusion of config_bam.h so this file is available also without bam.h
31 #ifdef YAT_HAVE_HTSLIB
32 #include <htslib/sam.h>
33 #else // if sam.h is not available #define CIGAR
34 #include <cstdint> // needed for int8_t
36 #define BAM_CIGAR_SHIFT 4
37 #define BAM_CIGAR_MASK ((1 << BAM_CIGAR_SHIFT) - 1)
39 #define BAM_CMATCH 0
41 #define BAM_CINS 1
43 #define BAM_CDEL 2
45 #define BAM_CREF_SKIP 3
47 #define BAM_CSOFT_CLIP 4
50 #define BAM_CHARD_CLIP 5
52 #define BAM_CPAD 6
54 #define BAM_CEQUAL 7
56 #define BAM_CDIFF 8
58 #endif // end of YAT_HAVE_LIBBAM
59 
60 // BAM_CBACK is not defined in old versions of bam.h
61 #ifndef BAM_CBACK
62 #define BAM_CBACK 9
63 #endif
64 
65 // backport #defines from samtools 0.1.19
66 #ifndef BAM_CIGAR_STR
67 #define BAM_CIGAR_STR "MIDNSHP=XB"
68 // lookup table used in bam_cigar_type
69 #define BAM_CIGAR_TYPE 0x3C1A7
70 
72 #define bam_cigar_op(c) ((c)&BAM_CIGAR_MASK)
73 // length of the operation
74 #define bam_cigar_oplen(c) ((c)>>BAM_CIGAR_SHIFT)
75 // char describing the operation, see column 2 in table below
76 #define bam_cigar_opchr(c) (BAM_CIGAR_STR[bam_cigar_op(c)])
77 // Create a cigar element with length l and operation o
78 #define bam_cigar_gen(l, o) ((l)<<BAM_CIGAR_SHIFT|(o))
79 // Returns a two-bits number describing the type of operation. The
80 // first bit, bam_cigar_type & 1, (4th column in table below) is 1 iff
81 // operation consumes query sequence. The second bit, bam_cigar_type &
82 // 2, (3rd column below) is 1 iff operation consumes reference
83 // sequence.
84 #define bam_cigar_type(o) (BAM_CIGAR_TYPE>>((o)<<1)&3)
85 #endif // end of backport
86 
87 namespace theplu {
88 namespace yat {
89 namespace utility {
90 
99  int8_t cigar_table(unsigned char c);
100 
101 }}} // end of namespace utility, yat and theplu
102 
103 #endif // end of file
int8_t cigar_table(unsigned char c)
The Department of Theoretical Physics namespace as we define it.

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14