PindelConfig.scala 3.13 KB
Newer Older
1
2
3
4
5
/**
 * 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.
6
 *
7
 * Copyright 2014 Sequencing Analysis Support Core - Leiden University Medical Center
8
 *
9
 * Contact us at: sasc@lumc.nl
10
 *
11
12
13
14
 * 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.
15
 */
16
package nl.lumc.sasc.biopet.extensions.pindel
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction
import nl.lumc.sasc.biopet.core.PipelineCommand
import nl.lumc.sasc.biopet.core.ToolCommand
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
import java.io.File

class PindelConfig(val root: Configurable) extends BiopetJavaCommandLineFunction {
  javaMainClass = getClass.getName
  @Input(doc = "Bam File")
  var input: File = _

  @Output(doc = "Output Config file")
  var output: File = _
Peter van 't Hof's avatar
Peter van 't Hof committed
32
33

  @Argument(doc = "Insertsize")
34
  var insertsize: Option[Int] = _
Peter van 't Hof's avatar
Peter van 't Hof committed
35
36
37
38

  override def commandLine = super.commandLine +
    "-i" + required(input) +
    "-s" + required(insertsize) +
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    "-o" + required(output)
}

object PindelConfig extends ToolCommand {
  def apply(root: Configurable, input: File, output: File): PindelConfig = {
    val conf = new PindelConfig(root)
    conf.input = input
    conf.output = output
    return conf
  }

  def apply(root: Configurable, input: File, outputDir: String): PindelConfig = {
    val dir = if (outputDir.endsWith("/")) outputDir else outputDir + "/"
    val outputFile = new File(dir + swapExtension(input.getName))
    return apply(root, input, outputFile)
  }

  def apply(root: Configurable, input: File): PindelConfig = {
    return apply(root, input, new File(swapExtension(input.getAbsolutePath)))
  }

  private def swapExtension(inputFile: String) = inputFile.substring(0, inputFile.lastIndexOf(".bam")) + ".pindel.cfg"
Peter van 't Hof's avatar
Peter van 't Hof committed
61
62

  case class Args(inputbam: File = null, samplelabel: Option[String] = None, insertsize: Option[Int] = None) extends AbstractArgs
63
64

  class OptParser extends AbstractOptParser {
Peter van 't Hof's avatar
Peter van 't Hof committed
65
66
67
68
69
70
71
72
73
    opt[File]('i', "inputbam") required () valueName ("<bamfile/path>") action { (x, c) =>
      c.copy(inputbam = x)
    } text ("Please specify the input bam file")
    opt[String]('l', "samplelabel") valueName ("<sample label>") action { (x, c) =>
      c.copy(samplelabel = Some(x))
    } text ("Sample label is missing")
    opt[Int]('s', "insertsize") valueName ("<insertsize>") action { (x, c) =>
      c.copy(insertsize = Some(x))
    } text ("Insertsize is missing")
74
  }
Peter van 't Hof's avatar
Peter van 't Hof committed
75

76
77
78
79
80
81
  /**
   * @param args the command line arguments
   */
  def main(args: Array[String]): Unit = {
    val argsParser = new OptParser
    val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1)
Peter van 't Hof's avatar
Peter van 't Hof committed
82

83
84
85
86
87
    val input: File = commandArgs.inputbam

  }
}