Commit aa405ebc authored by Wai Yi Leung's avatar Wai Yi Leung
Browse files

Merge branch 'patch-versioning' into 'develop'

Patch versioning

For issue #143

See merge request !140
parents 9133b3b4 86604ddd
......@@ -16,11 +16,13 @@
package nl.lumc.sasc.biopet.core
import java.io.{ PrintWriter, StringWriter }
import java.util.Properties
import nl.lumc.sasc.biopet.core.BiopetExecutable._
import org.apache.log4j.Logger
import scala.io.Source
import org.apache.log4j.Logger
import nl.lumc.sasc.biopet.{ FullVersion, LastCommitHash }
import nl.lumc.sasc.biopet.core.BiopetExecutable._
trait BiopetExecutable extends Logging {
def pipelines: List[MainCommand]
......@@ -49,7 +51,7 @@ trait BiopetExecutable extends Logging {
u.mkString("\n\n")
}
"""
|Usage : java -jar BiopetFramework.jar {%s} <name> [args]
|Usage : java -jar <path/to/biopet.jar> {%s} <name> [args]
|Version : %s
|
|%s
......@@ -59,7 +61,7 @@ trait BiopetExecutable extends Logging {
| - license
|
|Questions or comments? Email sasc@lumc.nl or check out the project page at https://git.lumc.nl/biopet/biopet.git
""".stripMargin.format(modules.keys.mkString(","), getVersion, usage)
""".stripMargin.format(modules.keys.mkString(","), FullVersion, usage)
}
def checkModule(module: String) {
......@@ -81,7 +83,7 @@ trait BiopetExecutable extends Logging {
args match {
case Array("version") => {
println("version: " + getVersion)
println("version: " + FullVersion)
}
case Array("license") => {
println(getLicense)
......@@ -118,30 +120,16 @@ trait BiopetExecutable extends Logging {
}
}
def checkDirtyBuild(logger: Logger) {
val prop = new Properties()
prop.load(getClass.getClassLoader.getResourceAsStream("git.properties"))
val describeShort = prop.getProperty("git.commit.id.describe-short")
if (describeShort.endsWith("-dirty")) {
logger.warn("**********************************************************")
logger.warn("* This JAR was built while there are uncommited changes. *")
logger.warn("* Reproducible results are *not* guaranteed. *")
logger.warn("**********************************************************")
def checkDirtyBuild(logger: Logger): Unit =
if (LastCommitHash.endsWith("-dirty")) {
logger.warn("***********************************************************")
logger.warn("* This JAR was built while there were uncommited changes. *")
logger.warn("* Reproducible results are *not* guaranteed. *")
logger.warn("***********************************************************")
}
}
}
object BiopetExecutable {
def getVersion = {
getClass.getPackage.getImplementationVersion + " (" + getCommitHash + ")"
}
def getCommitHash = {
val prop = new Properties()
prop.load(getClass.getClassLoader.getResourceAsStream("git.properties"))
prop.getProperty("git.commit.id.abbrev")
}
def getLicense: String = {
val stream = getClass.getClassLoader.getResourceAsStream("nl/lumc/sasc/biopet/License.txt")
Source.fromInputStream(stream).getLines().mkString("\n", "\n", "\n")
......
......@@ -15,6 +15,8 @@
*/
package nl.lumc.sasc.biopet.core
import nl.lumc.sasc.biopet.FullVersion
/**
* Trait for biopet tools, sets some default args
*/
......@@ -45,7 +47,7 @@ trait ToolCommand extends MainCommand with Logging {
sys.exit(1)
} text ("Print usage")
opt[Unit]('v', "version") foreach { _ =>
System.err.println("Version: " + BiopetExecutable.getVersion)
System.err.println("Version: " + FullVersion)
sys.exit(1)
} text ("Print version")
}
......
......@@ -45,23 +45,24 @@
package nl.lumc.sasc.biopet.core.workaround
import java.io.File
import collection.JavaConversions._
import java.io.{ File, FileOutputStream }
import java.net.URL
import java.util.{ ResourceBundle, Arrays }
import org.apache.commons.io.FilenameUtils
import org.broadinstitute.gatk.utils.commandline._
import org.broadinstitute.gatk.queue.util._
import org.broadinstitute.gatk.queue.{ QCommandPlugin, QScript, QScriptManager }
import org.broadinstitute.gatk.queue.util.{ Logging => GatkLogging }
import org.broadinstitute.gatk.queue.engine.{ QStatusMessenger, QGraphSettings, QGraph }
import collection.JavaConversions._
import org.broadinstitute.gatk.utils.classloader.PluginManager
import org.broadinstitute.gatk.utils.exceptions.UserException
import org.broadinstitute.gatk.utils.io.IOUtils
import org.broadinstitute.gatk.utils.help.ApplicationDetails
import java.io.FileOutputStream
import java.net.URL
import java.util.{ ResourceBundle, Arrays }
import org.broadinstitute.gatk.utils.text.TextFormattingUtils
import org.apache.commons.io.FilenameUtils
import nl.lumc.sasc.biopet.core.BiopetExecutable
import nl.lumc.sasc.biopet.FullVersion
/**
* Entry point of Queue. Compiles and runs QScripts passed in to the command line.
......@@ -291,7 +292,7 @@ class BiopetQCommandLine extends CommandLineProgram with Logging {
}
private def createQueueHeader(): Seq[String] = {
Seq("Biopet version: " + BiopetExecutable.getVersion, "",
Seq("Biopet version: " + FullVersion, "",
"Based on GATK Queue",
// String.format("Queue v%s, Compiled %s", getQueueVersion, getBuildTimestamp),
"Copyright (c) 2012 The Broad Institute",
......
/**
* 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.
*/
package nl.lumc.sasc
import java.util.Properties
/**
* Common values and functions for the biopet package
*
* @author Wibowo Arindrarto <w.arindrarto@lumc.nl>
*/
package object biopet {
/** Latest git commit hash, with '-dirty' appended if any uncommited changes were present */
val LastCommitHash: String = {
val prop = new Properties()
prop.load(getClass.getClassLoader.getResourceAsStream("git.properties"))
val hash = prop.getProperty("git.commit.id.abbrev")
if (prop.getProperty("git.commit.id.describe-short").endsWith("-dirty")) s"$hash-dirty"
else hash
}
/** Package version */
// needs the Option here since the value is `null` when we run from an unpackaged JAR
val Version: String = Option(getClass.getPackage.getImplementationVersion).getOrElse("unpackaged")
/** Full version (raw version and latest commit hash) */
val FullVersion: String = s"$Version ($LastCommitHash)"
}
......@@ -16,7 +16,6 @@
package nl.lumc.sasc.biopet.pipelines.gentrap
import java.io.File
import java.util.Properties
import scala.language.reflectiveCalls
import org.broadinstitute.gatk.queue.QScript
......@@ -24,6 +23,7 @@ import org.broadinstitute.gatk.queue.function.QFunction
import picard.analysis.directed.RnaSeqMetricsCollector.StrandSpecificity
import scalaz._, Scalaz._
import nl.lumc.sasc.biopet.FullVersion
import nl.lumc.sasc.biopet.core._
import nl.lumc.sasc.biopet.core.config._
import nl.lumc.sasc.biopet.core.summary._
......@@ -234,16 +234,6 @@ class Gentrap(val root: Configurable) extends QScript with MultiSampleQScript wi
"isoform_fpkm_cufflinks_blind_heatmap" -> isoFpkmCufflinksBlindHeatmapJob
)
private def version: String = {
val baseVersion = getClass.getPackage.getImplementationVersion
val commitHash = {
val prop = new Properties()
prop.load(getClass.getClassLoader.getResourceAsStream("git.properties"))
prop.getProperty("git.commit.id.abbrev")
}
s"$baseVersion ($commitHash)"
}
/** Output summary file */
def summaryFile: File = new File(outputDir, "gentrap.summary.json")
......@@ -268,7 +258,7 @@ class Gentrap(val root: Configurable) extends QScript with MultiSampleQScript wi
"strand_protocol" -> strandProtocol.toString,
"call_variants" -> callVariants,
"remove_ribosomal_reads" -> removeRibosomalReads,
"version" -> version
"version" -> FullVersion
)
/** Job for writing PDF report template */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment