From 74df425b822e378c316fdad2fa811e6f0d2d389f Mon Sep 17 00:00:00 2001 From: Mark Tomko <610104+mtomko@users.noreply.github.com> Date: Tue, 29 Aug 2023 08:57:56 -0700 Subject: [PATCH] Updates (#22) --- CHANGELOG.md | 3 + build.sbt | 19 +- project/build.properties | 2 +- project/plugins.sbt | 12 +- .../gpp/poolq3/PoolQConfig.scala | 298 +++++++++--------- .../gpp/poolq3/parser/BarcodeSet.scala | 7 +- .../gpp/poolq3/parser/ReferenceData.scala | 7 +- .../gpp/poolq3/process/ScoringConsumer.scala | 5 +- .../reports/UnexpectedSequenceWriter.scala | 4 +- .../poolq3/barcode/BarcodePolicyTest.scala | 47 +-- .../gpp/poolq3/barcode/KeyMaskTest.scala | 16 +- .../gpp/poolq3/barcode/KeyMaskTest2.scala | 11 +- .../gpp/poolq3/barcode/KeyRangeTest.scala | 32 +- .../poolq3/barcode/TemplatePolicyTest.scala | 12 +- .../hist/OpenHashMapHistogramTest.scala | 10 +- .../poolq3/hist/ShardedHistogramTest.scala | 12 +- .../gpp/poolq3/hist/TupleHistogramTest.scala | 10 +- .../integration/AmbiguousMatchTest.scala | 52 +-- .../integration/LongBarcodeMatchTest.scala | 12 +- .../integration/UnambiguousMatchTest.scala | 52 +-- .../integration/UnambiguousVariantTest.scala | 6 +- .../legacy/LegacyIntegrationTest.scala | 20 +- .../poolq3/numeric/NumericPackageTest.scala | 6 +- .../gpp/poolq3/parser/FastqParserTest.scala | 2 +- .../gpp/poolq3/parser/ReferenceDataTest.scala | 2 +- .../gpp/poolq3/reference/BkTreeTest.scala | 4 +- .../poolq3/reference/ExactReferenceTest.scala | 18 +- .../reference/VariantReferenceTest.scala | 18 +- .../poolq3/reports/BarcodeCountsTest.scala | 24 +- .../poolq3/reports/CorrelationFileTest.scala | 6 +- .../gpp/poolq3/reports/CountsTest.scala | 26 +- .../poolq3/reports/RunInfoWriterTest.scala | 2 +- .../gpp/poolq3/reports/UmiQualityTest.scala | 2 +- .../UnexpectedSequenceFileWriterTest.scala | 2 +- .../reports/UnexpectedSequencesTest.scala | 4 +- .../gpp/poolq3/seq/SeqPackageTest.scala | 20 +- .../gpp/poolq3/testutil/package.scala | 4 +- 37 files changed, 406 insertions(+), 383 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f5fabd..4f43946 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3.6.4 +No user-facing changes + ## 3.6.3 * Documentation for processing demultiplexed FASTQ files diff --git a/build.sbt b/build.sbt index d85072e..dce716e 100644 --- a/build.sbt +++ b/build.sbt @@ -2,34 +2,33 @@ val artifactId = "poolq" inThisBuild( List( - scalaVersion := "2.13.10", + scalaVersion := "2.13.11", semanticdbEnabled := true, semanticdbVersion := scalafixSemanticdb.revision, - scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0", versionScheme := Some("early-semver") ) ) lazy val versions = new { val acyclic = "0.2.1" - val betterFiles = "3.9.1" + val betterFiles = "3.9.2" val betterMonadicFor = "0.3.1" - val catsEffect3 = "3.4.5" - val cats = "2.9.0" - val commonsIo = "2.11.0" + val catsEffect3 = "3.5.1" + val cats = "2.10.0" + val commonsIo = "2.13.0" val commonsText = "1.10.0" val commonsMath3 = "3.6.1" - val fastutil = "8.5.11" - val fs2 = "3.5.0" + val fastutil = "8.5.12" + val fs2 = "3.8.0" val kantanCodecs = "0.5.3" val kantanCsv = "0.7.0" val log4s = "1.10.0" val logback = "1.2.11" val munit = "0.7.29" val munitCatsEffect3 = "1.0.7" - val samTools = "3.0.4" + val samTools = "3.0.5" val scalaCheck = "1.17.0" - val scalaTest = "3.2.15" + val scalaTest = "3.2.16" val scalaTestPlusScalaCheck = "3.2.2.0" val scopt = "4.1.0" val slf4j = "1.7.36" diff --git a/project/build.properties b/project/build.properties index 46e43a9..3040987 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.2 +sbt.version=1.9.4 diff --git a/project/plugins.sbt b/project/plugins.sbt index d6f5adc..b686cc6 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,11 +1,11 @@ -addSbtPlugin("ch.epfl.scala" % "sbt-missinglink" % "0.3.3") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.4") +addSbtPlugin("ch.epfl.scala" % "sbt-missinglink" % "0.3.6") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.0") addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") -addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") +addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.3.1") addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.9.0") -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.1") +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0") +addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.8") diff --git a/src/main/scala/org/broadinstitute/gpp/poolq3/PoolQConfig.scala b/src/main/scala/org/broadinstitute/gpp/poolq3/PoolQConfig.scala index f306821..8a55b51 100644 --- a/src/main/scala/org/broadinstitute/gpp/poolq3/PoolQConfig.scala +++ b/src/main/scala/org/broadinstitute/gpp/poolq3/PoolQConfig.scala @@ -118,185 +118,191 @@ object PoolQConfig { else if (!Files.isReadable(f)) failure(s"Could not read ${f.toAbsolutePath}") else success - head(BuildInfo.name, BuildInfo.version) - - opt[Path]("row-reference") - .valueName("") - .required() - .action((f, c) => c.copy(input = c.input.copy(rowReference = f))) - .text("reference file for row barcodes (i.e., constructs)") - .validate(existsAndIsReadable) - - opt[Path]("col-reference") - .valueName("") - .required() - .action((f, c) => c.copy(input = c.input.copy(colReference = f))) - .text("reference file for column barcodes (i.e., conditions)") - .validate(existsAndIsReadable) - - opt[File]("umi-reference").valueName("").action { (f, c) => - c.copy(input = c.input.copy(umiReference = Some(f.toPath))) - } + locally { + val _ = head(BuildInfo.name, BuildInfo.version) + + val _ = opt[Path]("row-reference") + .valueName("") + .required() + .action((f, c) => c.copy(input = c.input.copy(rowReference = f))) + .text("reference file for row barcodes (i.e., constructs)") + .validate(existsAndIsReadable) + + val _ = opt[Path]("col-reference") + .valueName("") + .required() + .action((f, c) => c.copy(input = c.input.copy(colReference = f))) + .text("reference file for column barcodes (i.e., conditions)") + .validate(existsAndIsReadable) + + val _ = opt[File]("umi-reference").valueName("").action { (f, c) => + c.copy(input = c.input.copy(umiReference = Some(f.toPath))) + } - opt[File]("global-reference").valueName("").action { (f, c) => - c.copy(input = c.input.copy(globalReference = Some(f.toPath))) - } + val _ = opt[File]("global-reference").valueName("").action { (f, c) => + c.copy(input = c.input.copy(globalReference = Some(f.toPath))) + } - opt[(Path, List[Path])]("row-reads") - .valueName("") - .action { case ((p, ps), c) => c.copy(input = c.input.copy(rowReads = Some(p), addlRowReads = ps)) } - .text("required if reads are split between two files") - .validate { case (p, ps) => (p :: ps).traverse_(existsAndIsReadable) } + val _ = opt[(Path, List[Path])]("row-reads") + .valueName("") + .action { case ((p, ps), c) => c.copy(input = c.input.copy(rowReads = Some(p), addlRowReads = ps)) } + .text("required if reads are split between two files") + .validate { case (p, ps) => (p :: ps).traverse_(existsAndIsReadable) } + + val _ = opt[(Path, List[Path])]("rev-row-reads") + .valueName("") + .action { case ((p, ps), c) => + c.copy(input = c.input.copy(reverseRowReads = Some(p), addlReverseRowReads = ps)) + } + .text("required for processing paired-end sequencing data") + .validate { case (p, ps) => (p :: ps).traverse_(existsAndIsReadable) } + + val _ = opt[(Path, List[Path])]("col-reads") + .valueName("") + .action { case ((p, ps), c) => c.copy(input = c.input.copy(colReads = Some(p), addlColReads = ps)) } + .text("required if reads are split between two files") + .validate { case (p, ps) => (p :: ps).traverse_(existsAndIsReadable) } + + val _ = opt[(Path, List[Path])]("reads") + .valueName("") + .action { case ((p, ps), c) => c.copy(input = c.input.copy(reads = Some(p), addlReads = ps)) } + .text("required if reads are contained in a single file") + .validate { case (p, ps) => (p :: ps).traverse_(existsAndIsReadable) } + + val _ = opt[ReadIdCheckPolicy]("read-id-check-policy") + .valueName("") + .action((p, c) => c.copy(input = c.input.copy(readIdCheckPolicy = p))) + .text("read ID check policy; one of [lax, strict, illumina]") + + val _ = opt[String]("row-matcher") + .valueName("") + .action((m, c) => c.copy(rowMatchFn = m)) + .text("function used to match row barcodes against the row reference database") + + val _ = opt[String]("col-matcher") + .valueName("") + .action((m, c) => c.copy(colMatchFn = m)) + .text("function used to match column barcodes against the column reference database") + + val _ = opt[Boolean]("count-ambiguous") + .action((b, c) => c.copy(countAmbiguous = b)) + .text("when true, counts ambiguous fuzzy matches for all potential row barcodes") + + val _ = opt[String]("row-barcode-policy").valueName("").action { (p, c) => + c.copy(rowBarcodePolicyStr = p) + } - opt[(Path, List[Path])]("rev-row-reads") - .valueName("") - .action { case ((p, ps), c) => - c.copy(input = c.input.copy(reverseRowReads = Some(p), addlReverseRowReads = ps)) + val _ = opt[String]("rev-row-barcode-policy").valueName("").action { (p, c) => + c.copy(reverseRowBarcodePolicyStr = Some(p)) } - .text("required for processing paired-end sequencing data") - .validate { case (p, ps) => (p :: ps).traverse_(existsAndIsReadable) } - - opt[(Path, List[Path])]("col-reads") - .valueName("") - .action { case ((p, ps), c) => c.copy(input = c.input.copy(colReads = Some(p), addlColReads = ps)) } - .text("required if reads are split between two files") - .validate { case (p, ps) => (p :: ps).traverse_(existsAndIsReadable) } - - opt[(Path, List[Path])]("reads") - .valueName("") - .action { case ((p, ps), c) => c.copy(input = c.input.copy(reads = Some(p), addlReads = ps)) } - .text("required if reads are contained in a single file") - .validate { case (p, ps) => (p :: ps).traverse_(existsAndIsReadable) } - - opt[ReadIdCheckPolicy]("read-id-check-policy") - .valueName("") - .action((p, c) => c.copy(input = c.input.copy(readIdCheckPolicy = p))) - .text("read ID check policy; one of [lax, strict, illumina]") - - opt[String]("row-matcher") - .valueName("") - .action((m, c) => c.copy(rowMatchFn = m)) - .text("function used to match row barcodes against the row reference database") - - opt[String]("col-matcher") - .valueName("") - .action((m, c) => c.copy(colMatchFn = m)) - .text("function used to match column barcodes against the column reference database") - - opt[Boolean]("count-ambiguous") - .action((b, c) => c.copy(countAmbiguous = b)) - .text("when true, counts ambiguous fuzzy matches for all potential row barcodes") - - opt[String]("row-barcode-policy").valueName("").action { (p, c) => - c.copy(rowBarcodePolicyStr = p) - } - opt[String]("rev-row-barcode-policy").valueName("").action { (p, c) => - c.copy(reverseRowBarcodePolicyStr = Some(p)) - } + val _ = opt[String]("col-barcode-policy").valueName("").action { (p, c) => + c.copy(colBarcodePolicyStr = p) + } - opt[String]("col-barcode-policy").valueName("").action { (p, c) => - c.copy(colBarcodePolicyStr = p) - } + val _ = opt[String]("umi-barcode-policy").valueName("").action { (p, c) => + c.copy(umiBarcodePolicyStr = Some(p)) + } - opt[String]("umi-barcode-policy").valueName("").action { (p, c) => - c.copy(umiBarcodePolicyStr = Some(p)) - } + val _ = opt[Path]("umi-counts-dir").valueName("").action { (f, c) => + c.copy(output = c.output.copy(umiCountsFilesDir = Some(f))) + } - opt[Path]("umi-counts-dir").valueName("").action { (f, c) => - c.copy(output = c.output.copy(umiCountsFilesDir = Some(f))) - } + val _ = opt[Path]("umi-barcode-counts-dir").valueName("").action { (f, c) => + c.copy(output = c.output.copy(umiBarcodeCountsFilesDir = Some(f))) + } - opt[Path]("umi-barcode-counts-dir").valueName("").action { (f, c) => - c.copy(output = c.output.copy(umiBarcodeCountsFilesDir = Some(f))) - } + val _ = + opt[Path]("quality").valueName("").action((f, c) => c.copy(output = c.output.copy(qualityFile = f))) - opt[Path]("quality").valueName("").action((f, c) => c.copy(output = c.output.copy(qualityFile = f))) + val _ = opt[Path]("counts").valueName("").action((f, c) => c.copy(output = c.output.copy(countsFile = f))) - opt[Path]("counts").valueName("").action((f, c) => c.copy(output = c.output.copy(countsFile = f))) + val _ = opt[Path]("normalized-counts").valueName("").action { (f, c) => + c.copy(output = c.output.copy(normalizedCountsFile = f)) + } - opt[Path]("normalized-counts").valueName("").action { (f, c) => - c.copy(output = c.output.copy(normalizedCountsFile = f)) - } + val _ = opt[Path]("barcode-counts").valueName("").action { (f, c) => + c.copy(output = c.output.copy(barcodeCountsFile = f)) + } - opt[Path]("barcode-counts").valueName("").action { (f, c) => - c.copy(output = c.output.copy(barcodeCountsFile = f)) - } + val _ = opt[Path]("scores").valueName("").action((f, c) => c.copy(output = c.output.copy(countsFile = f))) - opt[Path]("scores").valueName("").action((f, c) => c.copy(output = c.output.copy(countsFile = f))) + val _ = opt[Path]("normalized-scores").valueName("").action { (f, c) => + c.copy(output = c.output.copy(normalizedCountsFile = f)) + } - opt[Path]("normalized-scores").valueName("").action { (f, c) => - c.copy(output = c.output.copy(normalizedCountsFile = f)) - } + val _ = opt[Path]("barcode-scores").valueName("").action { (f, c) => + c.copy(output = c.output.copy(barcodeCountsFile = f)) + } - opt[Path]("barcode-scores").valueName("").action { (f, c) => - c.copy(output = c.output.copy(barcodeCountsFile = f)) - } + val _ = opt[Path]("correlation").valueName("").action { (f, c) => + c.copy(output = c.output.copy(correlationFile = f)) + } - opt[Path]("correlation").valueName("").action { (f, c) => - c.copy(output = c.output.copy(correlationFile = f)) - } + val _ = + opt[Path]("run-info").valueName("").action((f, c) => c.copy(output = c.output.copy(runInfoFile = f))) - opt[Path]("run-info").valueName("").action((f, c) => c.copy(output = c.output.copy(runInfoFile = f))) + val _ = opt[Int]("unexpected-sequence-threshold") + .valueName("") + .action((n, c) => c.copy(unexpectedSequencesToReport = n)) + .validate { n => + if (n > 0) success + else failure(s"Unexpected sequence threshold must be greater than 0, got: $n") + } - opt[Int]("unexpected-sequence-threshold") - .valueName("") - .action((n, c) => c.copy(unexpectedSequencesToReport = n)) - .validate { n => - if (n > 0) success - else failure(s"Unexpected sequence threshold must be greater than 0, got: $n") + val _ = opt[Path]("unexpected-sequences").valueName("").action { (f, c) => + c.copy(output = c.output.copy(unexpectedSequencesFile = f)) } - opt[Path]("unexpected-sequences").valueName("").action { (f, c) => - c.copy(output = c.output.copy(unexpectedSequencesFile = f)) - } + val _ = opt[Path]("umi-quality").valueName("").action { (f, c) => + c.copy(output = c.output.copy(umiQualityFile = f)) + } - opt[Path]("umi-quality").valueName("").action { (f, c) => - c.copy(output = c.output.copy(umiQualityFile = f)) - } + val _ = opt[Path]("unexpected-sequence-cache").valueName("").action { (f, c) => + c.copy(unexpectedSequenceCacheDir = Some(f)) + } - opt[Path]("unexpected-sequence-cache").valueName("").action { (f, c) => - c.copy(unexpectedSequenceCacheDir = Some(f)) - } + val _ = opt[Unit]("retain-unexpected-sequence-cache").hidden().action { (_, c) => + c.copy(removeUnexpectedSequenceCache = false) + } - opt[Unit]("retain-unexpected-sequence-cache").hidden().action { (_, c) => - c.copy(removeUnexpectedSequenceCache = false) - } + val _ = + opt[Unit]("skip-unexpected-sequence-report").action((_, c) => c.copy(skipUnexpectedSequenceReport = true)) - opt[Unit]("skip-unexpected-sequence-report").action((_, c) => c.copy(skipUnexpectedSequenceReport = true)) + val _ = opt[Unit]("skip-short-reads").action((_, c) => c.copy(skipShortReads = true)) - opt[Unit]("skip-short-reads").action((_, c) => c.copy(skipShortReads = true)) + val _ = opt[Unit]("always-count-col-barcodes") + .action((_, c) => c.copy(alwaysCountColumnBarcodes = true)) + .text("Count each column barcode regardless of whether a row barcode was found in the read") - opt[Unit]("always-count-col-barcodes") - .action((_, c) => c.copy(alwaysCountColumnBarcodes = true)) - .text("Count each column barcode regardless of whether a row barcode was found in the read") + val _ = opt[Unit]("compat") + .action((_, c) => c.copy(reportsDialect = PoolQ2Dialect)) + .text("Enable PoolQ 2.X compatibility mode") - opt[Unit]("compat") - .action((_, c) => c.copy(reportsDialect = PoolQ2Dialect)) - .text("Enable PoolQ 2.X compatibility mode") + val _ = + opt[Unit]("gct").action((_, c) => c.copy(reportsDialect = GctDialect)).text("Output counts in GCT format") - opt[Unit]("gct").action((_, c) => c.copy(reportsDialect = GctDialect)).text("Output counts in GCT format") + // this is used for throughput testing + val _ = opt[Unit]("noop").hidden().action((_, c) => c.copy(noopConsumer = true)) - // this is used for throughput testing - opt[Unit]("noop").hidden().action((_, c) => c.copy(noopConsumer = true)) + val _ = checkConfig { c => + val readsCheck = (c.input.reads, c.input.rowReads, c.input.colReads) match { + case (None, None, None) => failure("No reads files specified.") + case (None, None, Some(_)) => + failure("Column barcode file specified but no row barcodes file specified.") + case (None, Some(_), None) => + failure("Row barcode file specified but no column barcodes file specified.") + case _ => success + } - checkConfig { c => - val readsCheck = (c.input.reads, c.input.rowReads, c.input.colReads) match { - case (None, None, None) => failure("No reads files specified.") - case (None, None, Some(_)) => - failure("Column barcode file specified but no row barcodes file specified.") - case (None, Some(_), None) => - failure("Row barcode file specified but no column barcodes file specified.") - case _ => success - } + val pairedEndConsistencyCheck = (c.input.reverseRowReads, c.reverseRowBarcodePolicyStr) match { + case (Some(_), None) => failure("Reverse row reads file specified but no reverse barcode policy specified") + case (None, Some(_)) => failure("Reverse barcode policy specified but now reverse row reads file specified") + case _ => success + } - val pairedEndConsistencyCheck = (c.input.reverseRowReads, c.reverseRowBarcodePolicyStr) match { - case (Some(_), None) => failure("Reverse row reads file specified but no reverse barcode policy specified") - case (None, Some(_)) => failure("Reverse barcode policy specified but now reverse row reads file specified") - case _ => success + readsCheck >> pairedEndConsistencyCheck } - - readsCheck >> pairedEndConsistencyCheck } } diff --git a/src/main/scala/org/broadinstitute/gpp/poolq3/parser/BarcodeSet.scala b/src/main/scala/org/broadinstitute/gpp/poolq3/parser/BarcodeSet.scala index ea80385..f000f31 100644 --- a/src/main/scala/org/broadinstitute/gpp/poolq3/parser/BarcodeSet.scala +++ b/src/main/scala/org/broadinstitute/gpp/poolq3/parser/BarcodeSet.scala @@ -36,7 +36,12 @@ object BarcodeSet { def apply(file: Path): BarcodeSet = Using.resource(new FileInputStream(file.toFile)) { fin => - val in = new BOMInputStream(fin, false, ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_16LE) + val in = BOMInputStream + .builder() + .setInputStream(fin) + .setByteOrderMarks(ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_16LE) + .setInclude(false) + .get() val br = new BufferedReader(new InputStreamReader(in)) skipHeader(br, BarcodeRe) br.lines() diff --git a/src/main/scala/org/broadinstitute/gpp/poolq3/parser/ReferenceData.scala b/src/main/scala/org/broadinstitute/gpp/poolq3/parser/ReferenceData.scala index e7f85dc..1358a44 100644 --- a/src/main/scala/org/broadinstitute/gpp/poolq3/parser/ReferenceData.scala +++ b/src/main/scala/org/broadinstitute/gpp/poolq3/parser/ReferenceData.scala @@ -70,7 +70,12 @@ object ReferenceData { def apply(file: Path, quote: Char = '"'): ReferenceData = { Using.resource(new FileInputStream(file.toFile)) { fin => - val in = new BOMInputStream(fin, false, ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_16LE) + val in = BOMInputStream + .builder() + .setInputStream(fin) + .setByteOrderMarks(ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_16LE) + .setInclude(false) + .get() val br = new BufferedReader(new InputStreamReader(in)) val delimiter = guessDelimiter(br) val config = diff --git a/src/main/scala/org/broadinstitute/gpp/poolq3/process/ScoringConsumer.scala b/src/main/scala/org/broadinstitute/gpp/poolq3/process/ScoringConsumer.scala index d3a8a30..2efce2b 100644 --- a/src/main/scala/org/broadinstitute/gpp/poolq3/process/ScoringConsumer.scala +++ b/src/main/scala/org/broadinstitute/gpp/poolq3/process/ScoringConsumer.scala @@ -159,9 +159,8 @@ final class ScoringConsumer( log.debug(s"Incrementing state for ($r, $c}).") umiReference match { case None => - None // we're not in UMI mode, so just increment the state - state.known.increment(None, (r, c)) + val _ = state.known.increment(None, (r, c)) case Some(ref) => // we're in UMI mode handleUmi(umi, ref, r, c) @@ -182,7 +181,7 @@ final class ScoringConsumer( val _ = state.known.increment(Some(u), (r, c)) } else { // we found an unknown UMI barcode, so track it somehow - state.known.increment(None, (r, c)) + val _ = state.known.increment(None, (r, c)) val _ = state.unknownUmi.increment(u) } case None => diff --git a/src/main/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequenceWriter.scala b/src/main/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequenceWriter.scala index fd394d9..128add9 100644 --- a/src/main/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequenceWriter.scala +++ b/src/main/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequenceWriter.scala @@ -105,7 +105,7 @@ object UnexpectedSequenceWriter { val colBc = fields(1) // can't avoid the double hash lookup here without a big hassle - r.put(rowBc, r.getOrElseUpdate(rowBc, 0) + 1) + val _ = r.put(rowBc, r.getOrElseUpdate(rowBc, 0) + 1) h.putIfAbsent(rowBc, new Object2IntOpenHashMap[String]()) h.get(rowBc).addTo(colBc, 1) } @@ -120,7 +120,7 @@ object UnexpectedSequenceWriter { ): Unit = { val drop = r.toSeq.sortBy { case (_, count) => -count }.drop(n) drop.foreach { case (bc, _) => - r.remove(bc) + val _ = r.remove(bc) h.remove(bc) } } diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/BarcodePolicyTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/BarcodePolicyTest.scala index 81b09a0..21abbfa 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/BarcodePolicyTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/BarcodePolicyTest.scala @@ -5,50 +5,53 @@ */ package org.broadinstitute.gpp.poolq3.barcode -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers._ +import munit.FunSuite -class BarcodePolicyTest extends AnyFlatSpec { +class BarcodePolicyTest extends FunSuite { - "BarcodePolicy" should "choose a fixed barcode policy" in { - BarcodePolicy("FIXED@0", 8, false) should be(FixedOffsetPolicy(0, 8, false)) + test("fixed barcode policy") { + assertEquals(BarcodePolicy("FIXED@0", 8, false), FixedOffsetPolicy(0, 8, false)) // this is a deprecated option but needs to be supported for the time being - BarcodePolicy("FIXED:0", 8, false) should be(FixedOffsetPolicy(0, 8, false)) + assertEquals(BarcodePolicy("FIXED:0", 8, false), FixedOffsetPolicy(0, 8, false)) } - it should "choose a known prefix barcode policy" in { - BarcodePolicy("PREFIX:CACCG@7", 20, false) should be(IndexOfKnownPrefixPolicy("CACCG", 20, Some(7))) - BarcodePolicy("PREFIX:CACCG@7-9", 20, false) should be(IndexOfKnownPrefixPolicy("CACCG", 20, Some(7), Some(9))) - BarcodePolicy("PREFIX:CACCG@-9", 20, false) should be(IndexOfKnownPrefixPolicy("CACCG", 20, None, Some(9))) + test("known prefix barcode policy") { + assertEquals(BarcodePolicy("PREFIX:CACCG@7", 20, false), IndexOfKnownPrefixPolicy("CACCG", 20, Some(7))) + assertEquals(BarcodePolicy("PREFIX:CACCG@7-9", 20, false), IndexOfKnownPrefixPolicy("CACCG", 20, Some(7), Some(9))) + assertEquals(BarcodePolicy("PREFIX:CACCG@-9", 20, false), IndexOfKnownPrefixPolicy("CACCG", 20, None, Some(9))) } - it should "let the user specify a shorter length with a fixed policy" in { - BarcodePolicy("FIXED@0:6", 6, true) should be(FixedOffsetPolicy(0, 6, true)) + test("specify a shorter length with a fixed policy") { + assertEquals(BarcodePolicy("FIXED@0:6", 6, true), FixedOffsetPolicy(0, 6, true)) // this is a deprecated option but needs to be supported for the time being - BarcodePolicy("FIXED:0:6", 6, true) should be(FixedOffsetPolicy(0, 6, true)) + assertEquals(BarcodePolicy("FIXED:0:6", 6, true), FixedOffsetPolicy(0, 6, true)) } - it should "let the user specify a shorter length with a known prefix policy" in { - BarcodePolicy("PREFIX:CACCG@7:19", 19, false) should be(IndexOfKnownPrefixPolicy("CACCG", 19, Some(7))) + test("specify a shorter length with a known prefix policy") { + assertEquals(BarcodePolicy("PREFIX:CACCG@7:19", 19, false), IndexOfKnownPrefixPolicy("CACCG", 19, Some(7))) } - it should "let the user specify a keymask policy" in { - BarcodePolicy("KEYMASK:caccgNNNNttNNNNaa@3", 8, false) should be( + test("keymask policy") { + assertEquals( + BarcodePolicy("KEYMASK:caccgNNNNttNNNNaa@3", 8, false), GeneralTemplatePolicy(KeyMask("caccgNNNNttNNNNaa"), Some(3), None) ) - BarcodePolicy("TEMPLATE:caccgNNNNttNNNNaa@3", 8, false) should be( + assertEquals( + BarcodePolicy("TEMPLATE:caccgNNNNttNNNNaa@3", 8, false), GeneralTemplatePolicy(KeyMask("caccgNNNNttNNNNaa"), Some(3), None) ) } - it should "recognize a split barcode situation" in { - BarcodePolicy("TEMPLATE:caccgNNNNNnnnnnntatgcNNNNaa@3", 9, false) should be( + test("split barcode situation") { + assertEquals( + BarcodePolicy("TEMPLATE:caccgNNNNNnnnnnntatgcNNNNaa@3", 9, false), SplitBarcodePolicy("CACCG", 5, 6, "TATGC", 4, Some(3), None) ) } - it should "let the user specify just a 3' limit" in { - BarcodePolicy("TEMPLATE:NNNNNNNNNNNNNNNNNNNNNNN@-1", 23, false) should be( + test("specify just a 3' limit") { + assertEquals( + BarcodePolicy("TEMPLATE:NNNNNNNNNNNNNNNNNNNNNNN@-1", 23, false), GeneralTemplatePolicy(KeyMask("NNNNNNNNNNNNNNNNNNNNNNN"), None, Some(1)) ) } diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyMaskTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyMaskTest.scala index cd28081..7a7aa03 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyMaskTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyMaskTest.scala @@ -12,13 +12,13 @@ class KeyMaskTest extends AnyFlatSpec { "KeyMask.apply" should "construct the correct key mask from a pattern" in { val km0 = KeyMask("NNNNNNNNNNNNNNNNN") - km0 should be(KeyMask.fromString(17, "1-17")) + val _ = km0 should be(KeyMask.fromString(17, "1-17")) val km1 = KeyMask("NNNNNNNNNNNNNNNNNnNN") - km1 should be(KeyMask.fromString(20, "1-17,19-20")) + val _ = km1 should be(KeyMask.fromString(20, "1-17,19-20")) val km2 = KeyMask("nNNNNNNNNNNNNNNNNNnNNn") - km2 should be(KeyMask.fromString(22, "2-18,20-21")) + val _ = km2 should be(KeyMask.fromString(22, "2-18,20-21")) val km3 = KeyMask("nnnNNNNNNNNNNNNNNNNNnNNnN") - km3 should be(KeyMask.fromString(25, "4-20,22-23,25")) + val _ = km3 should be(KeyMask.fromString(25, "4-20,22-23,25")) val km4 = KeyMask("nnnnNNNNNNNNNNNNNNNNNNNNnnnnnn") km4 should be(KeyMask.fromString(30, "5-24")) } @@ -30,14 +30,14 @@ class KeyMaskTest extends AnyFlatSpec { val km5 = KeyMask( "caccgNNNNNNNNNNNNNNNNNNNNnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnNNNNNNNNNNNNNNNNNNNNN" ) - km5.contextLength should be(240) - km5.keyLengthInBases should be(41) + val _ = km5.contextLength should be(240) + val _ = km5.keyLengthInBases should be(41) km5.keyRanges should be(Seq(KeyRange(5, 24), KeyRange(219, 239))) } "KeyMask.fromString" should "compute the correct key mask from a list of key ranges in either syntax" in { val km1 = KeyMask.fromString(23, "4-20,22-23") - km1 should be(KeyMask(23, Seq(KeyRange(3, 19), KeyRange(21, 22)))) + val _ = km1 should be(KeyMask(23, Seq(KeyRange(3, 19), KeyRange(21, 22)))) val km2 = KeyMask.fromString(23, "4..20,22..23") km2 should be(KeyMask(23, Seq(KeyRange(3, 19), KeyRange(21, 22)))) } @@ -59,7 +59,7 @@ class KeyMaskTest extends AnyFlatSpec { } it should "merge adjacent ranges" in { - KeyMask.mergeAdjacent(Seq(KeyRange(1, 9), KeyRange(10, 12), KeyRange(14, 17))) should be( + val _ = KeyMask.mergeAdjacent(Seq(KeyRange(1, 9), KeyRange(10, 12), KeyRange(14, 17))) should be( Seq(KeyRange(1, 12), KeyRange(14, 17)) ) KeyMask.fromString(10, "1,2..4,5,6-8,9") should be(KeyMask.fromString(10, "1-9")) diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyMaskTest2.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyMaskTest2.scala index a421e74..c58d8a7 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyMaskTest2.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyMaskTest2.scala @@ -5,23 +5,22 @@ */ package org.broadinstitute.gpp.poolq3.barcode -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers._ +import munit.FunSuite /** This class provides additional tests for the KeyMask that are not found in the FISHR codebase from which KeyMask and * its primary test class were lifted. We will try not to modify the copied test classes to make subsequent updates * from FISHR easier. Instead, new PoolQ-specific tests will live here. */ -class KeyMaskTest2 extends AnyFlatSpec { +class KeyMaskTest2 extends FunSuite { - "KeyMask.apply" should "construct the correct key mask from a pattern" in { + test("construct the correct key mask from a pattern") { // 0 1 2 // 12345678901234567890123456789 val km0 = KeyMask("caccgNNNNNnnnnnnnnnttacaNNNNN") // parsing should work how we expect - km0.keyRanges should be(Seq(KeyRange(5, 9), KeyRange(24, 28))) - km0.keyLengthInBases should be(10) + assertEquals(km0.keyRanges, Seq(KeyRange(5, 9), KeyRange(24, 28))) + assertEquals(km0.keyLengthInBases, 10) } } diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyRangeTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyRangeTest.scala index 710d912..3d10286 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyRangeTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/KeyRangeTest.scala @@ -14,32 +14,32 @@ import org.scalatest.matchers.should.Matchers._ class KeyRangeTest extends AnyFlatSpec { "KeyRange" should "enforce well-formedness" in { - noException should be thrownBy KeyRange(3, 4) - noException should be thrownBy KeyRange(3, 3) - an[IllegalArgumentException] should be thrownBy KeyRange(3, 2) + val _ = noException should be thrownBy KeyRange(3, 4) + val _ = noException should be thrownBy KeyRange(3, 3) + val _ = an[IllegalArgumentException] should be thrownBy KeyRange(3, 2) an[IllegalArgumentException] should be thrownBy KeyRange(-2, 2) } it should "have working compare()" in { val ord = implicitly[Ordering[KeyRange]] - ord.compare(KeyRange(2, 5), KeyRange(2, 5)) should be(0) - KeyRange(2, 5) should be <= KeyRange(2, 5) - KeyRange(2, 5) should be >= KeyRange(2, 5) + val _ = ord.compare(KeyRange(2, 5), KeyRange(2, 5)) should be(0) + val _ = KeyRange(2, 5) should be <= KeyRange(2, 5) + val _ = KeyRange(2, 5) should be >= KeyRange(2, 5) - KeyRange(2, 5) should be < KeyRange(3, 4) - KeyRange(2, 5) should be < KeyRange(2, 6) - KeyRange(2, 5) should be > KeyRange(2, 4) + val _ = KeyRange(2, 5) should be < KeyRange(3, 4) + val _ = KeyRange(2, 5) should be < KeyRange(2, 6) + val _ = KeyRange(2, 5) should be > KeyRange(2, 4) KeyRange(2, 5) should be > KeyRange(1, 32) } it should "be creatable from a string" in { - KeyRange("1-1") should be(KeyRange(0, 0)) - KeyRange("1..1") should be(KeyRange(0, 0)) - KeyRange("1") should be(KeyRange(0, 0)) - KeyRange("1-6") should be(KeyRange(0, 5)) - KeyRange("1..6") should be(KeyRange(0, 5)) - an[IllegalArgumentException] should be thrownBy KeyRange("0-5") - an[IllegalArgumentException] should be thrownBy KeyRange("-1-5") + val _ = KeyRange("1-1") should be(KeyRange(0, 0)) + val _ = KeyRange("1..1") should be(KeyRange(0, 0)) + val _ = KeyRange("1") should be(KeyRange(0, 0)) + val _ = KeyRange("1-6") should be(KeyRange(0, 5)) + val _ = KeyRange("1..6") should be(KeyRange(0, 5)) + val _ = an[IllegalArgumentException] should be thrownBy KeyRange("0-5") + val _ = an[IllegalArgumentException] should be thrownBy KeyRange("-1-5") an[IllegalArgumentException] should be thrownBy KeyRange("6-5") } diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/TemplatePolicyTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/TemplatePolicyTest.scala index c3c4494..5818936 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/TemplatePolicyTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/barcode/TemplatePolicyTest.scala @@ -113,8 +113,12 @@ class TemplatePolicyTest extends AnyFlatSpec { val keymask = KeyMask(pattern) val kmp = new GeneralTemplatePolicy(keymask, Some(0)) - kmp.find(Read("", read1)) should be(Some(FoundBarcode("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT".toCharArray, 5))) - kmp.find(Read("", read2)) should be(Some(FoundBarcode("NTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT".toCharArray, 5))) + val _ = kmp.find(Read("", read1)) should be( + Some(FoundBarcode("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT".toCharArray, 5)) + ) + val _ = kmp.find(Read("", read2)) should be( + Some(FoundBarcode("NTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT".toCharArray, 5)) + ) kmp.find(Read("", read3)) should be(None) } @@ -131,8 +135,8 @@ class TemplatePolicyTest extends AnyFlatSpec { (variable: String, r1: String, ns: String, r2: String, rest: String) => val read = Read("id", variable + fixed + prefix1 + r1 + ns + prefix2 + r2 + rest) // warm up phase - nanoTimed(100)(_ => kmp.find(read)) - nanoTimed(100)(_ => kpp.find(read)) + val _ = nanoTimed(100)(_ => kmp.find(read)) + val _ = nanoTimed(100)(_ => kpp.find(read)) // go! val (ret1, t1) = nanoTimed(10000)(_ => kmp.find(read)) diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/hist/OpenHashMapHistogramTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/hist/OpenHashMapHistogramTest.scala index b94cf88..b8ba3fd 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/hist/OpenHashMapHistogramTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/hist/OpenHashMapHistogramTest.scala @@ -13,17 +13,17 @@ class OpenHashMapHistogramTest extends FunSuite with ScalaCheckSuite { test("OpenHashMapHistogram should track frequencies") { val h = new OpenHashMapHistogram[String] - h.increment("AAAA") - h.increment("AAAA") - h.increment("AAAA") - h.increment("AAAA") + val _ = h.increment("AAAA") + val _ = h.increment("AAAA") + val _ = h.increment("AAAA") + val _ = h.increment("AAAA") assertEquals(h.count("AAAA"), 4) assertEquals(h.count("CCCC"), 0) } property("OpenHashMapHistogram should track frequencies for arbitrary data") { - forAll { data: List[Int] => + forAll { (data: List[Int]) => val expectedCounts: Map[Int, Int] = data.groupBy(identity).view.mapValues(_.length).toMap val hist = new OpenHashMapHistogram[Int] diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/hist/ShardedHistogramTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/hist/ShardedHistogramTest.scala index 79edcb0..ee96ae8 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/hist/ShardedHistogramTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/hist/ShardedHistogramTest.scala @@ -14,13 +14,13 @@ class ShardedHistogramTest extends FunSuite with ScalaCheckSuite { val h = new BasicShardedHistogram[String, String](new OpenHashMapHistogram) // increment a few things - h.increment(None, "AAAA") + val _ = h.increment(None, "AAAA") - h.increment(Some("CCCC"), "AAAA") - h.increment(Some("CCCC"), "AAAA") - h.increment(Some("CCCT"), "AAAA") + val _ = h.increment(Some("CCCC"), "AAAA") + val _ = h.increment(Some("CCCC"), "AAAA") + val _ = h.increment(Some("CCCT"), "AAAA") - h.increment(Some("CCCT"), "TTTT") + val _ = h.increment(Some("CCCT"), "TTTT") // make sure the resulting histogram checks out assertEquals(h.shards, Set("CCCC", "CCCT")) @@ -34,7 +34,7 @@ class ShardedHistogramTest extends FunSuite with ScalaCheckSuite { property("track frequencies for arbitrary data") { def key(x: Int): Option[Int] = if (x < 0) None else Some(x) - forAll { data: List[(Int, Int)] => + forAll { (data: List[(Int, Int)]) => val actualHistogram = new BasicShardedHistogram[Int, Int](new OpenHashMapHistogram) data.foreach { case (shard, value) => actualHistogram.increment(key(shard), value) diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/hist/TupleHistogramTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/hist/TupleHistogramTest.scala index 16495a3..cb6629b 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/hist/TupleHistogramTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/hist/TupleHistogramTest.scala @@ -13,17 +13,17 @@ class TupleHistogramTest extends FunSuite with ScalaCheckSuite { test("OpenHashMapHistogram should track frequencies") { val h = new TupleHistogram[String] - h.increment(("AAAA", "TTTT")) - h.increment(("AAAA", "TTTT")) - h.increment(("AAAA", "TTTT")) - h.increment(("AAAA", "TTTT")) + val _ = h.increment(("AAAA", "TTTT")) + val _ = h.increment(("AAAA", "TTTT")) + val _ = h.increment(("AAAA", "TTTT")) + val _ = h.increment(("AAAA", "TTTT")) assertEquals(h.count(("AAAA", "TTTT")), 4) assertEquals(h.count(("AAAA", "TTTC")), 0) } property("track frequencies for arbitrary data") { - forAll { data: List[(Char, Char)] => + forAll { (data: List[(Char, Char)]) => val expectedCounts: Map[(Char, Char), Int] = data.groupBy(identity).view.mapValues(_.length).toMap val hist = new TupleHistogram[Char] diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/integration/AmbiguousMatchTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/integration/AmbiguousMatchTest.scala index 6ec63ba..a21c2ae 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/integration/AmbiguousMatchTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/integration/AmbiguousMatchTest.scala @@ -62,43 +62,43 @@ class AmbiguousMatchTest extends AnyFlatSpec { val ret = PoolQ.runProcess(barcodes, consumer) val state = ret.get.state - state.reads should be(9) - state.exactMatches should be(3) + val _ = state.reads should be(9) + val _ = state.exactMatches should be(3) val hist = state.known - hist.count(("AAAAAAAAAAAAAAAAAAAA", "AAAA")) should be(1) - hist.count(("AAAAAAAAAAAAAAAAAAAA", "AAAT")) should be(1) - hist.count(("GATGTGCAGTGAGTAGCGAG", "AAAA")) should be(1) - hist.count(("CCGGTTGATGCGTGGTGATG", "CCCC")) should be(1) - hist.count(("AATGTGAAAATGTGATGAAT", "CCCG")) should be(1) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAA", "AAAA")) should be(1) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAA", "AAAT")) should be(1) + val _ = hist.count(("GATGTGCAGTGAGTAGCGAG", "AAAA")) should be(1) + val _ = hist.count(("CCGGTTGATGCGTGGTGATG", "CCCC")) should be(1) + val _ = hist.count(("AATGTGAAAATGTGATGAAT", "CCCG")) should be(1) // these all correspond to the ambiguous match at the end - hist.count(("AAAAAAAAAAAAAAAAAAAA", "CCCC")) should be(1) - hist.count(("AAAAAAAAAAAAAAAAAAAC", "CCCC")) should be(1) - hist.count(("AAAAAAAAAAAAAAAAAAAG", "CCCC")) should be(1) - hist.count(("AAAAAAAAAAAAAAAAAAAT", "CCCC")) should be(1) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAA", "CCCC")) should be(1) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAC", "CCCC")) should be(1) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAG", "CCCC")) should be(1) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAT", "CCCC")) should be(1) // these are combinations that didn't occur - hist.count(("AAAAAAAAAAAAAAAAAAAA", "CCCG")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAA", "CCCG")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAC", "AAAA")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAC", "AAAT")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAC", "CCCG")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAC", "AAAA")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAC", "AAAT")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAC", "CCCG")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAG", "AAAA")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAG", "AAAT")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAG", "CCCG")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAG", "AAAA")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAG", "AAAT")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAG", "CCCG")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAT", "AAAA")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAT", "AAAT")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAT", "CCCG")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAT", "AAAA")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAT", "AAAT")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAT", "CCCG")) should be(0) - hist.count(("GATGTGCAGTGAGTAGCGAG", "AAAT")) should be(0) - hist.count(("GATGTGCAGTGAGTAGCGAG", "CCCC")) should be(0) - hist.count(("GATGTGCAGTGAGTAGCGAG", "CCCG")) should be(0) + val _ = hist.count(("GATGTGCAGTGAGTAGCGAG", "AAAT")) should be(0) + val _ = hist.count(("GATGTGCAGTGAGTAGCGAG", "CCCC")) should be(0) + val _ = hist.count(("GATGTGCAGTGAGTAGCGAG", "CCCG")) should be(0) - hist.count(("AATGTGAAAATGTGATGAAT", "AAAA")) should be(0) - hist.count(("AATGTGAAAATGTGATGAAT", "AAAT")) should be(0) + val _ = hist.count(("AATGTGAAAATGTGATGAAT", "AAAA")) should be(0) + val _ = hist.count(("AATGTGAAAATGTGATGAAT", "AAAT")) should be(0) hist.count(("AATGTGAAAATGTGATGAAT", "CCCC")) should be(0) } diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/integration/LongBarcodeMatchTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/integration/LongBarcodeMatchTest.scala index a5a8039..af2b173 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/integration/LongBarcodeMatchTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/integration/LongBarcodeMatchTest.scala @@ -94,26 +94,26 @@ class LongBarcodeMatchTest extends AnyFlatSpec { val ret = PoolQ.runProcess(barcodes, consumer) val state = ret.get.state - state.reads should be(9) - state.exactMatches should be(2) - state.matches should be(4) + val _ = state.reads should be(9) + val _ = state.exactMatches should be(2) + val _ = state.matches should be(4) val hist = state.known // these are all the matches - hist.count( + val _ = hist.count( ( "TTTCTGTCATCCAAATACTCCACACGCAAATTTCCTTCCACTCGGATAAGATGCTGAGGAGGGGCCAGACCTAAGAGCAATCAGTGAGGAATCAGAGGCCTGGGGACCCTGGGCAACCAGCCCTGTCGTCTCTCCAGCCCCAGC", "AAAT" ) ) should be(1) - hist.count( + val _ = hist.count( ( "TTTCTGTCATCCAAATACTCCACACGCAAATTTCCTTCCACTCGGATAAGATGCTGAGGAGGGGCCAGACCTAAGAGCAATCAGTGAGGAATCAGAGGCCTGGGGACCCTGGGCAACCAGCCCTGTCGTCTCTCCAGCCCCAGC", "AAAA" ) ) should be(1) - hist.count( + val _ = hist.count( ( "TTTCTGTCATCCAAATACTCCACACGCAAATTTCCTTCCACTCGGATAAGATGCTGAGGAGGGGCCAGACCTAAGAGCAATCAGTGAGGAATCAGAGGCCTGGGGACCCTGGGCAACCAGCCCTGTCGTCTCTCCAGCCCCAGC", "CCCG" diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/integration/UnambiguousMatchTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/integration/UnambiguousMatchTest.scala index 01ea610..9a835d9 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/integration/UnambiguousMatchTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/integration/UnambiguousMatchTest.scala @@ -62,43 +62,43 @@ class UnambiguousMatchTest extends AnyFlatSpec { val ret = PoolQ.runProcess(barcodes, consumer) val state = ret.get.state - state.reads should be(9) - state.exactMatches should be(3) + val _ = state.reads should be(9) + val _ = state.exactMatches should be(3) val hist = state.known - hist.count(("AAAAAAAAAAAAAAAAAAAA", "AAAA")) should be(1) - hist.count(("AAAAAAAAAAAAAAAAAAAA", "AAAT")) should be(1) - hist.count(("GATGTGCAGTGAGTAGCGAG", "AAAA")) should be(1) - hist.count(("CCGGTTGATGCGTGGTGATG", "CCCC")) should be(1) - hist.count(("AATGTGAAAATGTGATGAAT", "CCCG")) should be(1) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAA", "AAAA")) should be(1) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAA", "AAAT")) should be(1) + val _ = hist.count(("GATGTGCAGTGAGTAGCGAG", "AAAA")) should be(1) + val _ = hist.count(("CCGGTTGATGCGTGGTGATG", "CCCC")) should be(1) + val _ = hist.count(("AATGTGAAAATGTGATGAAT", "CCCG")) should be(1) // these all correspond to the ambiguous match at the end - hist.count(("AAAAAAAAAAAAAAAAAAAA", "CCCC")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAC", "CCCC")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAG", "CCCC")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAT", "CCCC")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAA", "CCCC")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAC", "CCCC")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAG", "CCCC")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAT", "CCCC")) should be(0) // these are combinations that didn't occur - hist.count(("AAAAAAAAAAAAAAAAAAAA", "CCCG")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAA", "CCCG")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAC", "AAAA")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAC", "AAAT")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAC", "CCCG")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAC", "AAAA")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAC", "AAAT")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAC", "CCCG")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAG", "AAAA")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAG", "AAAT")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAG", "CCCG")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAG", "AAAA")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAG", "AAAT")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAG", "CCCG")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAT", "AAAA")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAT", "AAAT")) should be(0) - hist.count(("AAAAAAAAAAAAAAAAAAAT", "CCCG")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAT", "AAAA")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAT", "AAAT")) should be(0) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAT", "CCCG")) should be(0) - hist.count(("GATGTGCAGTGAGTAGCGAG", "AAAT")) should be(0) - hist.count(("GATGTGCAGTGAGTAGCGAG", "CCCC")) should be(0) - hist.count(("GATGTGCAGTGAGTAGCGAG", "CCCG")) should be(0) + val _ = hist.count(("GATGTGCAGTGAGTAGCGAG", "AAAT")) should be(0) + val _ = hist.count(("GATGTGCAGTGAGTAGCGAG", "CCCC")) should be(0) + val _ = hist.count(("GATGTGCAGTGAGTAGCGAG", "CCCG")) should be(0) - hist.count(("AATGTGAAAATGTGATGAAT", "AAAA")) should be(0) - hist.count(("AATGTGAAAATGTGATGAAT", "AAAT")) should be(0) + val _ = hist.count(("AATGTGAAAATGTGATGAAT", "AAAA")) should be(0) + val _ = hist.count(("AATGTGAAAATGTGATGAAT", "AAAT")) should be(0) hist.count(("AATGTGAAAATGTGATGAAT", "CCCC")) should be(0) } diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/integration/UnambiguousVariantTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/integration/UnambiguousVariantTest.scala index 493db05..611a1f6 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/integration/UnambiguousVariantTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/integration/UnambiguousVariantTest.scala @@ -41,11 +41,11 @@ class UnambiguousVariantTest extends AnyFlatSpec { val ret = PoolQ.runProcess(reads, consumer) val state = ret.get.state - state.reads should be(1) - state.exactMatches should be(0) + val _ = state.reads should be(1) + val _ = state.exactMatches should be(0) val hist = state.known - hist.count(("AAAAAAAAAAAAAAAAAAAA", "AAAA")) should be(1) + val _ = hist.count(("AAAAAAAAAAAAAAAAAAAA", "AAAA")) should be(1) for { row <- rowReferenceBarcodes.map(_.dnaBarcode) col <- colReferenceBarcodes.map(_.dnaBarcode) diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/integration/legacy/LegacyIntegrationTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/integration/legacy/LegacyIntegrationTest.scala index 1da7124..3f7280f 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/integration/legacy/LegacyIntegrationTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/integration/legacy/LegacyIntegrationTest.scala @@ -13,12 +13,12 @@ import org.broadinstitute.gpp.poolq3.testutil.contents import org.broadinstitute.gpp.poolq3.{PoolQ, PoolQConfig, PoolQInput, PoolQOutput, TestResources} import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers._ -import org.scalatest.{Assertion => TestAssertion} class LegacyIntegrationTest extends AnyFlatSpec with TestResources { - private[this] def filesSame(actual: Path, expected: Path): TestAssertion = - contents(actual) should be(contents(expected)) + private[this] def filesSame(actual: Path, expected: Path): Unit = { + val _ = contents(actual) should be(contents(expected)) + } /** Tests PoolQ end-to-end, using 10000 reads, 8 constructs, and 42 conditions. Compares the results to expected * results. @@ -59,7 +59,7 @@ class LegacyIntegrationTest extends AnyFlatSpec with TestResources { reportsDialect = PoolQ2Dialect ) - PoolQ.run(config) + val _ = PoolQ.run(config) filesSame(countsFile.path, resourcePath("counts-10000-8-42.txt")) filesSame(normalizedCountsFile.path, resourcePath("lognorm-10000-8-42.txt")) @@ -102,7 +102,7 @@ class LegacyIntegrationTest extends AnyFlatSpec with TestResources { reportsDialect = PoolQ2Dialect ) - PoolQ.run(config) + val _ = PoolQ.run(config) filesSame(countsFile.path, resourcePath("counts-10000-8-42.txt")) filesSame(normalizedCountsFile.path, resourcePath("lognorm-10000-8-42.txt")) @@ -152,7 +152,7 @@ class LegacyIntegrationTest extends AnyFlatSpec with TestResources { reportsDialect = PoolQ2Dialect ) - PoolQ.run(config) + val _ = PoolQ.run(config) filesSame(countsFile.toJava.toPath, resourcePath("long-reads-counts.txt")) filesSame(normalizedCountsFile.toJava.toPath, resourcePath("long-reads-lognorm.txt")) @@ -196,7 +196,7 @@ class LegacyIntegrationTest extends AnyFlatSpec with TestResources { reportsDialect = PoolQ2Dialect ) - PoolQ.run(config) + val _ = PoolQ.run(config) filesSame(countsFile.toJava.toPath, resourcePath("overlapping-barcode-counts.txt")) filesSame(normalizedCountsFile.toJava.toPath, resourcePath("overlapping-barcode-lognorm.txt")) @@ -242,7 +242,7 @@ class LegacyIntegrationTest extends AnyFlatSpec with TestResources { reportsDialect = PoolQ2Dialect ) - PoolQ.run(config) + val _ = PoolQ.run(config) filesSame(countsFile.toJava.toPath, resourcePath("next500-counts.txt")) filesSame(qualityFile.toJava.toPath, resourcePath("next500-quality.txt")) @@ -282,7 +282,7 @@ class LegacyIntegrationTest extends AnyFlatSpec with TestResources { reportsDialect = PoolQ2Dialect ) - PoolQ.run(config) + val _ = PoolQ.run(config) filesSame(countsFile.toJava.toPath, resourcePath("next500-counts.txt")) filesSame(qualityFile.toJava.toPath, resourcePath("next500-quality.txt")) @@ -325,7 +325,7 @@ class LegacyIntegrationTest extends AnyFlatSpec with TestResources { reportsDialect = PoolQ2Dialect ) - PoolQ.run(config) + val _ = PoolQ.run(config) filesSame(countsFile.toJava.toPath, resourcePath("duplicate-hp-counts.txt")) filesSame(normalizedCountsFile.toJava.toPath, resourcePath("duplicate-hp-lognorm.txt")) diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/numeric/NumericPackageTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/numeric/NumericPackageTest.scala index 6f021f9..7c74a0d 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/numeric/NumericPackageTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/numeric/NumericPackageTest.scala @@ -14,12 +14,12 @@ class NumericPackageTest extends AnyFlatSpec { "log2" should "take the log base 2" in { val smallNonNeg = Gen.chooseNum(0.0, 48.0) - forAll(smallNonNeg) { x: Double => log2(math.pow(2, x)) should be(x +- .00000000000001) } + forAll(smallNonNeg)((x: Double) => log2(math.pow(2, x)) should be(x +- .00000000000001)) } "logNormalize" should "not divide by zero" in { - logNormalize(0, 132656131) should be(0) - logNormalize(0, 0) should be(0) + val _ = logNormalize(0, 132656131) should be(0) + val _ = logNormalize(0, 0) should be(0) logNormalize(1, 0) should be(0) } diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/parser/FastqParserTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/parser/FastqParserTest.scala index 9ab1d30..caae53f 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/parser/FastqParserTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/parser/FastqParserTest.scala @@ -68,7 +68,7 @@ class FastqParserTest extends AnyFlatSpec { file.overwrite(data) val fqp = new FastqParser(file.path) val fqi = fqp.iterator - (fqi.toList should have).length(2) + val _ = (fqi.toList should have).length(2) fqi.close() } finally { file.delete() diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/parser/ReferenceDataTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/parser/ReferenceDataTest.scala index 1c502e1..368d023 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/parser/ReferenceDataTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/parser/ReferenceDataTest.scala @@ -89,7 +89,7 @@ class ReferenceDataTest extends AnyFlatSpec with TestResources { it should "read a CSV with empty IDs" in { val path = resourcePath("reference_empty_id.csv") val rd1 = ReferenceData(path) - rd1.mappings should be(Seq(ReferenceEntry("TTGAACCG", "EMPTY"), ReferenceEntry("GGCTTGCG", ""))) + val _ = rd1.mappings should be(Seq(ReferenceEntry("TTGAACCG", "EMPTY"), ReferenceEntry("GGCTTGCG", ""))) val rd2 = rd1.forColumnBarcodes(PoolQ2Dialect) rd2.mappings should be( Seq(ReferenceEntry("TTGAACCG", "EMPTY"), ReferenceEntry("GGCTTGCG", "Unlabeled Sample Barcodes")) diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/reference/BkTreeTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/reference/BkTreeTest.scala index d7b7f9e..9954f57 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/reference/BkTreeTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/reference/BkTreeTest.scala @@ -23,12 +23,12 @@ class BkTreeTest extends AnyFlatSpec { val t = new BkTree(levenshtein, Seq("book", "books", "cake", "boo", "boon", "cook", "cape", "cart")) - t.query("book", 1) should be(Set("book", "books", "boon", "boo", "cook")) + val _ = t.query("book", 1) should be(Set("book", "books", "boon", "boo", "cook")) t.query("booky", 1) should be(Set("book", "books")) } it should "support queries of arbitrary dictionaries" in { - forAll(referenceGen) { reference: List[String] => + forAll(referenceGen) { (reference: List[String]) => val tree = new BkTree(levenshtein, reference) reference.headOption.foreach { query => (0 until query.length).foreach { i => diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/reference/ExactReferenceTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/reference/ExactReferenceTest.scala index e6302ed..81dcd74 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/reference/ExactReferenceTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/reference/ExactReferenceTest.scala @@ -16,16 +16,16 @@ class ExactReferenceTest extends AnyFlatSpec { val referenceGen: Gen[List[String]] = Gen.listOfN(1000, barcode) "ExactReference" should "find matches for a given barcode" in { - forAll(referenceGen) { barcodes: List[String] => + forAll(referenceGen) { (barcodes: List[String]) => val reference = ExactReference(barcodes.map(b => ReferenceEntry(b, b)), identity, includeAmbiguous = false) barcodes.foreach { bc => - reference.isDefined(bc) should be(true) - reference.find(bc) should be(Seq(MatchedBarcode(bc, 0))) + val _ = reference.isDefined(bc) should be(true) + val _ = reference.find(bc) should be(Seq(MatchedBarcode(bc, 0))) reference.idsForBarcode(bc) should be(Seq(bc)) } - reference.allIds.toSet should be(barcodes.toSet) + val _ = reference.allIds.toSet should be(barcodes.toSet) reference.allBarcodes.toSet should be(barcodes.toSet) } } @@ -33,12 +33,12 @@ class ExactReferenceTest extends AnyFlatSpec { it should "find variants with the correct distance" in { val reference = ExactReference(Seq(ReferenceEntry("AAAAAAAAAAAAAAAAAAAA", "One")), identity, includeAmbiguous = false) - reference.find("AAAAAAAAAAAAAAAAAAAA") should be(Seq(MatchedBarcode("AAAAAAAAAAAAAAAAAAAA", 0))) - reference.find("NAAAAAAAAAAAAAAAAAAA") should be(Seq()) - reference.find("AAAAAAAAAAAAAAAAAAAT") should be(Seq()) - reference.find("NAAAAAAAAAAAAAAAAAAT") should be(Seq()) + val _ = reference.find("AAAAAAAAAAAAAAAAAAAA") should be(Seq(MatchedBarcode("AAAAAAAAAAAAAAAAAAAA", 0))) + val _ = reference.find("NAAAAAAAAAAAAAAAAAAA") should be(Seq()) + val _ = reference.find("AAAAAAAAAAAAAAAAAAAT") should be(Seq()) + val _ = reference.find("NAAAAAAAAAAAAAAAAAAT") should be(Seq()) - reference.barcodesForId("One") should be(Seq("AAAAAAAAAAAAAAAAAAAA")) + val _ = reference.barcodesForId("One") should be(Seq("AAAAAAAAAAAAAAAAAAAA")) reference.idsForBarcode("AAAAAAAAAAAAAAAAAAAA") should be(Seq("One")) } diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/reference/VariantReferenceTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/reference/VariantReferenceTest.scala index 0405090..e9e6fa0 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/reference/VariantReferenceTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/reference/VariantReferenceTest.scala @@ -20,7 +20,7 @@ class VariantReferenceTest extends AnyFlatSpec { private[this] val referenceGen: Gen[List[String]] = Gen.listOfN(1000, barcode) "VariantReference" should "find matches for a given barcode" in { - forAll(referenceGen) { barcodes: List[String] => + forAll(referenceGen) { (barcodes: List[String]) => val reference = VariantReference(barcodes.map(b => ReferenceEntry(b, b)), identity, false) barcodes.foreach(barcode => reference.find(barcode) should be(Seq(MatchedBarcode(barcode, 0)))) @@ -28,14 +28,14 @@ class VariantReferenceTest extends AnyFlatSpec { } it should "find matches for barcodes with zero or one Ns" in { - forAll(referenceGen) { barcodes: List[String] => + forAll(referenceGen) { (barcodes: List[String]) => val reference = VariantReference(barcodes.map(b => ReferenceEntry(b, b)), identity, false) barcodes.foreach { barcode => val bcN = withNs(barcode, 1) val bcNs = withNs(barcode, 2 + Random.nextInt(3)) - reference.find(barcode) should be(Seq(MatchedBarcode(barcode, 0))) - reference.find(bcN) should be(Seq(MatchedBarcode(barcode, 1))) + val _ = reference.find(barcode) should be(Seq(MatchedBarcode(barcode, 0))) + val _ = reference.find(bcN) should be(Seq(MatchedBarcode(barcode, 1))) reference.find(bcNs) should be(Seq()) } } @@ -44,9 +44,9 @@ class VariantReferenceTest extends AnyFlatSpec { it should "find variants with the correct distance" in { val reference = VariantReference(Seq(ReferenceEntry("AAAAAAAAAAAAAAAAAAAA", "One")), identity, includeAmbiguous = false) - reference.find("AAAAAAAAAAAAAAAAAAAA") should be(Seq(MatchedBarcode("AAAAAAAAAAAAAAAAAAAA", 0))) - reference.find("NAAAAAAAAAAAAAAAAAAA") should be(Seq(MatchedBarcode("AAAAAAAAAAAAAAAAAAAA", 1))) - reference.find("AAAAAAAAAAAAAAAAAAAT") should be(Seq(MatchedBarcode("AAAAAAAAAAAAAAAAAAAA", 1))) + val _ = reference.find("AAAAAAAAAAAAAAAAAAAA") should be(Seq(MatchedBarcode("AAAAAAAAAAAAAAAAAAAA", 0))) + val _ = reference.find("NAAAAAAAAAAAAAAAAAAA") should be(Seq(MatchedBarcode("AAAAAAAAAAAAAAAAAAAA", 1))) + val _ = reference.find("AAAAAAAAAAAAAAAAAAAT") should be(Seq(MatchedBarcode("AAAAAAAAAAAAAAAAAAAA", 1))) reference.find("NAAAAAAAAAAAAAAAAAAT") should be(Seq()) } @@ -56,7 +56,7 @@ class VariantReferenceTest extends AnyFlatSpec { val barcodes = Seq(ReferenceEntry("AAAAAAAAAAAAAAAAAAAA", "One"), ReferenceEntry("AAAAAAAAAAAAAAAAAAAT", "Two")) val reference1 = VariantReference(barcodes, _.dropRight(1), includeAmbiguous = false) - reference1.find("AAAAAAAAAAAAAAAAAAA") should be(Seq()) + val _ = reference1.find("AAAAAAAAAAAAAAAAAAA") should be(Seq()) val reference2 = VariantReference(barcodes, _.dropRight(1), includeAmbiguous = true) reference2.find("AAAAAAAAAAAAAAAAAAA").sorted should be(barcodes.map(bc => MatchedBarcode(bc.dnaBarcode, 0)).sorted) @@ -68,7 +68,7 @@ class VariantReferenceTest extends AnyFlatSpec { val barcodes = Seq(ReferenceEntry("AAAAAAAAAAAAAAAAAAAA", "One"), ReferenceEntry("AAAAAAAAAAAAAAAAAATA", "Two")) val reference1 = VariantReference(barcodes, _.dropRight(1), includeAmbiguous = false) - reference1.find("AAAAAAAAAAAAAAAAAAN") should be(Seq()) + val _ = reference1.find("AAAAAAAAAAAAAAAAAAN") should be(Seq()) val reference2 = VariantReference(barcodes, _.dropRight(1), includeAmbiguous = true) reference2.find("AAAAAAAAAAAAAAAAAAN").sorted should be(barcodes.map(bc => MatchedBarcode(bc.dnaBarcode, 1)).sorted) diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/BarcodeCountsTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/BarcodeCountsTest.scala index b7ca23b..8d6368c 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/BarcodeCountsTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/BarcodeCountsTest.scala @@ -94,7 +94,7 @@ class BarcodeCountsTest extends FunSuite { val ret = PoolQ.runProcess(barcodes, consumer) val state = ret.get.state - BarcodeCountsWriter.write(outputFile, state.known, rowReference, colReference, PoolQ2Dialect) + val _ = BarcodeCountsWriter.write(outputFile, state.known, rowReference, colReference, PoolQ2Dialect) val expected = s"""Construct Barcode\tConstruct IDs\t$SampleBarcode1\t$SampleBarcode2\t$SampleBarcode3\t$SampleBarcode4 @@ -118,7 +118,7 @@ class BarcodeCountsTest extends FunSuite { val ret = PoolQ.runProcess(barcodes, consumer) val state = ret.get.state - BarcodeCountsWriter.write(outputFile, state.known, rowReference, colReference, GctDialect) + val _ = BarcodeCountsWriter.write(outputFile, state.known, rowReference, colReference, GctDialect) val expected = s"""#1.2 @@ -174,17 +174,17 @@ class BarcodeCountsTest extends FunSuite { new OpenHashMapHistogram ) - state.known.increment(None, (brdn01, eh2)) - state.known.increment(a01.some, (brdn01, eh1)) - state.known.increment(a01.some, (brdn01, eh1)) - state.known.increment(a01.some, (brdn01, eh2)) - state.known.increment(e09.some, (brdn01, eh1)) + val _ = state.known.increment(None, (brdn01, eh2)) + val _ = state.known.increment(a01.some, (brdn01, eh1)) + val _ = state.known.increment(a01.some, (brdn01, eh1)) + val _ = state.known.increment(a01.some, (brdn01, eh2)) + val _ = state.known.increment(e09.some, (brdn01, eh1)) - state.known.increment(a03.some, (brdn02, eh1)) - state.known.increment(a03.some, (brdn02, sea2)) + val _ = state.known.increment(a03.some, (brdn02, eh1)) + val _ = state.known.increment(a03.some, (brdn02, sea2)) - state.known.increment(f02.some, (brdn03, sea1)) - state.known.increment(a03.some, (brdn03, sea1)) + val _ = state.known.increment(f02.some, (brdn03, sea1)) + val _ = state.known.increment(a03.some, (brdn03, sea1)) val aggregateOutputFile = Files.createTempFile("barcode-counts-file-test-umi-", ".txt") @@ -200,7 +200,7 @@ class BarcodeCountsTest extends FunSuite { } try { - BarcodeCountsWriter.write( + val _ = BarcodeCountsWriter.write( aggregateOutputFile, aggregateOutputFile.getParent.some, state.known, diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/CorrelationFileTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/CorrelationFileTest.scala index e9a60b4..b53b9d4 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/CorrelationFileTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/CorrelationFileTest.scala @@ -80,7 +80,7 @@ class CorrelationFileTest extends AnyFlatSpec { val state = ret.get.state val normalizedCounts = LogNormalizedCountsWriter.logNormalizedCounts(state.known, rowReference, colReference) - CorrelationFileWriter.write(outputFile, normalizedCounts, rowReference, colReference) + val _ = CorrelationFileWriter.write(outputFile, normalizedCounts, rowReference, colReference) val expected = s"""\t$Condition1\t$Condition2\t$Condition3 @@ -115,7 +115,7 @@ class CorrelationFileTest extends AnyFlatSpec { val normalizedCounts = LogNormalizedCountsWriter.logNormalizedCounts(state.known, rowReference, singleCondRef) // we've set a trap - if we try to compute a correlation, the library code should throw an exception - noException should be thrownBy { + val _ = noException should be thrownBy { CorrelationFileWriter.write(outputFile, normalizedCounts, rowReference, singleCondRef) } @@ -146,7 +146,7 @@ class CorrelationFileTest extends AnyFlatSpec { val normalizedCounts = LogNormalizedCountsWriter.logNormalizedCounts(state.known, rowReference, singleCondRef) // we've set a trap - if we try to compute a correlation, the library code should throw an exception - noException should be thrownBy { + val _ = noException should be thrownBy { CorrelationFileWriter.write(outputFile, normalizedCounts, rowReference, singleCondRef) } diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/CountsTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/CountsTest.scala index eedde56..951f408 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/CountsTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/CountsTest.scala @@ -99,7 +99,7 @@ class CountsTest extends FunSuite { val ret = PoolQ.runProcess(barcodes, consumer) val state = ret.get.state - CountsWriter.write(outputFile, state.known, rowReference, colReference, PoolQ2Dialect) + val _ = CountsWriter.write(outputFile, state.known, rowReference, colReference, PoolQ2Dialect) val expected = s"""Construct Barcode\tConstruct IDs\t$Condition1\t$Condition2\t$Condition3 @@ -134,7 +134,7 @@ class CountsTest extends FunSuite { includeAmbiguous = false ) - CountsWriter.write(outputFile, state.known, rowReference2, colReference, PoolQ2Dialect) + val _ = CountsWriter.write(outputFile, state.known, rowReference2, colReference, PoolQ2Dialect) val expected = s"""Construct Barcode\tConstruct IDs\t$Condition1\t$Condition2\t$Condition3 @@ -156,7 +156,7 @@ class CountsTest extends FunSuite { val ret = PoolQ.runProcess(barcodes, consumer) val state = ret.get.state - CountsWriter.write(outputFile, state.known, rowReference, colReference, GctDialect) + val _ = CountsWriter.write(outputFile, state.known, rowReference, colReference, GctDialect) val expected = s"""#1.2 @@ -212,17 +212,17 @@ class CountsTest extends FunSuite { new OpenHashMapHistogram ) - state.known.increment(None, (brdn01, eh2)) - state.known.increment(a01.some, (brdn01, eh1)) - state.known.increment(a01.some, (brdn01, eh1)) - state.known.increment(a01.some, (brdn01, eh2)) - state.known.increment(e09.some, (brdn01, eh1)) + val _ = state.known.increment(None, (brdn01, eh2)) + val _ = state.known.increment(a01.some, (brdn01, eh1)) + val _ = state.known.increment(a01.some, (brdn01, eh1)) + val _ = state.known.increment(a01.some, (brdn01, eh2)) + val _ = state.known.increment(e09.some, (brdn01, eh1)) - state.known.increment(a03.some, (brdn02, eh1)) - state.known.increment(a03.some, (brdn02, sea2)) + val _ = state.known.increment(a03.some, (brdn02, eh1)) + val _ = state.known.increment(a03.some, (brdn02, sea2)) - state.known.increment(f02.some, (brdn03, sea1)) - state.known.increment(a03.some, (brdn03, sea1)) + val _ = state.known.increment(f02.some, (brdn03, sea1)) + val _ = state.known.increment(a03.some, (brdn03, sea1)) val aggregateOutputFile = Files.createTempFile("counts-file-test-umi-", ".txt") @@ -238,7 +238,7 @@ class CountsTest extends FunSuite { } try { - CountsWriter.write( + val _ = CountsWriter.write( aggregateOutputFile, aggregateOutputFile.getParent.some, state.known, diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/RunInfoWriterTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/RunInfoWriterTest.scala index 74863b4..b5c0a43 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/RunInfoWriterTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/RunInfoWriterTest.scala @@ -41,7 +41,7 @@ class RunInfoWriterTest extends FunSuite { colBarcodePolicyStr = "FIXED@0", reportsDialect = PoolQ2Dialect ) - RunInfoWriter.write(outputFile, config) + val _ = RunInfoWriter.write(outputFile, config) val expected = s"""PoolQ version: ${BuildInfo.version} diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UmiQualityTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UmiQualityTest.scala index 0a1ce2d..8b884bd 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UmiQualityTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UmiQualityTest.scala @@ -49,7 +49,7 @@ class UmiQualityTest extends FunSuite with TestResources { val file = Files.createTempFile("umi-quality-", ".txt") try { - UmiQualityWriter.write(file, state) + val _ = UmiQualityWriter.write(file, state) // read the file, split into lines, drop the 1st header val reportContents = contents(file).split("\n", -1).drop(1) diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequenceFileWriterTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequenceFileWriterTest.scala index b93d54a..4732d8c 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequenceFileWriterTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequenceFileWriterTest.scala @@ -35,7 +35,7 @@ class UnexpectedSequenceFileWriterTest extends AnyFlatSpec { UnexpectedSequenceWriter.truncateToN(h, r, 3) - r.keySet should be(Set(1L, 2L, 4L)) + val _ = r.keySet should be(Set(1L, 2L, 4L)) h.keySet().iterator().asScala.toSet should be(Set(1L, 2L, 4L)) } diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequencesTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequencesTest.scala index bb79049..f95cce3 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequencesTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/reports/UnexpectedSequencesTest.scala @@ -76,9 +76,9 @@ class UnexpectedSequencesTest extends AnyFlatSpec { new ScoringConsumer(rowReference, colReference, countAmbiguous = true, false, None, Some(cachePath), false) // run PoolQ and write the file - PoolQ.runProcess(barcodes, consumer) + val _ = PoolQ.runProcess(barcodes, consumer) - UnexpectedSequenceWriter.write(outputFile, cachePath, 100, colReference, Some(globalReference)) + val _ = UnexpectedSequenceWriter.write(outputFile, cachePath, 100, colReference, Some(globalReference)) val expected = s"""Sequence\tTotal\tAAAA\tAAAT\tCCCC\tCCCG\tPotential IDs diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/seq/SeqPackageTest.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/seq/SeqPackageTest.scala index 267ff9d..4367b1a 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/seq/SeqPackageTest.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/seq/SeqPackageTest.scala @@ -14,8 +14,8 @@ import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks._ class SeqPackageTest extends AnyFlatSpec { "complement" should "complement a string of DNA" in { - complement("") should be("") - complement("ACGT") should be("TGCA") + val _ = complement("") should be("") + val _ = complement("ACGT") should be("TGCA") complement("NAATTTG") should be("NTTAAAC") } @@ -24,8 +24,8 @@ class SeqPackageTest extends AnyFlatSpec { } "reverseComplement" should "reverse complement a string of DNA" in { - reverseComplement("") should be("") - reverseComplement("ACGT") should be("ACGT") + val _ = reverseComplement("") should be("") + val _ = reverseComplement("ACGT") should be("ACGT") reverseComplement("NTTGTATTTA") should be("TAAATACAAN") } @@ -41,8 +41,8 @@ class SeqPackageTest extends AnyFlatSpec { forAll(barcode, barcode) { (x, y) => val xydist = countMismatches(x, y) if (x != y) { - xydist should be > 0 - countMismatches(x, x) should be(0) + val _ = xydist should be > 0 + val _ = countMismatches(x, x) should be(0) countMismatches(y, y) should be(0) } else xydist should be(0) } @@ -73,10 +73,10 @@ class SeqPackageTest extends AnyFlatSpec { } "nCount" should "return at most max Ns" in { - nCount("AAANAN".toCharArray, 0) should be(1) - nCount("AAANAN".toCharArray, 1) should be(1) - nCount("AAANAN".toCharArray, 2) should be(2) - nCount("AAANAN".toCharArray, 3) should be(2) + val _ = nCount("AAANAN".toCharArray, 0) should be(1) + val _ = nCount("AAANAN".toCharArray, 1) should be(1) + val _ = nCount("AAANAN".toCharArray, 2) should be(2) + val _ = nCount("AAANAN".toCharArray, 3) should be(2) nCount("TGNTA".toCharArray, 0) should be(1) } diff --git a/src/test/scala/org/broadinstitute/gpp/poolq3/testutil/package.scala b/src/test/scala/org/broadinstitute/gpp/poolq3/testutil/package.scala index 12f0c00..9a9273a 100644 --- a/src/test/scala/org/broadinstitute/gpp/poolq3/testutil/package.scala +++ b/src/test/scala/org/broadinstitute/gpp/poolq3/testutil/package.scala @@ -10,14 +10,14 @@ import java.nio.file.{Path => JPath} import scala.io.Source import scala.util.Using -import cats.effect.{Async, Resource} +import cats.effect.Resource import fs2.io.file.Files package object testutil { def contents(p: JPath): String = Using.resource(Source.fromFile(p.toFile))(_.mkString) - def tempFile[F[_]: Async](prefix: String, suffix: String): Resource[F, JPath] = + def tempFile[F[_]: Files](prefix: String, suffix: String): Resource[F, JPath] = Files[F].tempFile(None, prefix, suffix, None).map(_.toNioPath) }