2023-08-26 00:38:38 +08:00
|
|
|
/*********************************************************************************************
|
|
|
|
|
Description: Some useful functions
|
|
|
|
|
|
|
|
|
|
Copyright : All right reserved by NCIC.ICT
|
|
|
|
|
|
|
|
|
|
Author : Zhang Zhonghai
|
|
|
|
|
Date : 2023/08/25
|
|
|
|
|
***********************************************************************************************/
|
|
|
|
|
#ifndef __UTILS_H
|
|
|
|
|
#define __UTILS_H
|
|
|
|
|
|
2024-04-11 13:29:28 +08:00
|
|
|
#include <stdlib.h>
|
2025-09-18 15:09:48 +08:00
|
|
|
#include <stdio.h>
|
2024-04-11 13:29:28 +08:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include "kvec.h"
|
|
|
|
|
|
|
|
|
|
#undef MAX
|
|
|
|
|
#undef MIN
|
|
|
|
|
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
|
|
|
|
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
|
|
|
|
|
2025-09-18 15:09:48 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
|
#define LIKELY(x) __builtin_expect((x), 1)
|
|
|
|
|
#define UNLIKELY(x) __builtin_expect((x), 0)
|
|
|
|
|
#else
|
|
|
|
|
#define LIKELY(x) (x)
|
|
|
|
|
#define UNLIKELY(x) (x)
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-04-11 13:29:28 +08:00
|
|
|
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
|
|
|
|
|
|
|
|
|
#define BUF_SIZE 1048576
|
|
|
|
|
|
|
|
|
|
typedef kvec_t(uint8_t) seq_t;
|
|
|
|
|
typedef kvec_t(seq_t) seq_v;
|
|
|
|
|
|
|
|
|
|
typedef kvec_t(int) qti_t; // query target info type
|
|
|
|
|
typedef kvec_t(qti_t) qti_v;
|
|
|
|
|
|
|
|
|
|
typedef struct { size_t m; uint8_t *addr; } buf_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern const char *BASE;
|
2023-09-03 23:59:24 +08:00
|
|
|
|
|
|
|
|
extern unsigned char nst_nt4_table[256];
|
|
|
|
|
|
2024-04-11 13:29:28 +08:00
|
|
|
// 将碱基字符(ACGTN)转成int编码(0~4)
|
|
|
|
|
void base_char_to_int(char *str);
|
|
|
|
|
|
|
|
|
|
int read_qt_info(qti_v *qti_arr, buf_t *buf, int row_num_to_read, int info_num, FILE *fp);
|
|
|
|
|
|
|
|
|
|
int read_seq(seq_v *seq_arr, buf_t *buf, int row_num_to_read, FILE *fp);
|
2023-08-26 00:38:38 +08:00
|
|
|
|
2025-09-18 15:09:48 +08:00
|
|
|
void write_query_target_sequence(int qlen, const uint8_t *query, int tlen, const uint8_t *target, int h0, int fnum);
|
|
|
|
|
|
2023-08-26 00:38:38 +08:00
|
|
|
#endif
|