RunGubbins.scala 3.38 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
 * 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 that are
 * not part of GATK Queue 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.
 */
16
17
18
19
20
package nl.lumc.sasc.biopet.extensions

import java.io.File

import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
Peter van 't Hof's avatar
Peter van 't Hof committed
21
import nl.lumc.sasc.biopet.utils.config.Configurable
22
23
import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output }

Peter van 't Hof's avatar
Peter van 't Hof committed
24
25
26
27
28
/**
 * Extension for gubbins
 * See; https://github.com/sanger-pathogens/gubbins
 * No version known
 */
29
30
31
class RunGubbins(val root: Configurable) extends BiopetCommandLineFunction {

  @Input(doc = "Contaminants", required = false)
Peter van 't Hof's avatar
Peter van 't Hof committed
32
  var startingTree: Option[File] = config("starting_tree")
33
34
35
36
37
38
39
40

  @Input(doc = "Fasta file", shortName = "FQ")
  var fastafile: File = _

  @Output(doc = "Output", shortName = "out")
  var outputFiles: List[File] = Nil

  @Argument(required = true)
Peter van 't Hof's avatar
Peter van 't Hof committed
41
  var outputDirectory: File = null
42
43

  executable = config("exe", default = "run_gubbins.py")
Peter van 't Hof's avatar
Peter van 't Hof committed
44
45
46
  var outgroup: Option[String] = config("outgroup")
  var filterPercentage: Option[String] = config("filter_percentage")
  var treeBuilder: Option[String] = config("tree_builder")
47
48
  var iterations: Option[Int] = config("iterations")
  var minSnps: Option[Int] = config("min_snps")
Peter van 't Hof's avatar
Peter van 't Hof committed
49
  var convergeMethod: Option[String] = config("converge_method")
Peter van 't Hof's avatar
Peter van 't Hof committed
50
  var useTimeStamp: Boolean = config("use_time_stamp", default = false)
Peter van 't Hof's avatar
Peter van 't Hof committed
51
  var prefix: Option[String] = config("prefix")
Peter van 't Hof's avatar
Peter van 't Hof committed
52
53
  var verbose: Boolean = config("verbose", default = false)
  var noCleanup: Boolean = config("no_cleanup", default = false)
54

Peter van 't Hof's avatar
Peter van 't Hof committed
55
  /** Set correct output files */
Peter van 't Hof's avatar
Peter van 't Hof committed
56
57
  override def beforeGraph(): Unit = {
    super.beforeGraph()
Peter van 't Hof's avatar
Peter van 't Hof committed
58
59
    require(outputDirectory != null)
    jobLocalDir = outputDirectory
Peter van 't Hof's avatar
Peter van 't Hof committed
60
    if (prefix.isEmpty) prefix = Some(fastafile.getName)
61
62
63
64
65
66
67
68
    val out: List[String] = List(".recombination_predictions.embl",
      ".recombination_predictions.gff",
      ".branch_base_reconstruction.embl",
      ".summary_of_snp_distribution.vcf",
      ".per_branch_statistics.csv",
      ".filtered_polymorphic_sites.fasta",
      ".filtered_polymorphic_sites.phylip",
      ".final_tree.tre")
Peter van 't Hof's avatar
Peter van 't Hof committed
69
    for (t <- out) outputFiles ::= new File(outputDirectory + File.separator + prefix.getOrElse("gubbins") + t)
70
71
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
72
  /** Return command to execute */
Peter van 't Hof's avatar
Peter van 't Hof committed
73
  def cmdLine = required("cd", outputDirectory) + " && " + required(executable) +
74
75
76
77
78
79
80
81
82
83
84
85
86
    optional("--outgroup", outgroup) +
    optional("--starting_tree", startingTree) +
    optional("--filter_percentage", filterPercentage) +
    optional("--tree_builder", treeBuilder) +
    optional("--iterations", iterations) +
    optional("--min_snps", minSnps) +
    optional("--converge_method", convergeMethod) +
    conditional(useTimeStamp, "--use_time_stamp") +
    optional("--prefix", prefix) +
    conditional(verbose, "--verbose") +
    conditional(noCleanup, "--no_cleanup") +
    required(fastafile)
}