r806: polish BAM support
This commit is contained in:
parent
8a230db596
commit
1de61b556e
19
Makefile
19
Makefile
|
|
@ -2,10 +2,9 @@ CC= gcc
|
||||||
#CC= clang --analyze
|
#CC= clang --analyze
|
||||||
CFLAGS= -g -Wall -Wno-unused-function -O2
|
CFLAGS= -g -Wall -Wno-unused-function -O2
|
||||||
WRAP_MALLOC=-DUSE_MALLOC_WRAPPERS
|
WRAP_MALLOC=-DUSE_MALLOC_WRAPPERS
|
||||||
# set to 1 if you wish to have bam support, type 'make clean; make all'
|
HTSLIB_PATH=
|
||||||
USE_HTSLIB=0
|
|
||||||
AR= ar
|
AR= ar
|
||||||
DFLAGS= -DHAVE_PTHREAD $(WRAP_MALLOC)
|
DFLAGS= -DHAVE_PTHREAD $(WRAP_MALLOC)
|
||||||
LOBJS= utils.o kthread.o kstring.o ksw.o bwt.o bntseq.o bwa.o bwamem.o bwamem_pair.o bwamem_extra.o malloc_wrap.o
|
LOBJS= utils.o kthread.o kstring.o ksw.o bwt.o bntseq.o bwa.o bwamem.o bwamem_pair.o bwamem_extra.o malloc_wrap.o
|
||||||
AOBJS= QSufSort.o bwt_gen.o bwase.o bwaseqio.o bwtgap.o bwtaln.o bamlite.o \
|
AOBJS= QSufSort.o bwt_gen.o bwase.o bwaseqio.o bwtgap.o bwtaln.o bamlite.o \
|
||||||
is.o bwtindex.o bwape.o kopen.o pemerge.o \
|
is.o bwtindex.o bwape.o kopen.o pemerge.o \
|
||||||
|
|
@ -13,14 +12,14 @@ AOBJS= QSufSort.o bwt_gen.o bwase.o bwaseqio.o bwtgap.o bwtaln.o bamlite.o \
|
||||||
bwtsw2_chain.o fastmap.o bwtsw2_pair.o
|
bwtsw2_chain.o fastmap.o bwtsw2_pair.o
|
||||||
PROG= bwa
|
PROG= bwa
|
||||||
INCLUDES=
|
INCLUDES=
|
||||||
LIBS= -lm -lz -lpthread
|
LIBS= -lm -lz -lpthread
|
||||||
SUBDIRS= .
|
SUBDIRS= .
|
||||||
|
|
||||||
.SUFFIXES:.c .o .cc
|
.SUFFIXES:.c .o .cc
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
ifeq ($(USE_HTSLIB),1)
|
ifneq ($(HTSLIB_PATH),)
|
||||||
$(CC) -c $(CFLAGS) $(DFLAGS) -DUSE_HTSLIB $(INCLUDES) -I ../htslib $< -o $@
|
$(CC) -c $(CFLAGS) $(DFLAGS) -DUSE_HTSLIB $(INCLUDES) -I$(HTSLIB_PATH) $< -o $@
|
||||||
else
|
else
|
||||||
$(CC) -c $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
|
$(CC) -c $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
|
||||||
endif
|
endif
|
||||||
|
|
@ -28,15 +27,15 @@ endif
|
||||||
all:$(PROG)
|
all:$(PROG)
|
||||||
|
|
||||||
bwa:libbwa.a $(AOBJS) main.o
|
bwa:libbwa.a $(AOBJS) main.o
|
||||||
ifeq ($(USE_HTSLIB),1)
|
ifneq ($(HTSLIB_PATH),)
|
||||||
$(CC) $(CFLAGS) $(DFLAGS) $(AOBJS) main.o -o $@ ../htslib/libhts.a -L. -L../htslib -lbwa $(LIBS)
|
$(CC) $(CFLAGS) $(DFLAGS) $(AOBJS) main.o -o $@ $(HTSLIB_PATH)/libhts.a -L. -lbwa $(LIBS)
|
||||||
else
|
else
|
||||||
$(CC) $(CFLAGS) $(DFLAGS) $(AOBJS) main.o -o $@ -L. -lbwa $(LIBS)
|
$(CC) $(CFLAGS) $(DFLAGS) $(AOBJS) main.o -o $@ -L. -lbwa $(LIBS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
bwamem-lite:libbwa.a example.o
|
bwamem-lite:libbwa.a example.o
|
||||||
ifeq ($(USE_HTSLIB),1)
|
ifneq ($(HTSLIB_PATH),)
|
||||||
$(CC) $(CFLAGS) $(DFLAGS) example.o -o $@ ../htslib/libhts.a -L. -L../htslib -lbwa $(LIBS)
|
$(CC) $(CFLAGS) $(DFLAGS) example.o -o $@ $(HTSLIB_PATH)/libhts.a -L. -lbwa $(LIBS)
|
||||||
else
|
else
|
||||||
$(CC) $(CFLAGS) $(DFLAGS) example.o -o $@ -L. -lbwa $(LIBS)
|
$(CC) $(CFLAGS) $(DFLAGS) example.o -o $@ -L. -lbwa $(LIBS)
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
7
bwamem.c
7
bwamem.c
|
|
@ -1125,7 +1125,7 @@ static void worker2(void *data, int i, int tid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mem_process_seqs(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int64_t n_processed, int n, bseq1_t *seqs, const mem_pestat_t *pes0, bam_hdr_t *h)
|
void mem_process_seqs2(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int64_t n_processed, int n, bseq1_t *seqs, const mem_pestat_t *pes0, bam_hdr_t *h)
|
||||||
{
|
{
|
||||||
extern void kt_for(int n_threads, void (*func)(void*,int,int), void *data, int n);
|
extern void kt_for(int n_threads, void (*func)(void*,int,int), void *data, int n);
|
||||||
worker_t w;
|
worker_t w;
|
||||||
|
|
@ -1157,3 +1157,8 @@ void mem_process_seqs(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bn
|
||||||
if (bwa_verbose >= 3)
|
if (bwa_verbose >= 3)
|
||||||
fprintf(stderr, "[M::%s] Processed %d reads in %.3f CPU sec, %.3f real sec\n", __func__, n, cputime() - ctime, realtime() - rtime);
|
fprintf(stderr, "[M::%s] Processed %d reads in %.3f CPU sec, %.3f real sec\n", __func__, n, cputime() - ctime, realtime() - rtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mem_process_seqs(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int64_t n_processed, int n, bseq1_t *seqs, const mem_pestat_t *pes0)
|
||||||
|
{
|
||||||
|
mem_process_seqs2(opt, bwt, bns, pac, n_processed, n, seqs, pes0, 0);
|
||||||
|
}
|
||||||
|
|
|
||||||
4
bwamem.h
4
bwamem.h
|
|
@ -128,7 +128,8 @@ extern "C" {
|
||||||
* corresponding to each FF, FR, RF and RR orientation. See mem_pestat() for more info.
|
* corresponding to each FF, FR, RF and RR orientation. See mem_pestat() for more info.
|
||||||
* @param h the BAM header, NULL if not using HTSLIB
|
* @param h the BAM header, NULL if not using HTSLIB
|
||||||
*/
|
*/
|
||||||
void mem_process_seqs(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int64_t n_processed, int n, bseq1_t *seqs, const mem_pestat_t *pes0, bam_hdr_t *h);
|
void mem_process_seqs(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int64_t n_processed, int n, bseq1_t *seqs, const mem_pestat_t *pes0);
|
||||||
|
void mem_process_seqs2(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int64_t n_processed, int n, bseq1_t *seqs, const mem_pestat_t *pes0, bam_hdr_t *h);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the aligned regions for one query sequence
|
* Find the aligned regions for one query sequence
|
||||||
|
|
@ -160,7 +161,6 @@ extern "C" {
|
||||||
* @return CIGAR, strand, mapping quality and forward-strand position
|
* @return CIGAR, strand, mapping quality and forward-strand position
|
||||||
*/
|
*/
|
||||||
mem_aln_t mem_reg2aln(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, int l_seq, const char *seq, const mem_alnreg_t *ar);
|
mem_aln_t mem_reg2aln(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, int l_seq, const char *seq, const mem_alnreg_t *ar);
|
||||||
mem_aln_t mem_reg2aln2(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, int l_seq, const char *seq, const mem_alnreg_t *ar, const char *name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Infer the insert size distribution from interleaved alignment regions
|
* Infer the insert size distribution from interleaved alignment regions
|
||||||
|
|
|
||||||
|
|
@ -127,10 +127,8 @@ int main_mem(int argc, char *argv[])
|
||||||
#ifdef USE_HTSLIB
|
#ifdef USE_HTSLIB
|
||||||
} else if (c == 'o') {
|
} else if (c == 'o') {
|
||||||
opt->bam_output = atoi(optarg);
|
opt->bam_output = atoi(optarg);
|
||||||
}
|
|
||||||
#else
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
else return 1;
|
else return 1;
|
||||||
}
|
}
|
||||||
if (opt->n_threads < 1) opt->n_threads = 1;
|
if (opt->n_threads < 1) opt->n_threads = 1;
|
||||||
|
|
@ -280,7 +278,7 @@ int main_mem(int argc, char *argv[])
|
||||||
for (i = 0; i < n; ++i) size += seqs[i].l_seq;
|
for (i = 0; i < n; ++i) size += seqs[i].l_seq;
|
||||||
if (bwa_verbose >= 3)
|
if (bwa_verbose >= 3)
|
||||||
fprintf(stderr, "[M::%s] read %d sequences (%ld bp)...\n", __func__, n, (long)size);
|
fprintf(stderr, "[M::%s] read %d sequences (%ld bp)...\n", __func__, n, (long)size);
|
||||||
mem_process_seqs(opt, idx->bwt, idx->bns, idx->pac, n_processed, n, seqs, pes0, h);
|
mem_process_seqs2(opt, idx->bwt, idx->bns, idx->pac, n_processed, n, seqs, pes0, h);
|
||||||
n_processed += n;
|
n_processed += n;
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
#ifdef USE_HTSLIB
|
#ifdef USE_HTSLIB
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue