Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move around to_cigar_int #39

Merged
merged 1 commit into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
31 changes: 31 additions & 0 deletions src/ssw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 2 additions & 27 deletions src/ssw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down