GearsQiimeOpen.scala 2.41 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
/**
2
3
4
5
6
7
8
9
10
11
12
13
14
  * 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.
  */
Peter van 't Hof's avatar
Peter van 't Hof committed
15
16
17
18
19
20
21
22
23
24
package nl.lumc.sasc.biopet.pipelines.gears

import nl.lumc.sasc.biopet.core.SampleLibraryTag
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.extensions.qiime._
import nl.lumc.sasc.biopet.extensions.seqtk.SeqtkSample
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.queue.QScript

/**
25
26
27
28
29
30
  * Created by pjvan_thof on 12/4/15.
  */
class GearsQiimeOpen(val parent: Configurable)
    extends QScript
    with SummaryQScript
    with SampleLibraryTag {
Peter van 't Hof's avatar
Peter van 't Hof committed
31

32
  var fastaInput: File = _
Peter van 't Hof's avatar
Peter van 't Hof committed
33

Peter van 't Hof's avatar
Peter van 't Hof committed
34
  def init(): Unit = {
35
    require(fastaInput != null)
Peter van 't Hof's avatar
Peter van 't Hof committed
36
37
38
39
    require(sampleId.isDefined)
  }

  private var _otuMap: File = _
Peter van 't Hof's avatar
Peter van 't Hof committed
40
  def otuMap: File = _otuMap
Peter van 't Hof's avatar
Peter van 't Hof committed
41
42

  private var _otuTable: File = _
Peter van 't Hof's avatar
Peter van 't Hof committed
43
  def otuTable: File = _otuTable
Peter van 't Hof's avatar
Peter van 't Hof committed
44

Peter van 't Hof's avatar
Peter van 't Hof committed
45
  def biopetScript(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
46
47

    val openReference = new PickOpenReferenceOtus(this)
48
    openReference.inputFasta = addDownsample(fastaInput, new File(outputDir, s"downsample.fna"))
Peter van 't Hof's avatar
Peter van 't Hof committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    openReference.outputDir = new File(outputDir, "pick_open_reference_otus")
    add(openReference)
    _otuMap = openReference.otuMap
    _otuTable = openReference.otuTable

    addSummaryJobs()
  }

  /** Must return a map with used settings for this pipeline */
  def summarySettings: Map[String, Any] = Map()

  /** File to put in the summary for thie pipeline */
  def summaryFiles: Map[String, File] = Map("otu_table" -> otuTable, "otu_map" -> otuMap)

  val downSample: Option[Double] = config("downsample")

  def addDownsample(input: File, output: File): File = {
    downSample match {
      case Some(x) =>
        val seqtk = new SeqtkSample(this)
        seqtk.input = input
        seqtk.sample = x
        seqtk.output = output
        add(seqtk)
        output
      case _ => input
    }
  }
}