sw_perf/utils.h

56 lines
1.4 KiB
C
Raw Permalink Normal View History

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
#include <stdlib.h>
2025-09-18 15:09:48 +08:00
#include <stdio.h>
#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
#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;
extern unsigned char nst_nt4_table[256];
// 将碱基字符(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