Skip to content

Commit

Permalink
add kallisto quantification
Browse files Browse the repository at this point in the history
  • Loading branch information
hpratt committed May 17, 2020
1 parent f888f72 commit 975c69d
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 1 deletion.
2 changes: 1 addition & 1 deletion workflow/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "com.genomealmanac.rnaseq"
version = "1.0.0"
version = "1.1.0"
val artifactID = "rnaseq-workflow"

repositories {
Expand Down
54 changes: 54 additions & 0 deletions workflow/src/main/kotlin/workflow/task/Kallisto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package workflow.task

import krews.core.WorkflowBuilder
import krews.core.*
import krews.file.File
import krews.file.OutputFile
import org.reactivestreams.Publisher

data class KallistoParams (
val index: File,
val fragmentLength: Int? = 100,
val sdFragmentLength: Int? = 10,
val strandedness: String = "unstranded",
val cores: Int = 1
)

data class KallistoInput (
val r1: File,
val r2: File? = null,
val name: String
)

data class KallistoOutput (
val name: String,
val quantifications: File
)

fun WorkflowBuilder.kallistoTask(name: String, i: Publisher<KallistoInput>)
= this.task<KallistoInput, KallistoOutput>(name, i) {

val params = taskParams<KallistoParams>()
dockerImage = "docker.pkg.github.com/krews-community/rnaseq-kallisto-task/rnaseq-kallisto:1.1.0"
val prefix = "${input.name}"

output = KallistoOutput(
name = input.name,
quantifications = OutputFile("${prefix}.abundance.tsv")
)

command = """
java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 \
-jar /app/kallisto.jar quant \
--index ${params.index.dockerPath} \
--output-directory ${outputsDir} \
--cores ${params.cores} \
--strandedness ${params.strandedness} \
${ if (input.r2 === null) "--fragment-length ${params.fragmentLength}" else "" } \
${ if (input.r2 === null) "--sd-fragment-length ${params.sdFragmentLength}" else "" } \
--output-prefix ${input.name} \
--r1 ${input.r1.dockerPath} \
${ if (input.r2 !== null) "--r2 ${input.r2!!.dockerPath}" else "" }
"""

}
6 changes: 6 additions & 0 deletions workflow/src/main/kotlin/workflow/workflow/RnaSeqWorkflow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ val rnaSeqWorkflow = workflow("encode-rnaseq-workflow") {
}.toFlux()
val mergeFastqTask = MergeFastqTask("merge", mergeFastqInput)

/* run kallisto quant for experiments starting from FASTQs */
val kallistoInput = mergeFastqTask.map {
KallistoInput(it.mergedFileR1, it.mergedFileR2, it.repName)
}
kallistoTask("kallisto", kallistoInput)

/* create task to align reads for experiments starting from FASTQs */
val starInput = mergeFastqTask
.map { AlignerInput(it.mergedFileR1, it.mergedFileR2, it.repName, it.pairedEnd) }
Expand Down
12 changes: 12 additions & 0 deletions workflow/src/test/kotlin/workflow/AppTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ class AppTests {
local-path = "$testDir/test.index.tar.gz"
}
}
task.kallisto.params {
index = {
-type = "krews.file.LocalInputFile"
local-path = "$testDir/hg38.chrM.kallisto.idx"
}
fragment-length = 100
sd-fragment-length = 10
}
""".trimIndent()

@BeforeAll
Expand All @@ -104,6 +113,9 @@ class AppTests {
/* FASTQ merging task */
assertMD5(outputsDir.resolve("testrep1.merged.r1.fastq.gz"), "6b0d6ea05ab99a717a247e0b6ace5228")

/* kallisto task */
assertMD5(outputsDir.resolve("testrep1.abundance.tsv"), "5f9faa00904649814f7e030790164e6a")

/* STAR task */
assertMD5(outputsDir.resolve("testrep1_anno.bam"), "1644cde899e6e71de60b669855e315bc")
assertMD5(outputsDir.resolve("testrep1_anno_flagstat.txt"), "87c78efa9ad0a76dec66ab5c8e8e7754")
Expand Down
Binary file not shown.

0 comments on commit 975c69d

Please sign in to comment.