]> git.kaiwu.me - klib.git/commitdiff
added brief documentation
authorHeng Li <lh3@live.co.uk>
Sun, 11 Sep 2011 02:15:51 +0000 (22:15 -0400)
committerHeng Li <lh3@live.co.uk>
Sun, 11 Sep 2011 02:15:51 +0000 (22:15 -0400)
ksw.c
ksw.h

diff --git a/ksw.c b/ksw.c
index 50353a69eddbaf257921ec0d2cd1f9336ae6c39d..79f7a94ad9cc13e737c97fa1387470526ac13a9e 100644 (file)
--- a/ksw.c
+++ b/ksw.c
@@ -94,7 +94,7 @@ int ksw_sse2_16(ksw_query_t *q, int tlen, const uint8_t *target, ksw_aux_t *a) /
 {
        int slen, i, sum, m_b, n_b, te = -1, gmax = 0;
        uint64_t *b;
-       __m128i zero, gapoe, gape, shift, reduce, *H0, *H1, *E, *Hmax;
+       __m128i zero, gapoe, gape, shift, *H0, *H1, *E, *Hmax;
 
 #define __max_16(ret, xx) do { \
                (xx) = _mm_max_epu8((xx), _mm_srli_si128((xx), 8)); \
@@ -110,7 +110,6 @@ int ksw_sse2_16(ksw_query_t *q, int tlen, const uint8_t *target, ksw_aux_t *a) /
        gapoe = _mm_set1_epi8(a->gapo + a->gape);
        gape = _mm_set1_epi8(a->gape);
        shift = _mm_set1_epi8(q->shift);
-       reduce = _mm_set1_epi8(127);
        H0 = q->H0; H1 = q->H1; E = q->E; Hmax = q->Hmax;
        slen = q->slen;
        for (i = 0; i < slen; ++i) {
@@ -159,10 +158,10 @@ int ksw_sse2_16(ksw_query_t *q, int tlen, const uint8_t *target, ksw_aux_t *a) /
                                h = _mm_subs_epu8(h, gapoe);
                                f = _mm_subs_epu8(f, gape);
                                cmp = _mm_movemask_epi8(_mm_cmpeq_epi8(_mm_subs_epu8(f, h), zero));
-                               if (UNLIKELY(cmp == 0xffff)) goto end_loop;
+                               if (UNLIKELY(cmp == 0xffff)) goto end_loop16;
                        }
                }
-end_loop:
+end_loop16:
                //int k;for (k=0;k<16;++k)printf("%d ", ((uint8_t*)&max)[k]);printf("\n");
                __max_16(imax, max); // imax is the maximum number in max
                if (imax >= a->T) { // write the b array; this condition adds branching unfornately
diff --git a/ksw.h b/ksw.h
index 8307cccbd6c587e4ce60f2fc4960eab88bb5e085..d93d6a91ccd27c8bfd126e3b64eb0d4a9d325769 100644 (file)
--- a/ksw.h
+++ b/ksw.h
@@ -16,8 +16,36 @@ typedef struct {
 extern "C" {
 #endif
 
-ksw_query_t *ksw_qinit(int p, int qlen, const uint8_t *query, int m, const int8_t *mat); // to free, simply call free()
-int ksw_sse2_16(ksw_query_t *q, int tlen, const uint8_t *target, ksw_aux_t *a);
+       /**
+        * Initialize the query data structure
+        *
+        * @param size   Number of bytes used to store a score; valid valures are 1 or 2
+        * @param qlen   Length of the query sequence
+        * @param query  Query sequence
+        * @param m      Size of the alphabet
+        * @param mat    Scoring matrix in a one-dimension array
+        *
+        * @return       Query data structure
+        */
+       ksw_query_t *ksw_qinit(int size, int qlen, const uint8_t *query, int m, const int8_t *mat); // to free, simply call free()
+
+       /**
+        * Compute the maximum local score for queries initialized with ksw_qinit(1, ...)
+        *
+        * @param q       Query data structure returned by ksw_qinit(1, ...)
+        * @param tlen    Length of the target sequence
+        * @param target  Target sequence
+        * @param a       Auxiliary data structure (see ksw.h)
+        *
+        * @return        The maximum local score; if the returned value equals 255, the SW may not be finished
+        */
+       int ksw_sse2_8(ksw_query_t *q, int tlen, const uint8_t *target, ksw_aux_t *a);
+
+       /** Compute the maximum local score for queries initialized with ksw_qinit(2, ...) */
+       int ksw_sse2_16(ksw_query_t *q, int tlen, const uint8_t *target, ksw_aux_t *a);
+
+       /** Unified interface for ksw_sse2_8() and ksw_sse2_16() */
+       int ksw_sse2(ksw_query_t *q, int tlen, const uint8_t *target, ksw_aux_t *a);
 
 #ifdef __cplusplus
 }