Usability cleanup for BQSR
-- I'm seeing a lot of people trying to use BinaryTagCovariate in the community. They really shouldn't do this, so I moved it to private. -- Throw an exception if its required bintag argument is missing -- Check explicitly if user is requesting DinucCovariate and tell them that its been retired in favor of ContextCovariate -- Show the type (Required, Experimental, Standard) of the covariates when running --list
This commit is contained in:
parent
e5cfdb4811
commit
dcc972a557
|
|
@ -25,12 +25,14 @@
|
|||
|
||||
package org.broadinstitute.sting.utils.classloader;
|
||||
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.StingException;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
|
@ -234,4 +236,17 @@ public class JVMUtils {
|
|||
} else
|
||||
throw new ReviewedStingException("BUG: could not find generic type on class " + t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a comma-separated list of the names of the interfaces implemented by this class
|
||||
*
|
||||
* @param covClass
|
||||
* @return
|
||||
*/
|
||||
public static String classInterfaces(final Class covClass) {
|
||||
final List<String> interfaces = new ArrayList<String>();
|
||||
for ( final Class interfaceClass : covClass.getInterfaces() )
|
||||
interfaces.add(interfaceClass.getSimpleName());
|
||||
return Utils.join(", ", interfaces);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.apache.log4j.Logger;
|
|||
import org.broadinstitute.sting.gatk.report.GATKReport;
|
||||
import org.broadinstitute.sting.gatk.report.GATKReportTable;
|
||||
import org.broadinstitute.sting.gatk.walkers.bqsr.RecalibrationArgumentCollection;
|
||||
import org.broadinstitute.sting.utils.classloader.JVMUtils;
|
||||
import org.broadinstitute.sting.utils.recalibration.covariates.*;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.R.RScriptExecutor;
|
||||
|
|
@ -117,6 +118,12 @@ public class RecalUtils {
|
|||
|
||||
if (argumentCollection.COVARIATES != null) { // parse the -cov arguments that were provided, skipping over the ones already specified
|
||||
for (String requestedCovariateString : argumentCollection.COVARIATES) {
|
||||
// help the transition from BQSR v1 to BQSR v2
|
||||
if ( requestedCovariateString.equals("DinucCovariate") )
|
||||
throw new UserException.CommandLineException("DinucCovariate has been retired. Please use its successor covariate " +
|
||||
"ContextCovariate instead, which includes the 2 bp (dinuc) substitution model of the retired DinucCovariate " +
|
||||
"as well as an indel context to model the indel error rates");
|
||||
|
||||
boolean foundClass = false;
|
||||
for (Class<? extends Covariate> covClass : covariateClasses) {
|
||||
if (requestedCovariateString.equalsIgnoreCase(covClass.getSimpleName())) { // -cov argument matches the class name for an implementing class
|
||||
|
|
@ -178,18 +185,18 @@ public class RecalUtils {
|
|||
return dest;
|
||||
}
|
||||
|
||||
public static void listAvailableCovariates(Logger logger) {
|
||||
// Get a list of all available covariates
|
||||
final List<Class<? extends Covariate>> covariateClasses = new PluginManager<Covariate>(Covariate.class).getPlugins();
|
||||
|
||||
// Print and exit if that's what was requested
|
||||
/**
|
||||
* Print a list of all available covariates to logger as info
|
||||
*
|
||||
* @param logger
|
||||
*/
|
||||
public static void listAvailableCovariates(final Logger logger) {
|
||||
logger.info("Available covariates:");
|
||||
for (Class<?> covClass : covariateClasses)
|
||||
logger.info(covClass.getSimpleName());
|
||||
logger.info("");
|
||||
for (final Class<? extends Covariate> covClass : new PluginManager<Covariate>(Covariate.class).getPlugins()) {
|
||||
logger.info(String.format("\t%30s\t%s", covClass.getSimpleName(), JVMUtils.classInterfaces(covClass)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum SOLID_RECAL_MODE {
|
||||
/**
|
||||
* Treat reference inserted bases as reference matching bases. Very unsafe!
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
package org.broadinstitute.sting.utils.recalibration.covariates;
|
||||
|
||||
import org.broadinstitute.sting.utils.recalibration.ReadCovariates;
|
||||
import org.broadinstitute.sting.gatk.walkers.bqsr.RecalibrationArgumentCollection;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
|
||||
/**
|
||||
* Binary covariate allows BQSR to recalibrate based on a binary covariate in the BAM file. This covariate should assume values of 1 and 0.
|
||||
*
|
||||
* @author Mauricio Carneiro
|
||||
* @since 7/6/12
|
||||
*/
|
||||
public class BinaryTagCovariate implements ExperimentalCovariate {
|
||||
|
||||
private String tag;
|
||||
|
||||
@Override
|
||||
public void initialize(RecalibrationArgumentCollection RAC) {
|
||||
tag = RAC.BINARY_TAG_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordValues(GATKSAMRecord read, ReadCovariates values) {
|
||||
final Object tagObject = read.getAttribute(tag);
|
||||
|
||||
byte[] binaryTag;
|
||||
if (tagObject instanceof byte[])
|
||||
binaryTag = (byte[]) tagObject;
|
||||
else if (tagObject instanceof String) {
|
||||
int readLength = ((String) tagObject).length();
|
||||
binaryTag = new byte[readLength];
|
||||
for (int i = 0; i<readLength; i++)
|
||||
binaryTag[i] = Byte.decode(((String) tagObject).substring(i, i+1));
|
||||
}
|
||||
else
|
||||
throw new UserException("Binary tag is not a byte array (fast) or a string (slow). Type not supported");
|
||||
|
||||
for (int i = 0; i < read.getReadLength(); i++) {
|
||||
values.addCovariate((int) binaryTag[i], (int) binaryTag[i], (int) binaryTag[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(String str) {
|
||||
return Integer.decode(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatKey(int key) {
|
||||
return String.format("%d", key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int keyFromValue(Object value) {
|
||||
return Integer.decode((String) value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maximumKeyValue() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue