yat  0.14.5pre
Cigar.h
1 #ifndef theplu_yat_utility_cigar
2 #define theplu_yat_utility_cigar
3 
4 // $Id: Cigar.h 3417 2015-05-25 01:35:59Z peter $
5 
6 /*
7  Copyright (C) 2014, 2015 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 this program. 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_LIBBAM
32 #include "yat/omic/config_bam.h"
33 #include YAT_SAM_HEADER
34 #else // if sam.h is not available #define CIGAR
35 #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 #endif // end of file

Generated on Tue Sep 26 2017 02:33:29 for yat by  doxygen 1.8.5