Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nh13 committed Sep 1, 2023
1 parent 645bf0d commit 172e0df
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/com/fulcrumgenomics/fastq/FastqToBam.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class FastqToBam
@arg(flag='s', doc="If true, queryname sort the BAM file, otherwise preserve input order.") val sort: Boolean = false,
@arg(flag='u', doc="Tag in which to store molecular barcodes/UMIs.") val umiTag: String = ConsensusTags.UmiBases,
@arg(flag='q', doc="Tag in which to store molecular barcode/UMI qualities.") val umiQualTag: Option[String] = None,
@arg(doc="Store the sample barcode qualities in the QT Tag.") val storeSampleBarcodeQualities: Boolean = false,
@arg(flag='Q', doc="Store the sample barcode qualities in the QT Tag.") val storeSampleBarcodeQualities: Boolean = false,
@arg(flag='n', doc="Extract UMI(s) from read names and prepend to UMIs from reads.") val extractUmisFromReadNames: Boolean = false,
@arg( doc="Read group ID to use in the file header.") val readGroupId: String = "A",
@arg( doc="The name of the sequenced sample.") val sample: String,
Expand Down Expand Up @@ -184,7 +184,7 @@ class FastqToBam

if (sampleBarcode.nonEmpty) rec("BC") = sampleBarcode
if (storeSampleBarcodeQualities && sampleQuals.nonEmpty) rec("QT") = sampleQuals

// Set the UMI on the read depending on whether we got UMIs from the read names, reads or both
(umi, umiFromReadName) match {
case ("", Some(fromName)) => rec(this.umiTag) = fromName
Expand Down
28 changes: 19 additions & 9 deletions src/test/scala/com/fulcrumgenomics/fastq/FastqToBamTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,25 @@ class FastqToBamTest extends UnitSpec {
FastqRecord("q3:2:3:4:5:6:7", "GAACCCTCGA", "CDEFGHIJKL"),
)
val bam = makeTempFile("fastqToBamTest.", ".bam")
new FastqToBam(input = Seq(r1), output = bam, sample = "s", library = "l", readStructures = Seq(rs("3B3M3B+T")), storeSampleBarcodeQualities = true).execute()
val recs = readBamRecs(bam)
recs should have size 3
recs(0).apply[String]("BC") shouldBe "AAA-AAA"
recs(0).apply[String]("QT") shouldBe "ABC GHI"
recs(1).apply[String]("BC") shouldBe "TAA-AAA"
recs(1).apply[String]("QT") shouldBe "BCD HIJ"
recs(2).apply[String]("BC") shouldBe "GAA-TCG"
recs(2).apply[String]("QT") shouldBe "CDE IJK"

Seq(true, false).foreach { storeSampleBarcodeQualities =>
new FastqToBam(input = Seq(r1), output = bam, sample = "s", library = "l", readStructures = Seq(rs("3B3M3B+T")), storeSampleBarcodeQualities = storeSampleBarcodeQualities).execute()
val recs = readBamRecs(bam)
recs should have size 3
recs(0).apply[String]("BC") shouldBe "AAA-AAA"
recs(1).apply[String]("BC") shouldBe "TAA-AAA"
recs(2).apply[String]("BC") shouldBe "GAA-TCG"

if (storeSampleBarcodeQualities) {
recs(0).apply[String]("QT") shouldBe "ABC GHI"
recs(1).apply[String]("QT") shouldBe "BCD HIJ"
recs(2).apply[String]("QT") shouldBe "CDE IJK"
} else {
Range.inclusive(0, 2).foreach { index =>
recs(index).contains("QT") shouldBe false
}
}
}
}

it should "extract UMIs from read names when requested" in {
Expand Down

0 comments on commit 172e0df

Please sign in to comment.