source: trunk/yat/utility/Cigar.h @ 3417

Last change on this file since 3417 was 3417, checked in by Peter, 4 years ago

updating copyright statements

  • 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 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/// 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#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
71/// index of operation in range [0, 9], see below.
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
Note: See TracBrowser for help on using the repository browser.