Skip to content

Commit

Permalink
chore: increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
clintval committed Jul 28, 2024
1 parent 4c19d02 commit 87e6ca7
Showing 1 changed file with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class DisambiguateTest extends UnitSpec {
val input = builder.toTempFile(deleteOnExit = true)
val prefix = PathUtil.pathTo(dir.toString, more = "insilico")

val disambiguate = new Disambiguate(input = Seq(input), prefix = prefix)
val disambiguate = new Disambiguate(input = Seq(input), prefix = prefix, referenceNames = Seq("hg38"))
disambiguate.execute()

val source = SamSource(PathUtil.pathTo(Seq(prefix, assembly).mkString(".") + BamExtension))
Expand Down Expand Up @@ -154,6 +154,46 @@ class DisambiguateTest extends UnitSpec {
Io.assertWritableDirectory(PathUtil.pathTo(dir.toString, more = "ambiguous-alignments")) // will raise exception if non-existent.
}

it should "write out ambiguous templates to ambiguous-specific BAM files" in {
val humanAssembly: String = "hg38"
val mouseAssembly: String = "mm10"
val dir: DirPath = Io.makeTempDir("disambiguate")
//dir.toFile.deleteOnExit()

val humanBuilder = new SamBuilder(sort = Some(SamOrder.Queryname))
val mouseBuilder = new SamBuilder(sort = Some(SamOrder.Queryname))

val humanPair = humanBuilder.addPair(name = "pair", attrs = Map(NM.toString -> 2, AS.toString -> 32), start1 = 2, start2 = 101)
val mousePair = mouseBuilder.addPair(name = "pair", attrs = Map(NM.toString -> 2, AS.toString -> 32), start1 = 2, start2 = 101)

humanBuilder.header.getSequenceDictionary.getSequences.forEach { seq: SAMSequenceRecord => val _ = seq.setAssembly(humanAssembly) }
mouseBuilder.header.getSequenceDictionary.getSequences.forEach { seq: SAMSequenceRecord => val _ = seq.setAssembly(mouseAssembly) }

val prefix = PathUtil.pathTo(dir.toString, more = "insilico")

val humanBam = humanBuilder.toTempFile(deleteOnExit = false)
val mouseBam = mouseBuilder.toTempFile(deleteOnExit = false)

val disambiguate = new Disambiguate(input = Seq(mouseBam, humanBam), prefix = prefix)
disambiguate.execute()

val humanSource = SamSource(PathUtil.pathTo(Seq(prefix, humanAssembly).mkString(".") + BamExtension))
val mouseSource = SamSource(PathUtil.pathTo(Seq(prefix, mouseAssembly).mkString(".") + BamExtension))

humanSource.iterator.toSeq shouldBe empty
mouseSource.iterator.toSeq shouldBe empty

val ambiguousAlignments = PathUtil.pathTo(dir.toString, more = "ambiguous-alignments")

Io.assertWritableDirectory(ambiguousAlignments) // will raise exception if non-existent.

val ambiguousHumanSource = SamSource(ambiguousAlignments.resolve(PathUtil.replaceExtension(humanBam.getFileName, ".ambiguous" + BamExtension)))
val ambiguousMouseSource = SamSource(ambiguousAlignments.resolve(PathUtil.replaceExtension(mouseBam.getFileName, ".ambiguous" + BamExtension)))

ambiguousHumanSource.map(_.name).toSeq should contain theSameElementsInOrderAs humanPair.map(_.name)
ambiguousMouseSource.map(_.name).toSeq should contain theSameElementsInOrderAs mousePair.map(_.name)
}

"NeoNeodisambiguate" should "run end-to-end via the CLI entrypoint" in {
val humanAssembly: String = "hg38"
val mouseAssembly: String = "mm10"
Expand Down

0 comments on commit 87e6ca7

Please sign in to comment.