From e37a638e0903c3644be8b6923b7be6dbb6afdd1c Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Fri, 26 Aug 2011 13:24:06 -0400 Subject: [PATCH] Fix for disallowed characters in GATKReportTable -- Illegal characters are automatically replaced with _ --- .../sting/gatk/report/GATKReportTable.java | 4 +++- .../sting/queue/util/QJobReport.scala | 13 +++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/report/GATKReportTable.java b/public/java/src/org/broadinstitute/sting/gatk/report/GATKReportTable.java index 152e1a57b..3e3aa29a7 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/report/GATKReportTable.java +++ b/public/java/src/org/broadinstitute/sting/gatk/report/GATKReportTable.java @@ -92,6 +92,8 @@ import java.util.regex.Pattern; * @author Khalid Shakir */ public class GATKReportTable { + /** REGEX that matches any table with an invalid name */ + public final static String INVALID_TABLE_NAME_REGEX = "[^a-zA-Z0-9_\\-\\.]"; private static final GATKReportVersion LATEST_REPORT_VERSION = GATKReportVersion.V0_2; private String tableName; private String tableDescription; @@ -111,7 +113,7 @@ public class GATKReportTable { * @return true if the name is valid, false if otherwise */ private boolean isValidName(String name) { - Pattern p = Pattern.compile("[^a-zA-Z0-9_\\-\\.]"); + Pattern p = Pattern.compile(INVALID_TABLE_NAME_REGEX); Matcher m = p.matcher(name); return !m.find(); 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 a1fa10cd8..04ae54c21 100644 --- a/public/scala/src/org/broadinstitute/sting/queue/util/QJobReport.scala +++ b/public/scala/src/org/broadinstitute/sting/queue/util/QJobReport.scala @@ -51,7 +51,7 @@ trait QJobReport extends Logging { logger.info("info " + info) reportFeatures = Map( "iteration" -> 1, - "analysisName" -> self.analysisName, + "analysisName" -> getReportGroup, "jobName" -> QJobReport.workAroundSameJobNames(this), "intermediate" -> self.isIntermediate, "startTime" -> info.getStartTime.getTime, @@ -59,15 +59,12 @@ trait QJobReport extends Logging { "formattedStartTime" -> info.getFormattedStartTime, "formattedDoneTime" -> info.getFormattedDoneTime, "runtime" -> info.getRuntimeInMs).mapValues((x:Any) => if (x != null) x.toString else "null") ++ reportFeatures - -// // handle the special case of iterations -// reportFeatures.get("iteration") match { -// case None => reportFeatures("iteration") = 1 -// case _ => ; -// } + // note -- by adding reportFeatures second we override iteration + // (or any other binding) with the user provided value } - def getReportGroup = analysisName + /** 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: List[String] = getReportFeatures.keys.toList