File tree 2 files changed +19
-0
lines changed
main/scala/com/fulcrumgenomics/bam/api
test/scala/com/fulcrumgenomics/bam/api
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ package com.fulcrumgenomics.bam.api
27
27
28
28
import com .fulcrumgenomics .FgBioDef ._
29
29
import com .fulcrumgenomics .alignment .Cigar
30
+ import com .fulcrumgenomics .umi .ConsensusTags .PerRead .AllPerReadTags
30
31
import htsjdk .samtools
31
32
import htsjdk .samtools .SamPairUtil .PairOrientation
32
33
import htsjdk .samtools ._
@@ -269,6 +270,10 @@ trait SamRecord {
269
270
SamPairUtil .getPairOrientation(this ) == PairOrientation .FR
270
271
}
271
272
273
+ def isConsensus : Boolean = {
274
+ AllPerReadTags .exists(this .contains)
275
+ }
276
+
272
277
/** Clone method that does a "reasonably deep" clone. The bases and quals are cloned as is the attributes map,
273
278
* though not the values in the attributes map. */
274
279
override def clone (): SamRecord = {
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ package com.fulcrumgenomics.bam.api
27
27
import com .fulcrumgenomics .alignment .Cigar
28
28
import com .fulcrumgenomics .testing .SamBuilder .{Minus , Plus }
29
29
import com .fulcrumgenomics .testing .{SamBuilder , UnitSpec }
30
+ import com .fulcrumgenomics .umi .ConsensusTags .PerRead .AllPerReadTags
30
31
import htsjdk .samtools .TextCigarCodec
31
32
import org .scalatest .OptionValues
32
33
@@ -289,4 +290,17 @@ class SamRecordTest extends UnitSpec with OptionValues {
289
290
rec1.matesOverlap shouldBe None // Mate's start is not enclosed by rec, and mate's end cannot be determined
290
291
rec2.matesOverlap.value shouldBe true // Mate's start is enclosed by rec, regardless of where mate end is
291
292
}
293
+
294
+ " SamRecord.isConsensus" should " return false for reads without consensus tags" in {
295
+ val builder = new SamBuilder (sort= Some (SamOrder .Coordinate ), readLength= 10 , baseQuality= 20 )
296
+ builder.addFrag(start= 100 ).exists(_.isConsensus) shouldBe false
297
+ builder.addPair(start1= 100 , start2= 100 , unmapped2= true ).exists(_.isConsensus) shouldBe false
298
+ }
299
+
300
+ it should " return true for reads with consensus tags" in {
301
+ val builder = new SamBuilder (sort= Some (SamOrder .Coordinate ), readLength= 10 , baseQuality= 20 )
302
+ AllPerReadTags .forall(
303
+ tag => builder.addFrag(start= 10 , attrs= Map (tag -> 123 )).exists(_.isConsensus)
304
+ ) shouldBe true
305
+ }
292
306
}
You can’t perform that action at this time.
0 commit comments