From a3f0aa1d5b222bdd22cb8c42bab8a82324f3f916 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Sat, 4 Nov 2017 12:13:38 -0400 Subject: [PATCH] r550: fixed -L issues with secondary and supp aln --- README.md | 6 ++---- format.c | 7 +++++-- main.c | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1f732ca..82af075 100644 --- a/README.md +++ b/README.md @@ -212,10 +212,8 @@ To avoid this issue, you can add option `-L` at the minimap2 command line. This option moves a long CIGAR to the `CG` tag and leaves a fully clipped CIGAR at the SAM CIGAR column. Current tools that don't read CIGAR (e.g. merging and sorting) still work with such BAM records; tools that read CIGAR will -effectively ignore these records. I have pull requests to the SAM spec, htslib, -htsjdk, bedtools2, Rsamtools and igv.js. If they are accepted, future versions -of these tools will seamlessly recognize long-cigar records generated by option -`-L`. +effectively ignore these records. It has been decided that future tools will +will seamlessly recognize long-cigar records generated by option `-L`. **TD;DR**: if you work with ultra-long reads and use tools that only process BAM files, please add option `-L`. diff --git a/format.c b/format.c index 3b5d3f5..4b7df15 100644 --- a/format.c +++ b/format.c @@ -346,8 +346,11 @@ void mm_write_sam2(kstring_t *s, const mm_idx_t *mi, const mm_bseq1_t *t, int se if (n_cigar > max_bam_cigar_op) cigar_in_tag = 1; } - if (cigar_in_tag) mm_sprintf_lite(s, "%dS", t->l_seq); - else write_sam_cigar(s, flag, 0, t->l_seq, r); + if (cigar_in_tag) { + if (flag & 0x100) mm_sprintf_lite(s, "0S"); // secondary alignment + else if (flag & 0x800) mm_sprintf_lite(s, "%dS", r->re - r->rs); // supplementary alignment + else mm_sprintf_lite(s, "%dS", t->l_seq); + } else write_sam_cigar(s, flag, 0, t->l_seq, r); } // write mate positions diff --git a/main.c b/main.c index 0bcfbf3..90f621b 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ #include "mmpriv.h" #include "getopt.h" -#define MM_VERSION "2.3-r546-dirty" +#define MM_VERSION "2.3-r550-dirty" #ifdef __linux__ #include