Skip to content

Commit

Permalink
ZipperBams to produce mate score ("ms") for samtools markdup
Browse files Browse the repository at this point in the history
Fixes: #951
  • Loading branch information
nh13 authored Dec 18, 2023
1 parent 9c475fd commit 6aa20ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/scala/com/fulcrumgenomics/bam/Bams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down

0 comments on commit 6aa20ab

Please sign in to comment.