source: branches/0.12-stable/yat/utility/Cigar.h @ 3300

Last change on this file since 3300 was 3300, checked in by Peter, 8 years ago

BAM_CBACK is not #defined in older versions of bam.h. refs #810

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1#ifndef theplu_yat_utility_cigar
2#define theplu_yat_utility_cigar
3
4// $Id: Cigar.h 3300 2014-08-20 05:43:27Z peter $
5
6/*
7  Copyright (C) 2014 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_BAM_HEADER
34#else // if bam.h is not available #define CIGAR
35/// describe how CIGAR operation/length is packed into a 32-bit
36#define BAM_CIGAR_SHIFT 4
37/// operation is described in four lowest bits
38#define BAM_CIGAR_MASK  ((1 << BAM_CIGAR_SHIFT) - 1)
39/// \abstract CIGAR: M = match or mismatch
40#define BAM_CMATCH      0
41/// \abstract CIGAR: I = insertion to the reference
42#define BAM_CINS        1
43/// \abstract CIGAR: D = deletion from the reference
44#define BAM_CDEL        2
45/// \abstract CIGAR: N = skip on the reference (e.g. spliced alignment)
46#define BAM_CREF_SKIP   3
47/// \abstract CIGAR: S = clip on the read with clipped sequence
48/// present in qseq
49#define BAM_CSOFT_CLIP  4
50/// \abstract CIGAR: H = clip on the read with clipped sequence trimmed off
51#define BAM_CHARD_CLIP  5
52/// \abstract CIGAR: P = padding
53#define BAM_CPAD        6
54/// \abstract CIGAR: equals = match
55#define BAM_CEQUAL      7
56/// \abstract CIGAR: X = mismatch
57#define BAM_CDIFF       8
58#define BAM_CBACK       9
59#endif // end of YAT_HAVE_LIBBAM
60
61// CBACK is not defined in old versions of bam.h
62#ifndef BAM_CBACK
63#define BAM_CBACK 9
64#endif
65
66// backport #defines from samtools 0.1.19
67#ifndef BAM_CIGAR_STR
68#define BAM_CIGAR_STR "MIDNSHP=XB"
69// lookup table used in bam_cigar_type
70#define BAM_CIGAR_TYPE 0x3C1A7
71
72/// index of operation in range [0, 9], see below.
73#define bam_cigar_op(c) ((c)&BAM_CIGAR_MASK)
74// length of the operation
75#define bam_cigar_oplen(c) ((c)>>BAM_CIGAR_SHIFT)
76// char describing the operation, see column 2 in table below
77#define bam_cigar_opchr(c) (BAM_CIGAR_STR[bam_cigar_op(c)])
78// Create a cigar element with length l and operation o
79#define bam_cigar_gen(l, o) ((l)<<BAM_CIGAR_SHIFT|(o))
80// Returns a two-bits number describing the type of operation. The
81// first bit, bam_cigar_type & 1, (4th column in table below) is 1 iff
82// operation consumes query sequence. The second bit, bam_cigar_type &
83// 2, (3rd column below) is 1 iff operation consumes reference
84// sequence.
85#define bam_cigar_type(o) (BAM_CIGAR_TYPE>>((o)<<1)&3)
86#endif // end of backport
87
88#endif // end of file
Note: See TracBrowser for help on using the repository browser.