Created new DeprecatedToolChecks class
--Based on existing code in GenomeAnalysisEngine --Hashmaps hold mapping of deprecated tool name to version number and recommended replacement (if any) --Using FastUtils for maps; specifically Object2ObjectMap but there could be a better type for Strings... --Added user exception for deprecated annotations --Added deprecation check to AnnotationInterfaceManager.validateAnnotations --Run when annotations are initialized --Made annotation sets instead of lists
This commit is contained in:
parent
6b4d88ebe9
commit
d70bf64737
|
|
@ -67,6 +67,9 @@ import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static org.broadinstitute.sting.utils.DeprecatedToolChecks.getWalkerDeprecationInfo;
|
||||||
|
import static org.broadinstitute.sting.utils.DeprecatedToolChecks.isDeprecatedWalker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A GenomeAnalysisEngine that runs a specified walker.
|
* A GenomeAnalysisEngine that runs a specified walker.
|
||||||
*/
|
*/
|
||||||
|
|
@ -288,40 +291,6 @@ public class GenomeAnalysisEngine {
|
||||||
//return result;
|
//return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO -- Let's move this to a utility class in unstable - but which one?
|
|
||||||
// **************************************************************************************
|
|
||||||
// * Handle Deprecated Walkers *
|
|
||||||
// **************************************************************************************
|
|
||||||
|
|
||||||
// Mapping from walker name to major version number where the walker first disappeared
|
|
||||||
private static Map<String, String> deprecatedGATKWalkers = new HashMap<String, String>();
|
|
||||||
static {
|
|
||||||
deprecatedGATKWalkers.put("CountCovariates", "2.0");
|
|
||||||
deprecatedGATKWalkers.put("TableRecalibration", "2.0");
|
|
||||||
deprecatedGATKWalkers.put("AlignmentWalker", "2.2");
|
|
||||||
deprecatedGATKWalkers.put("CountBestAlignments", "2.2");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility method to check whether a given walker has been deprecated in a previous GATK release
|
|
||||||
*
|
|
||||||
* @param walkerName the walker class name (not the full package) to check
|
|
||||||
*/
|
|
||||||
public static boolean isDeprecatedWalker(final String walkerName) {
|
|
||||||
return deprecatedGATKWalkers.containsKey(walkerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility method to check whether a given walker has been deprecated in a previous GATK release
|
|
||||||
*
|
|
||||||
* @param walkerName the walker class name (not the full package) to check
|
|
||||||
*/
|
|
||||||
public static String getDeprecatedMajorVersionNumber(final String walkerName) {
|
|
||||||
return deprecatedGATKWalkers.get(walkerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// **************************************************************************************
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves an instance of the walker based on the walker name.
|
* Retrieves an instance of the walker based on the walker name.
|
||||||
*
|
*
|
||||||
|
|
@ -333,7 +302,7 @@ public class GenomeAnalysisEngine {
|
||||||
return walkerManager.createByName(walkerName);
|
return walkerManager.createByName(walkerName);
|
||||||
} catch ( UserException e ) {
|
} catch ( UserException e ) {
|
||||||
if ( isDeprecatedWalker(walkerName) ) {
|
if ( isDeprecatedWalker(walkerName) ) {
|
||||||
e = new UserException.DeprecatedWalker(walkerName, getDeprecatedMajorVersionNumber(walkerName));
|
e = new UserException.DeprecatedWalker(walkerName, getWalkerDeprecationInfo(walkerName));
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
@ -565,6 +534,8 @@ public class GenomeAnalysisEngine {
|
||||||
if ( intervals != null && intervals.isEmpty() ) {
|
if ( intervals != null && intervals.isEmpty() ) {
|
||||||
logger.warn("The given combination of -L and -XL options results in an empty set. No intervals to process.");
|
logger.warn("The given combination of -L and -XL options results in an empty set. No intervals to process.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: add a check for ActiveRegion walkers to prevent users from passing an entire contig/chromosome
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ import org.broadinstitute.variant.vcf.*;
|
||||||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||||
import org.broadinstitute.variant.variantcontext.VariantContext;
|
import org.broadinstitute.variant.variantcontext.VariantContext;
|
||||||
import org.broadinstitute.variant.variantcontext.writer.VariantContextWriter;
|
import org.broadinstitute.variant.variantcontext.writer.VariantContextWriter;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
@ -155,7 +156,7 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> implements Ann
|
||||||
* If multiple records in the rod overlap the given position, one is chosen arbitrarily.
|
* If multiple records in the rod overlap the given position, one is chosen arbitrarily.
|
||||||
*/
|
*/
|
||||||
@Argument(fullName="expression", shortName="E", doc="One or more specific expressions to apply to variant calls; see documentation for more details", required=false)
|
@Argument(fullName="expression", shortName="E", doc="One or more specific expressions to apply to variant calls; see documentation for more details", required=false)
|
||||||
protected List<String> expressionsToUse = new ArrayList<String>();
|
protected Set<String> expressionsToUse = new ObjectOpenHashSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note that the -XL argument can be used along with this one to exclude annotations.
|
* Note that the -XL argument can be used along with this one to exclude annotations.
|
||||||
|
|
@ -189,9 +190,10 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> implements Ann
|
||||||
*/
|
*/
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
if ( LIST )
|
if ( LIST ) {
|
||||||
HelpUtils.listAnnotations();
|
HelpUtils.listAnnotations();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
// get the list of all sample names from the variant VCF input rod, if applicable
|
// get the list of all sample names from the variant VCF input rod, if applicable
|
||||||
List<String> rodName = Arrays.asList(variantCollection.variants.getName());
|
List<String> rodName = Arrays.asList(variantCollection.variants.getName());
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ public class VariantAnnotatorEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
// select specific expressions to use
|
// select specific expressions to use
|
||||||
public void initializeExpressions(List<String> expressionsToUse) {
|
public void initializeExpressions(Set<String> expressionsToUse) {
|
||||||
// set up the expressions
|
// set up the expressions
|
||||||
for ( String expression : expressionsToUse )
|
for ( String expression : expressionsToUse )
|
||||||
requestedExpressions.add(new VAExpression(expression, walker.getResourceRodBindings()));
|
requestedExpressions.add(new VAExpression(expression, walker.getResourceRodBindings()));
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
package org.broadinstitute.sting.gatk.walkers.annotator.interfaces;
|
package org.broadinstitute.sting.gatk.walkers.annotator.interfaces;
|
||||||
|
|
||||||
|
import org.broadinstitute.sting.utils.DeprecatedToolChecks;
|
||||||
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
||||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
|
|
||||||
|
|
@ -58,7 +59,7 @@ public class AnnotationInterfaceManager {
|
||||||
if ( interfaceClass == null )
|
if ( interfaceClass == null )
|
||||||
interfaceClass = classMap.get(group + "Annotation");
|
interfaceClass = classMap.get(group + "Annotation");
|
||||||
if ( interfaceClass == null )
|
if ( interfaceClass == null )
|
||||||
throw new UserException.BadArgumentValue("group", "Class " + group + " is not found; please check that you have specified the class name correctly");
|
throw new UserException.BadArgumentValue("group", "Annotation group " + group + " was not found; please check that you have specified the group name correctly");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,8 +68,13 @@ public class AnnotationInterfaceManager {
|
||||||
Class annotationClass = classMap.get(annotation);
|
Class annotationClass = classMap.get(annotation);
|
||||||
if ( annotationClass == null )
|
if ( annotationClass == null )
|
||||||
annotationClass = classMap.get(annotation + "Annotation");
|
annotationClass = classMap.get(annotation + "Annotation");
|
||||||
if ( annotationClass == null )
|
if ( annotationClass == null ) {
|
||||||
throw new UserException.BadArgumentValue("annotation", "Class " + annotation + " is not found; please check that you have specified the class name correctly");
|
if (DeprecatedToolChecks.isDeprecatedAnnotation(annotation) ) {
|
||||||
|
throw new UserException.DeprecatedAnnotation(annotation, DeprecatedToolChecks.getAnnotationDeprecationInfo(annotation));
|
||||||
|
} else {
|
||||||
|
throw new UserException.BadArgumentValue("annotation", "Annotation " + annotation + " was not found; please check that you have specified the annotation name correctly");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2012 The Broad Institute
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||||
|
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.broadinstitute.sting.utils;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class for handling deprecated tools gracefully
|
||||||
|
*
|
||||||
|
* @author vdauwera
|
||||||
|
* @since 3/11/13
|
||||||
|
*/
|
||||||
|
public class DeprecatedToolChecks {
|
||||||
|
|
||||||
|
// Mapping from walker name to major version number where the walker first disappeared and optional replacement options
|
||||||
|
private static Object2ObjectMap deprecatedGATKWalkers = new Object2ObjectOpenHashMap();
|
||||||
|
static {
|
||||||
|
// Indicate recommended replacement in parentheses if applicable
|
||||||
|
deprecatedGATKWalkers.put("CountCovariates", "2.0 (use BaseRecalibrator instead; see documentation for usage)");
|
||||||
|
deprecatedGATKWalkers.put("AnalyzeCovariates", "2.0 (use BaseRecalibrator instead; see documentation for usage)");
|
||||||
|
deprecatedGATKWalkers.put("TableRecalibration", "2.0 (use PrintReads with -BQSR instead; see documentation for usage)");
|
||||||
|
deprecatedGATKWalkers.put("AlignmentWalker", "2.2 (no replacement)");
|
||||||
|
deprecatedGATKWalkers.put("CountBestAlignments", "2.2 (no replacement)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mapping from walker name to major version number where the walker first disappeared and optional replacement options
|
||||||
|
private static Object2ObjectMap deprecatedGATKAnnotations = new Object2ObjectOpenHashMap();
|
||||||
|
static {
|
||||||
|
// Same comments as for walkers
|
||||||
|
deprecatedGATKAnnotations.put("DepthOfCoverage", "2.4 (renamed to Coverage)");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to check whether a given walker has been deprecated in a previous GATK release
|
||||||
|
*
|
||||||
|
* @param walkerName the walker class name (not the full package) to check
|
||||||
|
*/
|
||||||
|
public static boolean isDeprecatedWalker(final String walkerName) {
|
||||||
|
return deprecatedGATKWalkers.containsKey(walkerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to check whether a given annotation has been deprecated in a previous GATK release
|
||||||
|
*
|
||||||
|
* @param annotationName the annotation class name (not the full package) to check
|
||||||
|
*/
|
||||||
|
public static boolean isDeprecatedAnnotation(final String annotationName) {
|
||||||
|
return deprecatedGATKAnnotations.containsKey(annotationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to pull up the version number at which a walker was deprecated and the suggested replacement, if any
|
||||||
|
*
|
||||||
|
* @param walkerName the walker class name (not the full package) to check
|
||||||
|
*/
|
||||||
|
public static String getWalkerDeprecationInfo(final String walkerName) {
|
||||||
|
return deprecatedGATKWalkers.get(walkerName).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to pull up the version number at which an annotation was deprecated and the suggested replacement, if any
|
||||||
|
*
|
||||||
|
* @param annotationName the annotation class name (not the full package) to check
|
||||||
|
*/
|
||||||
|
public static String getAnnotationDeprecationInfo(final String annotationName) {
|
||||||
|
return deprecatedGATKAnnotations.get(annotationName).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -371,14 +371,18 @@ public class UserException extends ReviewedStingException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static class DeprecatedWalker extends UserException {
|
public static class DeprecatedWalker extends UserException {
|
||||||
public DeprecatedWalker(String walkerName, String version) {
|
public DeprecatedWalker(String walkerName, String version) {
|
||||||
super(String.format("Walker %s is no longer available in the GATK; it has been deprecated since version %s", walkerName, version));
|
super(String.format("Walker %s is no longer available in the GATK; it has been deprecated since version %s", walkerName, version));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class DeprecatedAnnotation extends UserException {
|
||||||
|
public DeprecatedAnnotation(String annotationName, String version) {
|
||||||
|
super(String.format("Annotation %s is no longer available in the GATK; it has been deprecated since version %s", annotationName, version));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class CannotExecuteQScript extends UserException {
|
public static class CannotExecuteQScript extends UserException {
|
||||||
public CannotExecuteQScript(String message) {
|
public CannotExecuteQScript(String message) {
|
||||||
super(String.format("Unable to execute QScript: " + message));
|
super(String.format("Unable to execute QScript: " + message));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue