2009-07-22 06:23:28 +08:00
|
|
|
/*
|
2010-04-20 07:00:08 +08:00
|
|
|
* Copyright (c) 2010 The Broad Institute
|
2010-04-20 23:26:32 +08:00
|
|
|
*
|
2009-07-22 06:23:28 +08:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
|
* obtaining a copy of this software and associated documentation
|
2010-04-20 23:26:32 +08:00
|
|
|
* files (the "Software"), to deal in the Software without
|
2009-07-22 06:23:28 +08:00
|
|
|
* 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:
|
2010-04-20 23:26:32 +08:00
|
|
|
*
|
2009-07-22 06:23:28 +08:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
|
*
|
2010-04-20 23:26:32 +08:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
2009-07-22 06:23:28 +08:00
|
|
|
* 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
|
2010-04-20 07:00:08 +08:00
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
|
|
|
|
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2009-07-22 06:23:28 +08:00
|
|
|
*/
|
|
|
|
|
|
2009-03-18 07:22:37 +08:00
|
|
|
package org.broadinstitute.sting.gatk;
|
|
|
|
|
|
2010-08-12 05:58:26 +08:00
|
|
|
import org.broadinstitute.sting.commandline.Hidden;
|
2011-02-04 01:59:19 +08:00
|
|
|
import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource;
|
2009-11-11 02:40:16 +08:00
|
|
|
import org.broadinstitute.sting.gatk.filters.FilterManager;
|
2011-05-05 03:29:08 +08:00
|
|
|
import org.broadinstitute.sting.gatk.filters.ReadFilter;
|
2010-04-01 06:39:56 +08:00
|
|
|
import org.broadinstitute.sting.gatk.walkers.*;
|
2011-07-18 08:29:58 +08:00
|
|
|
import org.broadinstitute.sting.utils.baq.BAQ;
|
2010-04-20 07:00:08 +08:00
|
|
|
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
2011-07-18 08:29:58 +08:00
|
|
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
2009-12-12 12:04:37 +08:00
|
|
|
import org.broadinstitute.sting.utils.help.DescriptionTaglet;
|
2010-04-01 06:39:56 +08:00
|
|
|
import org.broadinstitute.sting.utils.help.DisplayNameTaglet;
|
2009-12-12 12:04:37 +08:00
|
|
|
import org.broadinstitute.sting.utils.help.SummaryTaglet;
|
2011-07-18 08:29:58 +08:00
|
|
|
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
|
2010-04-01 06:39:56 +08:00
|
|
|
|
|
|
|
|
import java.util.*;
|
2009-03-18 07:22:37 +08:00
|
|
|
|
|
|
|
|
/**
|
2010-08-10 00:42:48 +08:00
|
|
|
* Plugin manager that also provides various utilities for inspecting Walkers.
|
2009-03-18 07:22:37 +08:00
|
|
|
*/
|
2009-11-11 02:40:16 +08:00
|
|
|
public class WalkerManager extends PluginManager<Walker> {
|
2009-03-18 07:22:37 +08:00
|
|
|
|
2009-12-05 07:24:29 +08:00
|
|
|
/**
|
|
|
|
|
* A collection of help text for walkers and their enclosing packages.
|
|
|
|
|
*/
|
2010-01-16 07:31:29 +08:00
|
|
|
private ResourceBundle helpText;
|
2009-12-05 07:24:29 +08:00
|
|
|
|
2009-07-22 02:32:22 +08:00
|
|
|
public WalkerManager() {
|
2009-11-11 02:40:16 +08:00
|
|
|
super(Walker.class,"walker","Walker");
|
2010-01-21 03:18:19 +08:00
|
|
|
helpText = TextFormattingUtils.loadResourceBundle("StingText");
|
2009-07-22 06:23:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2009-12-05 07:24:29 +08:00
|
|
|
* Get the list of walkers currently available to the GATK, organized
|
|
|
|
|
* by package.
|
2010-08-05 10:26:46 +08:00
|
|
|
* @param visibleWalkersOnly If true, return only the walker names that aren't hidden.
|
2009-07-22 06:23:28 +08:00
|
|
|
* @return Names of currently available walkers.
|
|
|
|
|
*/
|
2010-08-05 10:26:46 +08:00
|
|
|
public Map<String,Collection<Class<? extends Walker>>> getWalkerNamesByPackage(boolean visibleWalkersOnly) {
|
2009-12-05 07:24:29 +08:00
|
|
|
Map<String,Collection<Class<? extends Walker>>> walkersByPackage = new HashMap<String,Collection<Class<? extends Walker>>>();
|
2010-11-13 04:14:28 +08:00
|
|
|
for(Class<? extends Walker> walker: getPlugins()) {
|
2010-08-05 10:26:46 +08:00
|
|
|
if(visibleWalkersOnly && isHidden(walker))
|
|
|
|
|
continue;
|
|
|
|
|
|
2009-12-10 04:12:35 +08:00
|
|
|
// Extract the name for the package; if the walker is in the unnamed package, use the empty string
|
|
|
|
|
String walkerPackage = walker.getPackage() != null ? walker.getPackage().getName() : "";
|
2009-12-05 07:24:29 +08:00
|
|
|
if(!walkersByPackage.containsKey(walkerPackage))
|
|
|
|
|
walkersByPackage.put(walkerPackage,new ArrayList<Class<? extends Walker>>());
|
|
|
|
|
walkersByPackage.get(walkerPackage).add(walker);
|
|
|
|
|
}
|
|
|
|
|
return Collections.unmodifiableMap(walkersByPackage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the display name for a given package.
|
|
|
|
|
* @param packageName Fully qualified package name.
|
|
|
|
|
* @return A suitable display name for the package.
|
|
|
|
|
*/
|
|
|
|
|
public String getPackageDisplayName(String packageName) {
|
2009-12-10 04:12:35 +08:00
|
|
|
// Try to find an override for the display name of this package.
|
2009-12-12 12:04:37 +08:00
|
|
|
String displayNameKey = String.format("%s.%s",packageName,DisplayNameTaglet.NAME);
|
2010-08-10 00:42:48 +08:00
|
|
|
String displayName;
|
2009-12-12 12:04:37 +08:00
|
|
|
if(helpText.containsKey(displayNameKey)) {
|
2010-01-16 07:31:29 +08:00
|
|
|
displayName = helpText.getString(displayNameKey);
|
2009-12-12 12:04:37 +08:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// If no override exists...
|
2009-12-10 04:12:35 +08:00
|
|
|
// ...try to compute the override from the text of the package name, while accounting for
|
|
|
|
|
// unpackaged walkers.
|
|
|
|
|
displayName = packageName.substring(packageName.lastIndexOf('.')+1);
|
|
|
|
|
if(displayName.trim().equals("")) displayName = "<unpackaged>";
|
|
|
|
|
}
|
|
|
|
|
return displayName;
|
2009-12-05 07:24:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the help text associated with a given package name.
|
|
|
|
|
* @param packageName Package for which to search for help text.
|
|
|
|
|
* @return Package help text, or "" if none exists.
|
|
|
|
|
*/
|
2009-12-12 12:04:37 +08:00
|
|
|
public String getPackageSummaryText(String packageName) {
|
|
|
|
|
String key = String.format("%s.%s",packageName,SummaryTaglet.NAME);
|
|
|
|
|
if(!helpText.containsKey(key))
|
2009-12-05 07:24:29 +08:00
|
|
|
return "";
|
2010-01-16 07:31:29 +08:00
|
|
|
return helpText.getString(key);
|
2009-12-05 07:24:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2009-12-12 12:04:37 +08:00
|
|
|
* Gets the summary help text associated with a given walker type.
|
2009-12-05 07:24:29 +08:00
|
|
|
* @param walkerType Type of walker for which to search for help text.
|
2009-12-12 12:04:37 +08:00
|
|
|
* @return Walker summary description, or "" if none exists.
|
|
|
|
|
*/
|
|
|
|
|
public String getWalkerSummaryText(Class<? extends Walker> walkerType) {
|
|
|
|
|
String walkerSummary = String.format("%s.%s",walkerType.getName(), SummaryTaglet.NAME);
|
|
|
|
|
if(!helpText.containsKey(walkerSummary))
|
|
|
|
|
return "";
|
2010-01-16 07:31:29 +08:00
|
|
|
return helpText.getString(walkerSummary);
|
2009-12-12 12:04:37 +08:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 00:42:48 +08:00
|
|
|
/**
|
|
|
|
|
* Gets the summary help text associated with a given walker type.
|
|
|
|
|
* @param walker Walker for which to search for help text.
|
|
|
|
|
* @return Walker summary description, or "" if none exists.
|
|
|
|
|
*/
|
|
|
|
|
public String getWalkerSummaryText(Walker walker) {
|
|
|
|
|
return getWalkerSummaryText(walker.getClass());
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-12 12:04:37 +08:00
|
|
|
/**
|
|
|
|
|
* Gets the descriptive help text associated with a given walker type.
|
|
|
|
|
* @param walkerType Type of walker for which to search for help text.
|
|
|
|
|
* @return Walker full description, or "" if none exists.
|
2009-12-05 07:24:29 +08:00
|
|
|
*/
|
2009-12-12 12:04:37 +08:00
|
|
|
public String getWalkerDescriptionText(Class<? extends Walker> walkerType) {
|
|
|
|
|
String walkerDescription = String.format("%s.%s",walkerType.getName(), DescriptionTaglet.NAME);
|
|
|
|
|
if(!helpText.containsKey(walkerDescription))
|
2009-12-05 07:24:29 +08:00
|
|
|
return "";
|
2010-01-16 07:31:29 +08:00
|
|
|
return helpText.getString(walkerDescription);
|
2009-03-27 04:45:27 +08:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 00:42:48 +08:00
|
|
|
/**
|
|
|
|
|
* Gets the descriptive help text associated with a given walker type.
|
|
|
|
|
* @param walker Walker for which to search for help text.
|
|
|
|
|
* @return Walker full description, or "" if none exists.
|
|
|
|
|
*/
|
|
|
|
|
public String getWalkerDescriptionText(Walker walker) {
|
|
|
|
|
return getWalkerDescriptionText(walker.getClass());
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-16 05:02:12 +08:00
|
|
|
/**
|
|
|
|
|
* Retrieves the walker class given a walker name.
|
|
|
|
|
* @param walkerName Name of the walker.
|
|
|
|
|
* @return Class representing the walker.
|
|
|
|
|
*/
|
2010-08-10 00:42:48 +08:00
|
|
|
public Class<? extends Walker> getWalkerClassByName(String walkerName) {
|
2010-11-13 04:14:28 +08:00
|
|
|
return getPluginsByName().get(walkerName);
|
2009-03-18 07:22:37 +08:00
|
|
|
}
|
|
|
|
|
|
2009-05-16 05:02:12 +08:00
|
|
|
/**
|
|
|
|
|
* Gets the data source for the provided walker.
|
2010-08-10 00:42:48 +08:00
|
|
|
* @param walkerClass The class of the walker.
|
2009-05-16 05:02:12 +08:00
|
|
|
* @return Which type of data source to traverse over...reads or reference?
|
|
|
|
|
*/
|
2010-08-10 00:42:48 +08:00
|
|
|
public static DataSource getWalkerDataSource(Class<? extends Walker> walkerClass) {
|
2009-05-16 05:02:12 +08:00
|
|
|
By byDataSource = walkerClass.getAnnotation(By.class);
|
|
|
|
|
if( byDataSource == null )
|
2010-09-12 23:07:38 +08:00
|
|
|
throw new ReviewedStingException("Unable to find By annotation for walker class " + walkerClass.getName());
|
2009-05-16 05:02:12 +08:00
|
|
|
return byDataSource.value();
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-20 07:26:17 +08:00
|
|
|
/**
|
2010-08-10 00:42:48 +08:00
|
|
|
* Gets the data source for the provided walker.
|
|
|
|
|
* @param walker The walker.
|
|
|
|
|
* @return Which type of data source to traverse over...reads or reference?
|
|
|
|
|
*/
|
|
|
|
|
public static DataSource getWalkerDataSource(Walker walker) {
|
|
|
|
|
return getWalkerDataSource(walker.getClass());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a list of RODs allowed by the walker.
|
|
|
|
|
* @param walkerClass Class of the walker to query.
|
|
|
|
|
* @return The list of allowed reference meta data.
|
|
|
|
|
*/
|
|
|
|
|
public static List<RMD> getAllowsMetaData(Class<? extends Walker> walkerClass) {
|
|
|
|
|
Allows allowsDataSource = getWalkerAllowed(walkerClass);
|
|
|
|
|
if (allowsDataSource == null)
|
|
|
|
|
return Collections.<RMD>emptyList();
|
|
|
|
|
return Arrays.asList(allowsDataSource.referenceMetaData());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a list of RODs allowed by the walker.
|
2009-05-20 07:26:17 +08:00
|
|
|
* @param walker Walker to query.
|
2010-08-10 00:42:48 +08:00
|
|
|
* @return The list of allowed reference meta data.
|
|
|
|
|
*/
|
|
|
|
|
public static List<RMD> getAllowsMetaData(Walker walker) {
|
|
|
|
|
return getAllowsMetaData(walker.getClass());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the given walker supports the given data source.
|
|
|
|
|
* @param walkerClass Class of the walker to query.
|
2009-05-20 07:26:17 +08:00
|
|
|
* @param dataSource Source to check for .
|
|
|
|
|
* @return True if the walker forbids this data type. False otherwise.
|
|
|
|
|
*/
|
2010-08-10 00:42:48 +08:00
|
|
|
public static boolean isAllowed(Class<? extends Walker> walkerClass, DataSource dataSource) {
|
|
|
|
|
Allows allowsDataSource = getWalkerAllowed(walkerClass);
|
2009-05-20 07:26:17 +08:00
|
|
|
|
|
|
|
|
// Allows is less restrictive than requires. If an allows
|
|
|
|
|
// clause is not specified, any kind of data is allowed.
|
|
|
|
|
if( allowsDataSource == null )
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return Arrays.asList(allowsDataSource.value()).contains(dataSource);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-08-10 00:42:48 +08:00
|
|
|
* Determine whether the given walker supports the given data source.
|
2009-05-20 07:26:17 +08:00
|
|
|
* @param walker Walker to query.
|
2010-08-10 00:42:48 +08:00
|
|
|
* @param dataSource Source to check for .
|
|
|
|
|
* @return True if the walker forbids this data type. False otherwise.
|
|
|
|
|
*/
|
|
|
|
|
public static boolean isAllowed(Walker walker, DataSource dataSource) {
|
|
|
|
|
return isAllowed(walker.getClass(), dataSource);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the given walker supports the given reference ordered data.
|
|
|
|
|
* @param walkerClass Class of the walker to query.
|
2009-05-20 07:26:17 +08:00
|
|
|
* @param rod Source to check.
|
|
|
|
|
* @return True if the walker forbids this data type. False otherwise.
|
|
|
|
|
*/
|
2010-12-31 12:52:22 +08:00
|
|
|
public static boolean isAllowed(Class<? extends Walker> walkerClass, ReferenceOrderedDataSource rod) {
|
2010-08-10 00:42:48 +08:00
|
|
|
Allows allowsDataSource = getWalkerAllowed(walkerClass);
|
2009-05-20 07:26:17 +08:00
|
|
|
|
|
|
|
|
// Allows is less restrictive than requires. If an allows
|
|
|
|
|
// clause is not specified, any kind of data is allowed.
|
|
|
|
|
if( allowsDataSource == null )
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
// The difference between unspecified RMD and the empty set of metadata can't be detected.
|
|
|
|
|
// Treat an empty 'allows' as 'allow everything'. Maybe we can have a special RMD flag to account for this
|
|
|
|
|
// case in the future.
|
|
|
|
|
if( allowsDataSource.referenceMetaData().length == 0 )
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
for( RMD allowed: allowsDataSource.referenceMetaData() ) {
|
2010-05-28 22:52:44 +08:00
|
|
|
if( rod.matchesNameAndRecordType(allowed.name(),allowed.type()) )
|
2009-05-20 07:26:17 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 00:42:48 +08:00
|
|
|
/**
|
|
|
|
|
* Determine whether the given walker supports the given reference ordered data.
|
|
|
|
|
* @param walker Walker to query.
|
|
|
|
|
* @param rod Source to check.
|
|
|
|
|
* @return True if the walker forbids this data type. False otherwise.
|
|
|
|
|
*/
|
2010-12-31 12:52:22 +08:00
|
|
|
public static boolean isAllowed(Walker walker, ReferenceOrderedDataSource rod) {
|
2010-08-10 00:42:48 +08:00
|
|
|
return isAllowed(walker.getClass(), rod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the given walker requires the given data source.
|
|
|
|
|
* @param walkerClass Class of the walker to query.
|
|
|
|
|
* @param dataSource Source to check for.
|
|
|
|
|
* @return True if the walker allows this data type. False otherwise.
|
|
|
|
|
*/
|
|
|
|
|
public static boolean isRequired(Class<? extends Walker> walkerClass, DataSource dataSource) {
|
|
|
|
|
Requires requiresDataSource = getWalkerRequirements(walkerClass);
|
|
|
|
|
return Arrays.asList(requiresDataSource.value()).contains(dataSource);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-20 07:26:17 +08:00
|
|
|
/**
|
|
|
|
|
* Determine whether the given walker requires the given data source.
|
|
|
|
|
* @param walker Walker to query.
|
|
|
|
|
* @param dataSource Source to check for.
|
|
|
|
|
* @return True if the walker allows this data type. False otherwise.
|
|
|
|
|
*/
|
|
|
|
|
public static boolean isRequired(Walker walker, DataSource dataSource) {
|
2010-08-10 00:42:48 +08:00
|
|
|
return isRequired(walker.getClass(), dataSource);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a list of RODs required by the walker.
|
|
|
|
|
* @param walkerClass Class of the walker to query.
|
|
|
|
|
* @return The list of required reference meta data.
|
|
|
|
|
*/
|
|
|
|
|
public static List<RMD> getRequiredMetaData(Class<? extends Walker> walkerClass) {
|
|
|
|
|
Requires requiresDataSource = getWalkerRequirements(walkerClass);
|
|
|
|
|
return Arrays.asList(requiresDataSource.referenceMetaData());
|
2009-05-20 07:26:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a list of RODs required by the walker.
|
|
|
|
|
* @param walker Walker to query.
|
2010-08-10 00:42:48 +08:00
|
|
|
* @return The list of required reference meta data.
|
2009-05-20 07:26:17 +08:00
|
|
|
*/
|
|
|
|
|
public static List<RMD> getRequiredMetaData(Walker walker) {
|
2010-08-10 00:42:48 +08:00
|
|
|
return getRequiredMetaData(walker.getClass());
|
2009-05-20 07:26:17 +08:00
|
|
|
}
|
|
|
|
|
|
2010-08-05 10:26:46 +08:00
|
|
|
/**
|
|
|
|
|
* Reports whether this walker type is hidden -- in other words, whether it'll appear in the help output.
|
|
|
|
|
* @param walkerType Class to test for visibility.
|
|
|
|
|
* @return True if the walker should be hidden. False otherwise.
|
|
|
|
|
*/
|
|
|
|
|
public static boolean isHidden(Class<? extends Walker> walkerType) {
|
|
|
|
|
return walkerType.isAnnotationPresent(Hidden.class);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-10 07:59:53 +08:00
|
|
|
/**
|
|
|
|
|
* Extracts filters that the walker has requested be run on the dataset.
|
2010-08-10 00:42:48 +08:00
|
|
|
* @param walkerClass Class of the walker to inspect for filtering requests.
|
2009-11-11 02:40:16 +08:00
|
|
|
* @param filterManager Manages the creation of filters.
|
2009-07-10 07:59:53 +08:00
|
|
|
* @return A non-empty list of filters to apply to the reads.
|
|
|
|
|
*/
|
2011-05-05 03:29:08 +08:00
|
|
|
public static List<ReadFilter> getReadFilters(Class<? extends Walker> walkerClass, FilterManager filterManager) {
|
|
|
|
|
List<ReadFilter> filters = new ArrayList<ReadFilter>();
|
|
|
|
|
for(Class<? extends ReadFilter> filterType: getReadFilterTypes(walkerClass))
|
2009-11-11 02:40:16 +08:00
|
|
|
filters.add(filterManager.createFilterByType(filterType));
|
2009-07-10 07:59:53 +08:00
|
|
|
return filters;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 00:42:48 +08:00
|
|
|
/**
|
|
|
|
|
* Extracts filters that the walker has requested be run on the dataset.
|
|
|
|
|
* @param walker Walker to inspect for filtering requests.
|
|
|
|
|
* @param filterManager Manages the creation of filters.
|
|
|
|
|
* @return A non-empty list of filters to apply to the reads.
|
|
|
|
|
*/
|
2011-05-05 03:29:08 +08:00
|
|
|
public static List<ReadFilter> getReadFilters(Walker walker, FilterManager filterManager) {
|
2010-08-10 00:42:48 +08:00
|
|
|
return getReadFilters(walker.getClass(), filterManager);
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-19 13:40:05 +08:00
|
|
|
/**
|
|
|
|
|
* Gets the type of downsampling method requested by the walker. If an alternative
|
|
|
|
|
* downsampling method is specified on the command-line, the command-line version will
|
|
|
|
|
* be used instead.
|
2010-08-10 00:42:48 +08:00
|
|
|
* @param walkerClass The class of the walker to interrogate.
|
2010-05-19 13:40:05 +08:00
|
|
|
* @return The downsampling method, as specified by the walker. Null if none exists.
|
|
|
|
|
*/
|
2010-08-10 00:42:48 +08:00
|
|
|
public static DownsamplingMethod getDownsamplingMethod(Class<? extends Walker> walkerClass) {
|
2010-05-19 13:40:05 +08:00
|
|
|
DownsamplingMethod downsamplingMethod = null;
|
|
|
|
|
|
2010-08-10 00:42:48 +08:00
|
|
|
if( walkerClass.isAnnotationPresent(Downsample.class) ) {
|
|
|
|
|
Downsample downsampleParameters = walkerClass.getAnnotation(Downsample.class);
|
2010-05-19 13:40:05 +08:00
|
|
|
DownsampleType type = downsampleParameters.by();
|
|
|
|
|
Integer toCoverage = downsampleParameters.toCoverage() >= 0 ? downsampleParameters.toCoverage() : null;
|
|
|
|
|
Double toFraction = downsampleParameters.toFraction() >= 0.0d ? downsampleParameters.toFraction() : null;
|
|
|
|
|
downsamplingMethod = new DownsamplingMethod(type,toCoverage,toFraction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return downsamplingMethod;
|
|
|
|
|
}
|
|
|
|
|
|
BAQ calculation refactoring in the GATK. Single -baq argument can be NONE, CALCULATE_AS_NECESSARY, and RECALCULATE. Walkers can control bia the @BAQMode annotation how the BAQ calculation is applied. Can either be as a tag, by overwriting the qualities scores, or by only returning the baq-capped qualities scores. Additionally, walkers can be set up to have the BAQ applied to the incoming reads (ON_INPUT, the default), to output reads (ON_OUTPUT), or HANDLED_BY_WALKER, which means that calling into the BAQ system is the responsibility of the individual walker.
SAMFileWriterStub now supports BAQ writing as an internal feature. Several walkers have the @BAQMode applied to this, with parameters that I think are reasonable. Please look if you own these walkers, though
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4798 348d0f76-0448-11de-a6fe-93d51630548a
2010-12-07 04:55:52 +08:00
|
|
|
public static BAQ.QualityMode getBAQQualityMode(Walker walker) {
|
|
|
|
|
return walker.getClass().getAnnotation(BAQMode.class).QualityMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static BAQ.ApplicationTime getBAQApplicationTime(Walker walker) {
|
|
|
|
|
return walker.getClass().getAnnotation(BAQMode.class).ApplicationTime();
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 00:42:48 +08:00
|
|
|
/**
|
|
|
|
|
* Gets the type of downsampling method requested by the walker. If an alternative
|
|
|
|
|
* downsampling method is specified on the command-line, the command-line version will
|
|
|
|
|
* be used instead.
|
|
|
|
|
* @param walker The walker to interrogate.
|
|
|
|
|
* @return The downsampling method, as specified by the walker. Null if none exists.
|
|
|
|
|
*/
|
|
|
|
|
public static DownsamplingMethod getDownsamplingMethod(Walker walker) {
|
|
|
|
|
return getDownsamplingMethod(walker.getClass());
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-27 04:45:27 +08:00
|
|
|
/**
|
|
|
|
|
* Create a name for this type of walker.
|
2009-03-27 21:27:04 +08:00
|
|
|
*
|
2009-03-27 04:45:27 +08:00
|
|
|
* @param walkerType The type of walker.
|
|
|
|
|
* @return A name for this type of walker.
|
|
|
|
|
*/
|
2009-11-11 02:40:16 +08:00
|
|
|
@Override
|
|
|
|
|
public String getName(Class<? extends Walker> walkerType) {
|
2009-03-27 04:45:27 +08:00
|
|
|
String walkerName = "";
|
|
|
|
|
|
2009-03-27 21:27:04 +08:00
|
|
|
if (walkerType.getAnnotation(WalkerName.class) != null)
|
|
|
|
|
walkerName = walkerType.getAnnotation(WalkerName.class).value().trim();
|
2009-11-11 02:40:16 +08:00
|
|
|
else
|
|
|
|
|
walkerName = super.getName(walkerType);
|
2009-03-27 04:45:27 +08:00
|
|
|
|
|
|
|
|
return walkerName;
|
|
|
|
|
}
|
2009-05-20 07:26:17 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Utility to get the requires attribute from the walker.
|
|
|
|
|
* Throws an exception if requirements are missing.
|
2010-08-10 00:42:48 +08:00
|
|
|
* @param walkerClass Class of the walker to query for required data.
|
2009-05-20 07:26:17 +08:00
|
|
|
* @return Required data attribute.
|
|
|
|
|
*/
|
2010-08-10 00:42:48 +08:00
|
|
|
private static Requires getWalkerRequirements(Class<? extends Walker> walkerClass) {
|
2009-05-20 07:26:17 +08:00
|
|
|
Requires requiresDataSource = walkerClass.getAnnotation(Requires.class);
|
|
|
|
|
if( requiresDataSource == null )
|
2010-09-12 23:07:38 +08:00
|
|
|
throw new ReviewedStingException( "Unable to find data types required by walker class " + walkerClass.getName());
|
2009-05-20 07:26:17 +08:00
|
|
|
return requiresDataSource;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-08-10 00:42:48 +08:00
|
|
|
* Utility to get the requires attribute from the walker.
|
|
|
|
|
* Throws an exception if requirements are missing.
|
2009-05-20 07:26:17 +08:00
|
|
|
* @param walker Walker to query for required data.
|
2010-08-10 00:42:48 +08:00
|
|
|
* @return Required data attribute.
|
|
|
|
|
*/
|
|
|
|
|
private static Requires getWalkerRequirements(Walker walker) {
|
|
|
|
|
return getWalkerRequirements(walker.getClass());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Utility to get the forbidden attribute from the walker.
|
|
|
|
|
* @param walkerClass Class of the walker to query for required data.
|
2009-05-20 07:26:17 +08:00
|
|
|
* @return Required data attribute. Null if forbidden info isn't present.
|
|
|
|
|
*/
|
2010-08-10 00:42:48 +08:00
|
|
|
private static Allows getWalkerAllowed(Class<? extends Walker> walkerClass) {
|
2009-05-20 07:26:17 +08:00
|
|
|
Allows allowsDataSource = walkerClass.getAnnotation(Allows.class);
|
|
|
|
|
return allowsDataSource;
|
|
|
|
|
}
|
2009-07-10 07:59:53 +08:00
|
|
|
|
2010-08-10 00:42:48 +08:00
|
|
|
/**
|
|
|
|
|
* Utility to get the forbidden attribute from the walker.
|
|
|
|
|
* @param walker Walker to query for required data.
|
|
|
|
|
* @return Required data attribute. Null if forbidden info isn't present.
|
|
|
|
|
*/
|
|
|
|
|
private static Allows getWalkerAllowed(Walker walker) {
|
|
|
|
|
return getWalkerAllowed(walker.getClass());
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-10 07:59:53 +08:00
|
|
|
/**
|
|
|
|
|
* Gets the list of filtering classes specified as walker annotations.
|
2010-08-10 00:42:48 +08:00
|
|
|
* @param walkerClass Class of the walker to inspect.
|
2009-07-10 07:59:53 +08:00
|
|
|
* @return An array of types extending from SamRecordFilter. Will never be null.
|
|
|
|
|
*/
|
2011-05-05 03:29:08 +08:00
|
|
|
public static Collection<Class<? extends ReadFilter>> getReadFilterTypes(Class<?> walkerClass) {
|
|
|
|
|
List<Class<? extends ReadFilter>> filterTypes = new ArrayList<Class<? extends ReadFilter>>();
|
2010-08-12 04:17:11 +08:00
|
|
|
while(walkerClass != null) {
|
2011-04-08 11:34:50 +08:00
|
|
|
if(walkerClass.isAnnotationPresent(ReadFilters.class)) {
|
|
|
|
|
for ( Class c : walkerClass.getAnnotation(ReadFilters.class).value() ) {
|
|
|
|
|
if( !filterTypes.contains(c) )
|
|
|
|
|
filterTypes.add(c);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-08-12 04:17:11 +08:00
|
|
|
walkerClass = walkerClass.getSuperclass();
|
|
|
|
|
}
|
|
|
|
|
return filterTypes;
|
2009-07-10 07:59:53 +08:00
|
|
|
}
|
2010-08-10 00:42:48 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the list of filtering classes specified as walker annotations.
|
|
|
|
|
* @param walker The walker to inspect.
|
|
|
|
|
* @return An array of types extending from SamRecordFilter. Will never be null.
|
|
|
|
|
*/
|
2011-05-05 03:29:08 +08:00
|
|
|
public static Collection<Class<? extends ReadFilter>> getReadFilterTypes(Walker walker) {
|
2010-08-10 00:42:48 +08:00
|
|
|
return getReadFilterTypes(walker.getClass());
|
|
|
|
|
}
|
2009-03-18 07:22:37 +08:00
|
|
|
}
|