From c341ce25740a60966ce50d3e074509dcef231315 Mon Sep 17 00:00:00 2001 From: Sascha Steinbiss Date: Mon, 18 Jul 2016 23:08:54 +0000 Subject: [PATCH] move around to_cigar_int --- src/Makefile | 2 +- src/ssw.c | 31 +++++++++++++++++++++++++++++++ src/ssw.h | 29 ++--------------------------- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/Makefile b/src/Makefile index f726378..f4e763b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ CC = gcc CXX = g++ -CFLAGS := -Wall -pipe -O3 +CFLAGS := -Wall -pipe -O2 CXXFLAGS := $(CFLAGS) LOBJS = ssw.o LCPPOBJS = ssw_cpp.o diff --git a/src/ssw.c b/src/ssw.c index 825c39b..403ae23 100644 --- a/src/ssw.c +++ b/src/ssw.c @@ -529,6 +529,37 @@ static alignment_end* sw_sse2_word (const int8_t* ref, return bests; } +/*! @function Produce CIGAR 32-bit unsigned integer from CIGAR operation and CIGAR length + @param length length of CIGAR + @param op_letter CIGAR operation character ('M', 'I', etc) + @return 32-bit unsigned integer, representing encoded CIGAR operation and length +*/ +uint32_t to_cigar_int (uint32_t length, char op_letter) +{ + switch (op_letter) { + case 'M': /* alignment match (can be a sequence match or mismatch */ + default: + return length << BAM_CIGAR_SHIFT; + case 'S': /* soft clipping (clipped sequences present in SEQ) */ + return (length << BAM_CIGAR_SHIFT) | (4u); + case 'D': /* deletion from the reference */ + return (length << BAM_CIGAR_SHIFT) | (2u); + case 'I': /* insertion to the reference */ + return (length << BAM_CIGAR_SHIFT) | (1u); + case 'H': /* hard clipping (clipped sequences NOT present in SEQ) */ + return (length << BAM_CIGAR_SHIFT) | (5u); + case 'N': /* skipped region from the reference */ + return (length << BAM_CIGAR_SHIFT) | (3u); + case 'P': /* padding (silent deletion from padded reference) */ + return (length << BAM_CIGAR_SHIFT) | (6u); + case '=': /* sequence match */ + return (length << BAM_CIGAR_SHIFT) | (7u); + case 'X': /* sequence mismatch */ + return (length << BAM_CIGAR_SHIFT) | (8u); + } + return (uint32_t)-1; // This never happens +} + static cigar* banded_sw (const int8_t* ref, const int8_t* read, int32_t refLen, diff --git a/src/ssw.h b/src/ssw.h index 685ecf3..fe00cec 100644 --- a/src/ssw.h +++ b/src/ssw.h @@ -22,7 +22,7 @@ extern "C" { #define MAPSTR "MIDNSHP=X" #ifndef BAM_CIGAR_SHIFT -#define BAM_CIGAR_SHIFT 4 +#define BAM_CIGAR_SHIFT 4u #endif @@ -134,32 +134,7 @@ void align_destroy (s_align* a); @param op_letter CIGAR operation character ('M', 'I', etc) @return 32-bit unsigned integer, representing encoded CIGAR operation and length */ -static inline uint32_t to_cigar_int (uint32_t length, char op_letter) -{ - switch (op_letter) { - case 'M': /* alignment match (can be a sequence match or mismatch */ - default: - return length << BAM_CIGAR_SHIFT; - case 'S': /* soft clipping (clipped sequences present in SEQ) */ - return (length << BAM_CIGAR_SHIFT) | (4u); - case 'D': /* deletion from the reference */ - return (length << BAM_CIGAR_SHIFT) | (2u); - case 'I': /* insertion to the reference */ - return (length << BAM_CIGAR_SHIFT) | (1u); - case 'H': /* hard clipping (clipped sequences NOT present in SEQ) */ - return (length << BAM_CIGAR_SHIFT) | (5u); - case 'N': /* skipped region from the reference */ - return (length << BAM_CIGAR_SHIFT) | (3u); - case 'P': /* padding (silent deletion from padded reference) */ - return (length << BAM_CIGAR_SHIFT) | (6u); - case '=': /* sequence match */ - return (length << BAM_CIGAR_SHIFT) | (7u); - case 'X': /* sequence mismatch */ - return (length << BAM_CIGAR_SHIFT) | (8u); - } - return (uint32_t)-1; // This never happens -} - +uint32_t to_cigar_int (uint32_t length, char op_letter); /*! @function Extract CIGAR operation character from CIGAR 32-bit unsigned integer @param cigar_int 32-bit unsigned integer, representing encoded CIGAR operation and length