diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFasta.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFasta.scala index 33c26353d93c44b80c9f8750de4695eb60e4592a..66f5ba800899cda90d9a7c17c41c818c482667da 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFasta.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFasta.scala @@ -155,7 +155,7 @@ object BastyGenerateFasta extends ToolCommand { } } - protected var cmdArgs: Args = _ + protected implicit var cmdArgs: Args = _ private val chunkSize = 100000 /** @@ -253,7 +253,7 @@ object BastyGenerateFasta extends ToolCommand { } } - protected def writeVariantsOnly() { + protected[tools] def writeVariantsOnly() { val writer = new PrintWriter(cmdArgs.outputVariants) writer.println(">" + cmdArgs.outputName) val vcfReader = new VCFFileReader(cmdArgs.inputVcf, false) @@ -265,7 +265,10 @@ object BastyGenerateFasta extends ToolCommand { vcfReader.close() } - protected def getMaxAllele(vcfRecord: VariantContext): String = { + // TODO: what does this do? + // Seems to me it finds the allele in a sample with the highest AD value + // if this allele is shorter than the largest allele, it will append '-' to the string + protected[tools] def getMaxAllele(vcfRecord: VariantContext)(implicit cmdArgs: Args): String = { val maxSize = getLongestAllele(vcfRecord).getBases.length if (cmdArgs.sampleName == null) return fillAllele(vcfRecord.getReference.getBaseString, maxSize) diff --git a/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFastaTest.scala b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFastaTest.scala new file mode 100644 index 0000000000000000000000000000000000000000..48ff9cfe214aa289a9ac2a007b33b3d391d6100d --- /dev/null +++ b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/tools/BastyGenerateFastaTest.scala @@ -0,0 +1,41 @@ +package nl.lumc.sasc.biopet.tools + +import java.io.File +import java.nio.file.Paths + +import htsjdk.variant.vcf.VCFFileReader +import org.scalatest.Matchers +import org.scalatest.testng.TestNGSuite +import org.testng.annotations.Test +import org.scalatest.mock.MockitoSugar +import org.mockito.Mockito._ + +/** + * Created by ahbbollen on 13-8-15. + */ +class BastyGenerateFastaTest extends TestNGSuite with MockitoSugar with Matchers { + + import BastyGenerateFasta._ + private def resourcePath(p: String): String = { + Paths.get(getClass.getResource(p).toURI).toString + } + + val vepped_path = resourcePath("/VEP_oneline.vcf") + val vepped = new File(vepped_path) + + @Test def testGetMaxAllele = { + val reader = new VCFFileReader(vepped, false) + val record = reader.iterator().next() + + val child = mock[Args] + when(child.sampleName) thenReturn "Child_7006504" + val father = mock[Args] + when(father.sampleName) thenReturn "Father_7006506" + + + getMaxAllele(record)(child) shouldBe "C-" + getMaxAllele(record)(father) shouldBe "CA" + + } + +}