Stringtie.scala 2.34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/**
  * Biopet is built on top of GATK Queue for building bioinformatic
  * pipelines. It is mainly intended to support LUMC SHARK cluster which is running
  * SGE. But other types of HPC that are supported by GATK Queue (such as PBS)
  * should also be able to execute Biopet tools and pipelines.
  *
  * Copyright 2014 Sequencing Analysis Support Core - Leiden University Medical Center
  *
  * Contact us at: sasc@lumc.nl
  *
  * A dual licensing mode is applied. The source code within this project is freely available for non-commercial use under an AGPL
  * license; For commercial users or users who do not want to follow the AGPL
  * license, please contact us to obtain a separate license.
  */
package nl.lumc.sasc.biopet.pipelines.gentrap.measures

import nl.lumc.sasc.biopet.core.annotations.AnnotationGtf
import nl.lumc.sasc.biopet.extensions.stringtie.{StringtieMerge, Stringtie => StringtieTool}
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.queue.QScript

/**
  * Created by pjvan_thof on 1/12/16.
  */
pjvan_thof's avatar
pjvan_thof committed
25
class Stringtie(val parent: Configurable) extends QScript with Measurement with AnnotationGtf {
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
  def mergeArgs = MergeArgs(idCols = List(1), valCol = 2, fallback = "0")

  /** Pipeline itself */
  def biopetScript(): Unit = {
    val sampleGtfFiles: List[File] = bamFiles.map {
      case (id, file) =>
        val sampleDir = new File(outputDir, id)
        val stringtie = new StringtieTool(this)
        stringtie.inputBam = file
        stringtie.l = Some(id)
        stringtie.referenceGtf = Some(annotationGtf)
        stringtie.outputGtf = new File(sampleDir, s"$id.gtf")
        stringtie.geneAbundances = Some(new File(sampleDir, s"$id.gene_abund.tab"))
        stringtie.referenceCoverage = Some(new File(sampleDir, s"$id.cov_refs.gtf"))
        add(stringtie)
        stringtie.outputGtf
    }.toList

    val stringtieMerge = new StringtieMerge(this)
    stringtieMerge.inputGtfs = sampleGtfFiles
    stringtieMerge.referenceGtf = Some(annotationGtf)
pjvan_thof's avatar
pjvan_thof committed
47
    stringtieMerge.outputGtf = stringtieMergeOutput
48 49 50 51 52
    add(stringtieMerge)

    addSummaryJobs()
  }

pjvan_thof's avatar
pjvan_thof committed
53 54
  def stringtieMergeOutput: File = new File(outputDir, "stringtie.merged.gtf")

55
  override def summaryFiles: Map[String, File] =
pjvan_thof's avatar
pjvan_thof committed
56 57
    super.summaryFiles ++ Map("annotation_gtf" -> annotationGtf,
                              "stringtie_merged" -> stringtieMergeOutput)
58
}