Cuffquant.scala 6.18 KB
Newer Older
bow's avatar
bow committed
1 2 3 4 5 6 7 8 9 10
/**
 * 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
 *
11
 * A dual licensing mode is applied. The source code within this project is freely available for non-commercial use under an AGPL
bow's avatar
bow committed
12 13 14 15 16 17 18
 * 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.extensions

import java.io.File

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

import scala.util.matching.Regex
bow's avatar
bow committed
24 25 26 27 28

/**
 * Wrapper for the cuffquant command line tool.
 * Written based on cuffquant version v2.2.1 (md5: 0765b82b11db9256f5be341a7da884d6)
 */
29
class Cuffquant(val root: Configurable) extends BiopetCommandLineFunction with Version {
bow's avatar
bow committed
30 31 32 33 34

  /** default executable */
  executable = config("exe", default = "cuffquant")

  /** input file */
35 36 37 38 39
  @Input(doc = "Input file (SAM or BAM)", required = true) /*
    in cuffquant this input: sample1_rep1.sam,sample1_rep2.sam sample2_rep1.sam,sample2_rep2.sam
    means we have 2 samples, each with 2 replicates
    so our input is a list of lists of Files
   */
Peter van 't Hof's avatar
Peter van 't Hof committed
40
  var input: List[List[File]] = Nil
bow's avatar
bow committed
41 42 43

  /** input GTF file */
  @Input(doc = "Input GTF file", required = true)
Peter van 't Hof's avatar
Peter van 't Hof committed
44
  var transcriptsGtf: File = _
bow's avatar
bow committed
45 46 47 48

  /** output file, computed automatically from output directory */
  @Output(doc = "Output CXB file")
  lazy val outputCxb: File = {
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
49
    require(outputDir != null,
bow's avatar
bow committed
50 51
      "Can not set Cuffquant CXB output while input file and/or output directory is not defined")
    // cufflinks always outputs a transcripts.gtf file in the output directory
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
52
    new File(outputDir, "abundances.cxb")
bow's avatar
bow committed
53 54 55
  }

  /** write all output files to this directory [./] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
56
  var outputDir: File = config("output_dir", default = new File("."))
bow's avatar
bow committed
57 58

  /** ignore all alignment within transcripts in this file */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
59
  var maskFile: Option[File] = config("mask_file")
bow's avatar
bow committed
60 61

  /** use bias correction - reference fasta required [NULL] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
62
  var fragBiasCorrect: Option[String] = config("frag_bias_correct")
bow's avatar
bow committed
63 64

  /** use 'rescue method' for multi-reads (more accurate) [FALSE] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
65
  var multiReadCorrect: Boolean = config("multi_read_correct", default = false)
bow's avatar
bow committed
66 67

  /** number of threads used during analysis [1] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
68
  var numThreads: Option[Int] = config("num_threads")
bow's avatar
bow committed
69 70

  /** library prep used for input reads [below] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
71
  var libraryType: Option[String] = config("library_type")
bow's avatar
bow committed
72 73

  /** average fragment length (unpaired reads only) [200] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
74
  var fragLenMean: Option[Int] = config("frag_len_mean")
bow's avatar
bow committed
75 76

  /** fragment length std deviation (unpaired reads only) [80] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
77
  var fragLenStdDev: Option[Int] = config("frag_len_std_dev")
bow's avatar
bow committed
78 79

  /** minimum number of alignments in a locus for testing [10] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
80
  var minAlignmentCount: Option[Int] = config("min_alignment_count")
bow's avatar
bow committed
81 82

  /** maximum iterations allowed for MLE calculation [5000] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
83
  var maxMleIterations: Option[Int] = config("max_mle_iterations")
bow's avatar
bow committed
84 85 86 87 88 89 90 91 92 93 94

  /** log-friendly verbose processing (no progress bar) [FALSE] */
  var verbose: Boolean = config("verbose", default = false)

  /** log-friendly quiet processing (no progress bar) [FALSE] */
  var quiet: Boolean = config("quiet", default = false)

  /** value of random number generator seed [0] */
  var seed: Option[Int] = config("seed")

  /** do not contact server to check for update availability [FALSE] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
95
  var noUpdateCheck: Boolean = config("no_update_check", default = false)
bow's avatar
bow committed
96 97

  /** maximum fragments allowed in a bundle before skipping [500000] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
98
  var maxBundleFrags: Option[Int] = config("max_bundle_frags")
bow's avatar
bow committed
99 100

  /** Maximum number of alignments allowed per fragment [unlim] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
101
  var maxFragMultihits: Option[Int] = config("max_frag_multihits")
bow's avatar
bow committed
102 103

  /** No effective length correction [FALSE] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
104
  var noEffectiveLengthCorrection: Boolean = config("no_effective_length_correction", default = false)
bow's avatar
bow committed
105 106

  /** No length correction [FALSE] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
107
  var noLengthCorrection: Boolean = config("no_length_correction", default = false)
bow's avatar
bow committed
108 109

  /** Skip a random subset of reads this size [0.0] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
110
  var readSkipFraction: Option[Double] = config("read_skip_fraction")
bow's avatar
bow committed
111 112

  /** Break all read pairs [FALSE] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
113
  var noReadPairs: Boolean = config("no_read_pairs", default = false)
bow's avatar
bow committed
114 115

  /** Trim reads to be this long (keep 5' end) [none] */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
116
  var trimReadLength: Option[Int] = config("trim_read_length")
bow's avatar
bow committed
117 118

  /** Disable SCV correction */
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
119
  var noScvCorrection: Boolean = config("no_scv_correction", default = false)
bow's avatar
bow committed
120

Peter van 't Hof's avatar
Peter van 't Hof committed
121 122
  def versionRegex: Regex = """cuffquant v(.*)""".r
  def versionCommand: String = executable
Peter van 't Hof's avatar
Peter van 't Hof committed
123
  override def versionExitcode = List(0, 1)
bow's avatar
bow committed
124

Peter van 't Hof's avatar
Peter van 't Hof committed
125
  def cmdLine: String =
bow's avatar
bow committed
126
    required(executable) +
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
127 128 129 130 131 132 133 134 135 136
      required("--output-dir", outputDir) +
      optional("--mask-file", maskFile) +
      optional("--frag-bias-correct", fragBiasCorrect) +
      conditional(multiReadCorrect, "--multi-read-correct") +
      optional("--num-threads", numThreads) +
      optional("--library-type", libraryType) +
      optional("--frag-len-mean", fragLenMean) +
      optional("--frag-len-std-dev", fragLenStdDev) +
      optional("--min-alignment-count", minAlignmentCount) +
      optional("--max-mle-iterations", maxMleIterations) +
137 138 139
      conditional(verbose, "--verbose") +
      conditional(quiet, "--quiet") +
      optional("--seed", seed) +
Sander van der Zeeuw's avatar
Sander van der Zeeuw committed
140 141 142 143 144 145 146 147 148 149
      conditional(noUpdateCheck, "--no-update-check") +
      optional("--max-bundle-frags", maxBundleFrags) +
      optional("--max-frag-multihits", maxFragMultihits) +
      conditional(noEffectiveLengthCorrection, "--no-effective-length-correction") +
      conditional(noLengthCorrection, "--no-length-correction") +
      optional("--read-skip-fraction", readSkipFraction) +
      conditional(noReadPairs, "--no-read-pairs") +
      optional("--trim-read-length", trimReadLength) +
      conditional(noScvCorrection, "--no-scv-correction") +
      required(transcriptsGtf) +
150
      required(input.map(_.mkString(";").mkString(" ")))
bow's avatar
bow committed
151
}