Skip to content

Commit

Permalink
Merge pull request #39 from satta/gcc-issue
Browse files Browse the repository at this point in the history
move around to_cigar_int
  • Loading branch information
mengyao committed Aug 19, 2016
2 parents c216584 + c341ce2 commit fb2e302
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 28 deletions.
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 @@ -159,32 +159,7 @@ int32_t mark_mismatch (int32_t ref_begin1,
@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

0 comments on commit fb2e302

Please sign in to comment.