2023-08-26 03:00:15 +08:00
/*********************************************************************************************
2025-09-18 15:09:48 +08:00
Description : stripped sw align functions in bwa - mem
2023-08-26 03:00:15 +08:00
Copyright : All right reserved by NCIC . ICT
Author : Zhang Zhonghai
2025-09-18 15:09:48 +08:00
Date : 2024 / 04 / 11
2023-08-26 03:00:15 +08:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2025-09-18 15:09:48 +08:00
# ifndef __ALIGN_H
# define __ALIGN_H
2023-08-26 03:00:15 +08:00
# include <stdio.h>
2025-09-18 15:09:48 +08:00
# include <emmintrin.h>
# include <immintrin.h>
# include "byte_alloc.h"
2023-08-26 03:00:15 +08:00
2025-09-18 15:09:48 +08:00
# define KSW_XBYTE 0x10000
# define KSW_XSTOP 0x20000
# define KSW_XSUBO 0x40000
# define KSW_XSTART 0x80000
2023-08-26 03:00:15 +08:00
2025-09-18 15:09:48 +08:00
typedef struct
{
int score ; // best score
int te , qe ; // target end and query end
int score2 , te2 ; // second best score and ending position on the target
int tb , qb ; // target start and query start
} kswr_t ;
2023-08-26 03:00:15 +08:00
2025-09-18 15:09:48 +08:00
extern const kswr_t g_defr ;
typedef struct _kswq_t
{
int qlen , slen ;
uint8_t shift , mdiff , max , size ;
__m128i * qp , * H0 , * H1 , * E , * Hmax ;
} kswq_sse_t ;
typedef struct _kswq_avx2_t {
int qlen , slen ;
uint8_t shift , mdiff , max , size ;
__m256i * qp , * H0 , * H1 , * E , * Hmax ;
} kswq_avx2_t ;
# define ALIGN_FUNC_NUM 4
kswq_sse_t * aln_sse_qinit ( byte_mem_t * bmem , int size , int qlen , const uint8_t * query , int m , const int8_t * mat ) ;
kswr_t align_sse_i16 ( byte_mem_t * bmem , kswq_sse_t * q , int tlen , const uint8_t * target , int _o_del , int _e_del , int _o_ins , int _e_ins , int xtra ) ; // the first gap costs -(_o+_e)
kswr_t align_sse_u8 ( byte_mem_t * bmem , kswq_sse_t * q , int tlen , const uint8_t * target , int _o_del , int _e_del , int _o_ins , int _e_ins , int xtra ) ;
kswq_avx2_t * aln_avx2_qinit ( byte_mem_t * bmem , int size , int qlen , const uint8_t * query , int m , const int8_t * mat ) ;
kswr_t align_avx2_u8 ( byte_mem_t * bmem , kswq_avx2_t * q , int tlen , const uint8_t * target , int _o_del , int _e_del , int _o_ins ,
int _e_ins , int xtra ) ;
kswr_t align_avx2_i16 ( byte_mem_t * bmem , kswq_avx2_t * q , int tlen , const uint8_t * target , int _o_del , int _e_del , int _o_ins ,
int _e_ins , int xtra ) ;
int main_align ( int argc , char * argv [ ] ) ;
2023-08-26 03:00:15 +08:00
# endif