Md5sum.scala 2.13 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.
 */
Peter van 't Hof's avatar
Peter van 't Hof committed
16
17
18
19
package nl.lumc.sasc.biopet.extensions

import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
import nl.lumc.sasc.biopet.core.config.Configurable
Peter van 't Hof's avatar
Peter van 't Hof committed
20
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
Peter van 't Hof's avatar
Peter van 't Hof committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.io.File
import argonaut._, Argonaut._
import scalaz._, Scalaz._
import scala.io.Source

class Md5sum(val root: Configurable) extends BiopetCommandLineFunction {
  @Input(doc = "Input")
  var input: File = _

  @Output(doc = "Output")
  var output: File = _

  executable = config("exe", default = "md5sum")

Peter van 't Hof's avatar
Peter van 't Hof committed
35
  /** return commandline to execute */
Peter van 't Hof's avatar
Peter van 't Hof committed
36
37
38
39
40
  def cmdLine = required(executable) + required(input) + " > " + required(output)

  def getSummary: Json = {
    val data = Source.fromFile(output).mkString.split(" ")
    return ("path" := output.getAbsolutePath) ->:
Peter van 't Hof's avatar
Peter van 't Hof committed
41
      ("md5sum" := data(0)) ->:
Peter van 't Hof's avatar
Peter van 't Hof committed
42
43
44
45
      jEmptyObject
  }
}

Peter van 't Hof's avatar
Peter van 't Hof committed
46
/** Object for constructors for md5sum */
Peter van 't Hof's avatar
Peter van 't Hof committed
47
object Md5sum {
Peter van 't Hof's avatar
Peter van 't Hof committed
48
  /** Makes md5sum with md5 file in given dir */
Peter van 't Hof's avatar
Peter van 't Hof committed
49
  def apply(root: Configurable, fastqfile: File, outDir: File): Md5sum = {
Peter van 't Hof's avatar
Peter van 't Hof committed
50
51
    val md5sum = new Md5sum(root)
    md5sum.input = fastqfile
Peter van 't Hof's avatar
Peter van 't Hof committed
52
    md5sum.output = new File(outDir, fastqfile.getName + ".md5")
Peter van 't Hof's avatar
Peter van 't Hof committed
53
54
    return md5sum
  }
55

Peter van 't Hof's avatar
Peter van 't Hof committed
56
  /** Makes md5sum with md5 file in same dir as input file */
57
58
59
60
61
62
  def apply(root: Configurable, file: File): Md5sum = {
    val md5sum = new Md5sum(root)
    md5sum.input = file
    md5sum.output = new File(file.getParentFile, file.getName + ".md5")
    return md5sum
  }
Peter van 't Hof's avatar
Peter van 't Hof committed
63
}