Fix a nasty script bug in Queue
-- If you are using user-defined configurations (configureJobFeatures) and you didn't overwride the analysisName of your jobs, and there were other jobs using the same name, then you got very strange errors at the end of your script. For example, in my script I was using SelectVariants to prepare VCF files, and SelectVariants to generate a useful performance table. Since I forgot to make a special analysisName for my table commands, the generic SV commands were being included in the analysis group, and these were throwing an error since the special features added for the table weren't added to those SV commands
This commit is contained in:
parent
37b8d70321
commit
96dbd8df63
|
|
@ -40,6 +40,7 @@ trait QJobReport extends Logging {
|
|||
self: QFunction =>
|
||||
|
||||
protected var reportGroup: String = null
|
||||
protected var userReportFeatures: Map[String, String] = Map()
|
||||
protected var reportFeatures: Map[String, String] = Map()
|
||||
protected var reportEnabled: Boolean = true
|
||||
|
||||
|
|
@ -49,7 +50,7 @@ trait QJobReport extends Logging {
|
|||
|
||||
def setRunInfo(info: JobRunInfo) {
|
||||
//logger.info("info " + info)
|
||||
reportFeatures = Map(
|
||||
val runtimeFeatures = Map(
|
||||
"iteration" -> 1,
|
||||
"analysisName" -> getReportGroup,
|
||||
"jobName" -> QJobReport.workAroundSameJobNames(this),
|
||||
|
|
@ -59,36 +60,39 @@ trait QJobReport extends Logging {
|
|||
"doneTime" -> info.getDoneTime.getTime,
|
||||
"formattedStartTime" -> info.getFormattedStartTime,
|
||||
"formattedDoneTime" -> info.getFormattedDoneTime,
|
||||
"runtime" -> info.getRuntimeInMs).mapValues((x:Any) => if (x != null) x.toString else "null") ++ reportFeatures
|
||||
"runtime" -> info.getRuntimeInMs).mapValues((x:Any) => if (x != null) x.toString else "null")
|
||||
reportFeatures = runtimeFeatures ++ userReportFeatures
|
||||
// note -- by adding reportFeatures second we override iteration
|
||||
// (or any other binding) with the user provided value
|
||||
}
|
||||
|
||||
/** The report Group is the analysis name transform to only contain valid GATKReportTable characters */
|
||||
def getReportGroup = self.analysisName.replaceAll(GATKReportTable.INVALID_TABLE_NAME_REGEX, "_")
|
||||
def getReportFeatures = reportFeatures
|
||||
|
||||
def getReportFeatureNames: Seq[String] = getReportFeatures.keys.toSeq
|
||||
def getReportFeatureNames: Seq[String] = reportFeatures.keys.toSeq
|
||||
def getReportFeature(key: String): String = {
|
||||
getReportFeatures.get(key) match {
|
||||
reportFeatures.get(key) match {
|
||||
case Some(x) => x
|
||||
case None => throw new RuntimeException("Get called with key %s but no value was found".format(key))
|
||||
case None =>
|
||||
logger.warn("getReportFeature called with key %s but no value was found for group %s. This can be caused by adding user-defined job features to a job with a generic name used elsewhere in the Queue script. To fix the problem make sure that each group of commands with user-specific features has a unique analysisName".format(key, reportGroup))
|
||||
"NA"
|
||||
}
|
||||
}
|
||||
|
||||
def getReportName: String = getReportFeature("jobName")
|
||||
|
||||
def configureJobReport(features: Map[String, Any]) {
|
||||
this.reportFeatures = features.mapValues(_.toString)
|
||||
this.userReportFeatures = features.mapValues(_.toString)
|
||||
}
|
||||
|
||||
def addJobReportBinding(key: String, value: Any) {
|
||||
this.reportFeatures += (key -> value.toString)
|
||||
this.userReportFeatures += (key -> value.toString)
|
||||
}
|
||||
|
||||
// copy the QJobReport information -- todo : what's the best way to do this?
|
||||
override def copySettingsTo(function: QFunction) {
|
||||
self.copySettingsTo(function)
|
||||
function.userReportFeatures = this.userReportFeatures
|
||||
function.reportFeatures = this.reportFeatures
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue