Skip to content

Commit

Permalink
optionally write XB to include alignment score
Browse files Browse the repository at this point in the history
request from 4DN-DCIC
  • Loading branch information
lh3 committed Apr 2, 2018
1 parent a9c688a commit eb7dbc1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion bwamem.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,10 @@ void mem_aln2sam(const mem_opt_t *opt, const bntseq_t *bns, kstring_t *str, bseq
if (p->alt_sc > 0)
ksprintf(str, "\tpa:f:%.3f", (double)p->score / p->alt_sc);
}
if (p->XA) { kputsn("\tXA:Z:", 6, str); kputs(p->XA, str); }
if (p->XA) {
kputsn((opt->flag&MEM_F_XB)? "\tXB:Z:" : "\tXA:Z:", 6, str);
kputs(p->XA, str);
}
if (s->comment) { kputc('\t', str); kputs(s->comment, str); }
if ((opt->flag&MEM_F_REF_HDR) && p->rid >= 0 && bns->anns[p->rid].anno != 0 && bns->anns[p->rid].anno[0] != 0) {
int tmp;
Expand Down
1 change: 1 addition & 0 deletions bwamem.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ typedef struct __smem_i smem_i;
#define MEM_F_SOFTCLIP 0x200
#define MEM_F_SMARTPE 0x400
#define MEM_F_PRIMARY5 0x800
#define MEM_F_XB 0x1000

typedef struct {
int a, b; // match score and mismatch penalty
Expand Down
4 changes: 4 additions & 0 deletions bwamem_extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ char **mem_gen_alt(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac
kputc("MIDSHN"[t.cigar[k]&0xf], &str);
}
kputc(',', &str); kputw(t.NM, &str);
if (opt->flag & MEM_F_XB) {
kputc(',', &str);
kputw(t.score, &str);
}
kputc(';', &str);
free(t.cigar);
kputsn(str.s, str.l, &aln[r]);
Expand Down
3 changes: 2 additions & 1 deletion fastmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ int main_mem(int argc, char *argv[])

aux.opt = opt = mem_opt_init();
memset(&opt0, 0, sizeof(mem_opt_t));
while ((c = getopt(argc, argv, "51paMCSPVYjk:c:v:s:r:t:R:A:B:O:E:U:w:L:d:T:Q:D:m:I:N:o:f:W:x:G:h:y:K:X:H:")) >= 0) {
while ((c = getopt(argc, argv, "51paMCSPVYjuk:c:v:s:r:t:R:A:B:O:E:U:w:L:d:T:Q:D:m:I:N:o:f:W:x:G:h:y:K:X:H:")) >= 0) {
if (c == 'k') opt->min_seed_len = atoi(optarg), opt0.min_seed_len = 1;
else if (c == '1') no_mt_io = 1;
else if (c == 'x') mode = optarg;
Expand All @@ -148,6 +148,7 @@ int main_mem(int argc, char *argv[])
else if (c == 'Y') opt->flag |= MEM_F_SOFTCLIP;
else if (c == 'V') opt->flag |= MEM_F_REF_HDR;
else if (c == '5') opt->flag |= MEM_F_PRIMARY5;
else if (c == 'u') opt->flag |= MEM_F_XB;
else if (c == 'c') opt->max_occ = atoi(optarg), opt0.max_occ = 1;
else if (c == 'd') opt->zdrop = atoi(optarg), opt0.zdrop = 1;
else if (c == 'v') bwa_verbose = atoi(optarg);
Expand Down

0 comments on commit eb7dbc1

Please sign in to comment.