From 6aa20abfdc93bb58f135c8b00a2aee389f7eb93a Mon Sep 17 00:00:00 2001 From: Nils Homer Date: Mon, 18 Dec 2023 16:59:48 -0700 Subject: [PATCH] ZipperBams to produce mate score ("ms") for samtools markdup Fixes: #951 --- src/main/scala/com/fulcrumgenomics/bam/Bams.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/fulcrumgenomics/bam/Bams.scala b/src/main/scala/com/fulcrumgenomics/bam/Bams.scala index 61d6d52aa..8a422e468 100644 --- a/src/main/scala/com/fulcrumgenomics/bam/Bams.scala +++ b/src/main/scala/com/fulcrumgenomics/bam/Bams.scala @@ -105,16 +105,21 @@ case class Template(r1: Option[SamRecord], Template(x1, x2) } - /** Fixes mate information and sets mate cigar on all primary and supplementary (but not secondary) records. */ + /** Fixes mate information and sets mate cigar and mate score on all primary and supplementary (but not secondary) records. */ def fixMateInfo(): Unit = { + // Developer note: the mate score ("ms") tag is used by samtools markdup for (primary <- r1; supp <- r2Supplementals) { SamPairUtil.setMateInformationOnSupplementalAlignment(supp.asSam, primary.asSam, true) + supp("ms") = primary[Int]("AS") } for (primary <- r2; supp <- r1Supplementals) { SamPairUtil.setMateInformationOnSupplementalAlignment(supp.asSam, primary.asSam, true) + supp("ms") = primary[Int]("AS") } for (first <- r1; second <- r2) { SamPairUtil.setMateInfo(first.asSam, second.asSam, true) + first("ms") = second[Int]("AS") + second("ms") = first[Int]("AS") } }