Fix a bug in indexing process

This commit is contained in:
Zhang Zhonghai 2026-01-07 17:27:02 +08:00
parent 0e7d839b2e
commit ac93233f2f
7 changed files with 18 additions and 33 deletions

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
# Prerequisites
*.d
fastbwa
fastalign
# Object files
*.o

12
.vscode/launch.json vendored
View File

@ -9,7 +9,7 @@
"preLaunchTask": "Build",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/fastbwa",
"program": "${workspaceRoot}/fastalign",
"args": [
"mem",
"-t",
@ -31,10 +31,10 @@
"preLaunchTask": "Build",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/fastbwa",
"program": "${workspaceRoot}/fastalign",
"args": [
"index",
"~/data/reference/human_g1k_v37_decoy.fasta"
"./index/ref.fasta"
],
"cwd": "${workspaceFolder}", //
},
@ -43,7 +43,7 @@
"preLaunchTask": "Build",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/fastbwa",
"program": "${workspaceRoot}/fastalign",
"args": [
"buildkmer",
"~/data/reference/human_g1k_v37_decoy.fasta.256.64.fmt",
@ -56,7 +56,7 @@
"preLaunchTask": "Build",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/fastbwa",
"program": "${workspaceRoot}/fastalign",
"args": [
"shm",
"-Z",
@ -69,7 +69,7 @@
"preLaunchTask": "Build",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/fastbwa",
"program": "${workspaceRoot}/fastalign",
"args": [
"pac2bref",
"~/data1/fmt_ref/human_g1k_v37_decoy.fasta"

View File

@ -1,5 +1,5 @@
CC= gcc
CFLAGS= -g -Wall -Wno-unused-function -mavx2 -O2
CFLAGS= -g -Wall -Wno-unused-function -mavx2 #-O2
WRAP_MALLOC=-DUSE_MALLOC_WRAPPERS
SHOW_PERF= -DSHOW_PERF

2
bwa.h
View File

@ -103,8 +103,6 @@ extern "C" {
bwaidx_t *bwa_idx_load_from_shm(const char *hint);
bwaidx_t *bwa_idx_load_from_disk(const char *hint, int which);
bwaidx_t *bwa_fmtidx_load_from_shm(const char *hint);
bwaidx_t *bwa_ertidx_load_from_shm(const char *hint);
bwaidx_t *bwa_ertidx_load_from_disk(const char *hint);
bwaidx_t *bwa_idx_load(const char *hint, int which);
void bwa_idx_destroy(bwaidx_t *idx);
int bwa_idx2mem(bwaidx_t *idx);

View File

@ -386,16 +386,6 @@ int main_shm(int argc, char *argv[])
if (bwa_shm_test(shm_prefix) == 0)
{
#if 0
bwaidx_t *idx;
if (useERT)
idx = bwa_ertidx_load_from_disk(argv[optind]);
else
idx = bwa_idx_load_from_disk(argv[optind], BWA_IDX_BNS | BWA_IDX_PAC | BWA_IDX_FMT);
if (bwa_shm_stage(idx, shm_prefix, useERT) < 0) {
fprintf(stderr, "[E::%s] failed to stage the index in shared memory\n", __func__);
ret = 1;
}
bwa_idx_destroy(idx);
#else
if (bwa_shm_stage_fmt(argv[optind]) < 0) {

View File

@ -375,11 +375,13 @@ int bwa_idx_build(const char *fa, const char *prefix, int algo_type, int block_s
{ // nucleotide indexing
gzFile fp = xzopen(fa, "r");
t = clock();
start_async_read(fp);
t = clock();
if (bwa_verbose >= 3) fprintf(stderr, "[bwa_index] Pack FASTA... ");
l_pac = bns_fasta2bntseq(fp, prefix, 0);
if (bwa_verbose >= 3) fprintf(stderr, "%.2f sec\n", (float)(clock() - t) / CLOCKS_PER_SEC);
err_gzclose(fp);
stop_async_read(fp);
err_gzclose(fp);
}
if (algo_type == 0) algo_type = l_pac > 50000000? 2 : 3; // set the algorithm for generating BWT
{
@ -409,11 +411,13 @@ int bwa_idx_build(const char *fa, const char *prefix, int algo_type, int block_s
}
{
gzFile fp = xzopen(fa, "r");
t = clock();
start_async_read(fp);
t = clock();
if (bwa_verbose >= 3) fprintf(stderr, "[bwa_index] Pack forward-only FASTA... ");
l_pac = bns_fasta2bntseq(fp, prefix, 1);
if (bwa_verbose >= 3) fprintf(stderr, "%.2f sec\n", (float)(clock() - t) / CLOCKS_PER_SEC);
err_gzclose(fp);
stop_async_read(fp);
err_gzclose(fp);
}
{
bwt_t *bwt;

View File

@ -602,16 +602,9 @@ int main_mem(int argc, char *argv[])
PROF_END(gprof[G_PREPARE], prepare);
PROF_START(idx);
if (useERT) aux.idx = bwa_ertidx_load_from_shm(argv[optind]);
else aux.idx = bwa_fmtidx_load_from_shm(argv[optind]);
aux.idx = bwa_fmtidx_load_from_shm(argv[optind]);
if (aux.idx == 0) {
if (!useERT) {
if ((aux.idx = bwa_idx_load(argv[optind], BWA_IDX_BNS | BWA_IDX_PAC | BWA_IDX_FMT)) == 0) return 1; // FIXME: memory leak
}
else {
if ((aux.idx = bwa_ertidx_load_from_disk(argv[optind])) == 0) return 1; // FIXME: memory leak
}
if ((aux.idx = bwa_idx_load(argv[optind], BWA_IDX_BNS | BWA_IDX_PAC | BWA_IDX_FMT)) == 0) return 1; // FIXME: memory leak
} else if (bwa_verbose >= 3)
fprintf(stderr, "[M::%s] load the bwa index from shared memory\n", __func__);
if (ignore_alt)