Skip to content

Commit

Permalink
refactor: rename isConsensusRead to isFgbioStyleConsensus
Browse files Browse the repository at this point in the history
  • Loading branch information
znorgaard committed Jul 24, 2024
1 parent 04a51e9 commit ea80c6c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class CollectDuplexSeqMetrics
"prior to consensus calling. The UMI-grouped BAM is the output of running GroupReadsByUmi." +
s"\nFirst record in $input has consensus SAM tags present:\n$rec"

if (Umis.isConsensusRead(rec)) throw new IllegalArgumentException(exceptionString)
if (Umis.isFgbioStyleConsensus(rec)) throw new IllegalArgumentException(exceptionString)
}
val iterator = intervals match {
case None => _filteredIterator
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/fulcrumgenomics/umi/Umis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ object Umis {
* @param rec the record to test
* @return boolean indicating if the record is a consensus or not
*/
def isConsensusRead(rec: SamRecord): Boolean = {
def isFgbioStyleConsensus(rec: SamRecord): Boolean = {
rec.contains(ConsensusTags.PerRead.RawReadCount) ||
(rec.contains(ConsensusTags.PerRead.AbRawReadCount) && rec.contains(ConsensusTags.PerRead.BaRawReadCount))
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/scala/com/fulcrumgenomics/umi/UmisTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ class UmisTest extends UnitSpec with OptionValues {

"Umis.isConsensusRead" should "return false for reads without consensus tags" in {
val builder = new SamBuilder(sort=Some(SamOrder.Coordinate), readLength=10, baseQuality=20)
builder.addFrag(start=100).exists(Umis.isConsensusRead) shouldBe false
builder.addPair(start1=100, start2=100, unmapped2=true).exists(Umis.isConsensusRead) shouldBe false
builder.addFrag(start=100).exists(Umis.isFgbioStyleConsensus) shouldBe false
builder.addPair(start1=100, start2=100, unmapped2=true).exists(Umis.isFgbioStyleConsensus) shouldBe false
}

it should "return true for reads with consensus tags" in {
val builder = new SamBuilder(sort=Some(SamOrder.Coordinate), readLength=10, baseQuality=20)
builder.addFrag(start=10, attrs=Map(ConsensusTags.PerRead.RawReadCount -> 10))
.exists(Umis.isConsensusRead) shouldBe true
.exists(Umis.isFgbioStyleConsensus) shouldBe true
builder.addFrag(
start=10,
attrs=Map(ConsensusTags.PerRead.AbRawReadCount -> 10, ConsensusTags.PerRead.BaRawReadCount -> 10)
).exists(Umis.isConsensusRead) shouldBe true
).exists(Umis.isFgbioStyleConsensus) shouldBe true
}
}

0 comments on commit ea80c6c

Please sign in to comment.