Skip to content

Commit

Permalink
refactor: variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
znorgaard committed Dec 16, 2024
1 parent 27b140d commit ca81af8
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions src/main/scala/com/fulcrumgenomics/umi/GroupReadsByUmi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -468,17 +468,17 @@ case class TagFamilySizeMetric(family_size: Int,

/**
* Metrics produced by `GroupReadsByUmi` to describe reads passed through UMI grouping
* @param reads The number of reads accepted for grouping
* @param filteredNonPf The number of non-PF reads
* @param filteredPoorAlignment The number of templates discarded for poor
* @param filteredNsInUmi The number of templates discarded due to one or more Ns in the UMI
* @param filterUmisTooShort The number of templates discarded due to a shorter than expected UMI
* @param sam_records The number of SAM records accepted for grouping.
* @param filtered_non_pf The number of non-PF SAM records.
* @param filtered_poor_alignment The number of SAM records discarded for poor alignment.
* @param filtered_ns_in_umi The number of SAM records discarded due to one or more Ns in the UMI.
* @param filtered_umis_to_short The number of SAM records discarded due to a shorter than expected UMI.
*/
case class UmiGroupingMetric(reads: Long,
filteredNonPf: Long,
filteredPoorAlignment: Long,
filteredNsInUmi: Long,
filterUmisTooShort: Long) extends Metric
case class UmiGroupingMetric(sam_records: Long,
filtered_non_pf: Long,
filtered_poor_alignment: Long,
filtered_ns_in_umi: Long,
filtered_umis_to_short: Long) extends Metric

/** The strategies implemented by [[GroupReadsByUmi]] to identify reads from the same source molecule.*/
sealed trait Strategy extends EnumEntry {
Expand Down Expand Up @@ -758,27 +758,25 @@ class GroupReadsByUmi
Metric.write(p, ms)
}

// Write out UMI grouping metrics
this.groupingMetrics match {
case None => ()
case Some(p) =>
val groupingMetrics = UmiGroupingMetric(
reads = kept,
filteredNonPf = filteredNonPf,
filteredPoorAlignment = filteredPoorAlignment,
filteredNsInUmi = filteredNsInUmi,
filterUmisTooShort = filterUmisTooShort,
)
Metric.write(p, groupingMetrics)
// Write out UMI grouping metrics
this.groupingMetrics.foreach { path =>
val groupingMetrics = UmiGroupingMetric(
sam_records = kept,
filtered_non_pf = filteredNonPf,
filtered_poor_alignment = filteredPoorAlignment,
filtered_ns_in_umi = filteredNsInUmi,
filtered_umis_to_short = filterUmisTooShort,
)
Metric.write(path, groupingMetrics)
}
}

private def logStats(): Unit = {
logger.info(f"Accepted $kept%,d reads for grouping.")
if (filteredNonPf > 0) logger.info(f"Filtered out $filteredNonPf%,d non-PF reads.")
logger.info(f"Filtered out $filteredPoorAlignment%,d reads due to mapping issues.")
logger.info(f"Filtered out $filteredNsInUmi%,d reads that contained one or more Ns in their UMIs.")
this.minUmiLength.foreach { _ => logger.info(f"Filtered out $filterUmisTooShort%,d reads that contained UMIs that were too short.") }
logger.info(f"Accepted $kept%,d SAM records for grouping.")
if (filteredNonPf > 0) logger.info(f"Filtered out $filteredNonPf%,d non-PF SAM records.")
logger.info(f"Filtered out $filteredPoorAlignment%,d SAM records due to mapping issues.")
logger.info(f"Filtered out $filteredNsInUmi%,d SAM records that contained one or more Ns in their UMIs.")
this.minUmiLength.foreach { _ => logger.info(f"Filtered out $filterUmisTooShort%,d SAM records that contained UMIs that were too short.") }
}

/** Consumes the next group of templates with all matching end positions and returns them. */
Expand Down

0 comments on commit ca81af8

Please sign in to comment.