From 96dbd8df635c8449283d95ca4a2478e3abcb33bd Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Mon, 4 Jun 2012 07:10:13 -0400 Subject: [PATCH] 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 --- .../sting/queue/util/QJobReport.scala | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/public/scala/src/org/broadinstitute/sting/queue/util/QJobReport.scala b/public/scala/src/org/broadinstitute/sting/queue/util/QJobReport.scala index 093741b5d..73ab7c366 100644 --- a/public/scala/src/org/broadinstitute/sting/queue/util/QJobReport.scala +++ b/public/scala/src/org/broadinstitute/sting/queue/util/QJobReport.scala @@ -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 } }