Skip to content

Commit

Permalink
Fix pass-QC in output FASTQ read names (#923)
Browse files Browse the repository at this point in the history
* Fix pass-QC in output FASTQ read names

See #922
  • Loading branch information
nh13 authored Jul 28, 2023
1 parent e197ce4 commit 6a2a964
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/com/fulcrumgenomics/fastq/DemuxFastqs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ object OutputType extends FgBioEnum[OutputType] {
*/
case class ReadInfo(readNumber: Int, passQc: Boolean, internalControl: Boolean, sampleInfo: String, rest: Seq[String]) {
override def toString: String = {
val leading = f"$readNumber:${if (passQc) "Y" else "N"}:${if (internalControl) 1 else 0}:$sampleInfo"
val leading = f"$readNumber:${if (passQc) "N" else "Y"}:${if (internalControl) 1 else 0}:$sampleInfo"
if (rest.isEmpty) leading else leading + " " + rest.mkString(" ")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ class DemuxFastqsTest extends UnitSpec with OptionValues with ErrorLogLevel {
val standards = FastqStandards()
val rec = baseRec.copy(pairedEnd=true, name="Instrument:RunID:FlowCellID:Lane:Tile:X:Y", comment=Some("1:N:0:SampleNumber")).withReadInfo
val writer = new FastqRecordWriter(output.resolve("prefix"), pairedEnd=true, fastqStandards=standards)
writer.add(rec).header shouldBe "Instrument:RunID:FlowCellID:Lane:Tile:X:Y:SB:MB 1:N:0:SampleNumber"
writer.add(rec).header shouldBe "Instrument:RunID:FlowCellID:Lane:Tile:X:Y:SB:MB 1:Y:0:SampleNumber"
}

it should "set the read name to include the sample barcode for single-end" in {
Expand All @@ -1175,7 +1175,7 @@ class DemuxFastqsTest extends UnitSpec with OptionValues with ErrorLogLevel {
val standards = FastqStandards(includeSampleBarcodes=true)
val rec = baseRec.copy(pairedEnd=true, name="Instrument:RunID:FlowCellID:Lane:Tile:X:Y", comment=Some("1:N:0:SB")).withReadInfo
val writer = new FastqRecordWriter(output.resolve("prefix"), pairedEnd=false, fastqStandards=standards)
writer.add(rec).header shouldBe "Instrument:RunID:FlowCellID:Lane:Tile:X:Y 1:N:0:SB"
writer.add(rec).header shouldBe "Instrument:RunID:FlowCellID:Lane:Tile:X:Y 1:Y:0:SB"
}

it should "set the read name to include the sample barcode for paired end" in {
Expand All @@ -1184,7 +1184,7 @@ class DemuxFastqsTest extends UnitSpec with OptionValues with ErrorLogLevel {
val standards = FastqStandards(includeSampleBarcodes=true)
val rec = baseRec.copy(pairedEnd=true, name="Instrument:RunID:FlowCellID:Lane:Tile:X:Y", comment=Some("1:Y:0:SB1+SB2"), sampleBarcode=Seq("SB1","SB2"), molecularBarcode=Seq("MB1","MB2")).withReadInfo
val writer = new FastqRecordWriter(output.resolve("prefix"), pairedEnd=true, fastqStandards=standards)
writer.add(rec).header shouldBe "Instrument:RunID:FlowCellID:Lane:Tile:X:Y 1:Y:0:SB1+SB2"
writer.add(rec).header shouldBe "Instrument:RunID:FlowCellID:Lane:Tile:X:Y 1:N:0:SB1+SB2"
}

"ReadInfo" should "not be built if there was no comment in the given record when following Illumina standards" in {
Expand Down

0 comments on commit 6a2a964

Please sign in to comment.