Skip to content

Instantly share code, notes, and snippets.

@clintval
Created June 11, 2019 05:53
Show Gist options
  • Select an option

  • Save clintval/9c91ad288bc4e8c7f39f3267c4a507de to your computer and use it in GitHub Desktop.

Select an option

Save clintval/9c91ad288bc4e8c7f39f3267c4a507de to your computer and use it in GitHub Desktop.
/** Implicit methods for [[Template]] objects. */
implicit class TemplateUtil(val t: Template) {
private def tagValue[A](records: Iterator[SamRecord], tag: String): Iterator[Option[A]] = records.map(_.get[A](tag))
def bestEditDistanceToReference(t: Template): Option[Int] = tagValue[Int](t.allReads, SAMTag.NM.name).min
def worstEditDistanceToReference(t: Template): Option[Int] = tagValue[Int](t.allReads, SAMTag.NM.name).max
def bestAlignmentScore(t: Template): Option[Int] = tagValue[Int](t.allReads, SAMTag.AS.name).max
def worstAlignmentScore(t: Template): Option[Int] = tagValue[Int](t.allReads, SAMTag.AS.name).min
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment