AnalyzeCovariates uses the general RScript system now
-- Convenience constructor for collection for testing -- callRScript() now accepts Objects not Strings, for convenience
This commit is contained in:
parent
810a71c631
commit
ccec0b4d73
|
|
@ -31,6 +31,7 @@ import org.broadinstitute.sting.commandline.Input;
|
||||||
import org.broadinstitute.sting.gatk.walkers.recalibration.Covariate;
|
import org.broadinstitute.sting.gatk.walkers.recalibration.Covariate;
|
||||||
import org.broadinstitute.sting.gatk.walkers.recalibration.RecalDatum;
|
import org.broadinstitute.sting.gatk.walkers.recalibration.RecalDatum;
|
||||||
import org.broadinstitute.sting.gatk.walkers.recalibration.RecalibrationArgumentCollection;
|
import org.broadinstitute.sting.gatk.walkers.recalibration.RecalibrationArgumentCollection;
|
||||||
|
import org.broadinstitute.sting.utils.R.RScriptExecutor;
|
||||||
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
||||||
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
|
import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException;
|
||||||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||||
|
|
@ -38,6 +39,7 @@ import org.broadinstitute.sting.utils.text.XReadLines;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
@ -323,13 +325,14 @@ public class AnalyzeCovariates extends CommandLineProgram {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callRScripts() {
|
private void callRScripts() {
|
||||||
|
RScriptExecutor.RScriptArgumentCollection argumentCollection =
|
||||||
|
new RScriptExecutor.RScriptArgumentCollection(PATH_TO_RSCRIPT, Arrays.asList(PATH_TO_RESOURCES));
|
||||||
|
RScriptExecutor executor = new RScriptExecutor(argumentCollection, true);
|
||||||
|
|
||||||
int numReadGroups = 0;
|
int numReadGroups = 0;
|
||||||
|
|
||||||
// for each read group
|
// for each read group
|
||||||
for( Object readGroupKey : dataManager.getCollapsedTable(0).data.keySet() ) {
|
for( Object readGroupKey : dataManager.getCollapsedTable(0).data.keySet() ) {
|
||||||
|
|
||||||
Process p;
|
|
||||||
if(++numReadGroups <= NUM_READ_GROUPS_TO_PROCESS || NUM_READ_GROUPS_TO_PROCESS == -1) {
|
if(++numReadGroups <= NUM_READ_GROUPS_TO_PROCESS || NUM_READ_GROUPS_TO_PROCESS == -1) {
|
||||||
|
|
||||||
String readGroup = readGroupKey.toString();
|
String readGroup = readGroupKey.toString();
|
||||||
|
|
@ -338,36 +341,20 @@ public class AnalyzeCovariates extends CommandLineProgram {
|
||||||
// for each covariate
|
// for each covariate
|
||||||
for( int iii = 1; iii < requestedCovariates.size(); iii++ ) {
|
for( int iii = 1; iii < requestedCovariates.size(); iii++ ) {
|
||||||
Covariate cov = requestedCovariates.get(iii);
|
Covariate cov = requestedCovariates.get(iii);
|
||||||
try {
|
final String outputFilename = OUTPUT_DIR + readGroup + "." + cov.getClass().getSimpleName()+ ".dat";
|
||||||
|
|
||||||
if (DO_INDEL_QUALITY) {
|
if (DO_INDEL_QUALITY) {
|
||||||
p = Runtime.getRuntime().exec(PATH_TO_RSCRIPT + " " + PATH_TO_RESOURCES + "plot_indelQuality.R" + " " +
|
executor.callRScripts("plot_indelQuality.R", outputFilename,
|
||||||
OUTPUT_DIR + readGroup + "." + cov.getClass().getSimpleName()+ ".dat" + " " +
|
|
||||||
cov.getClass().getSimpleName().split("Covariate")[0]); // The third argument is the name of the covariate in order to make the plots look nice
|
cov.getClass().getSimpleName().split("Covariate")[0]); // The third argument is the name of the covariate in order to make the plots look nice
|
||||||
p.waitFor();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if( iii == 1 ) {
|
if( iii == 1 ) {
|
||||||
// Analyze reported quality
|
// Analyze reported quality
|
||||||
p = Runtime.getRuntime().exec(PATH_TO_RSCRIPT + " " + PATH_TO_RESOURCES + "plot_residualError_QualityScoreCovariate.R" + " " +
|
executor.callRScripts("plot_residualError_QualityScoreCovariate.R", outputFilename,
|
||||||
OUTPUT_DIR + readGroup + "." + cov.getClass().getSimpleName()+ ".dat" + " " +
|
IGNORE_QSCORES_LESS_THAN, MAX_QUALITY_SCORE, MAX_HISTOGRAM_VALUE); // The third argument is the Q scores that should be turned pink in the plot because they were ignored
|
||||||
IGNORE_QSCORES_LESS_THAN + " " + MAX_QUALITY_SCORE + " " + MAX_HISTOGRAM_VALUE); // The third argument is the Q scores that should be turned pink in the plot because they were ignored
|
|
||||||
p.waitFor();
|
|
||||||
} else { // Analyze all other covariates
|
} else { // Analyze all other covariates
|
||||||
p = Runtime.getRuntime().exec(PATH_TO_RSCRIPT + " " + PATH_TO_RESOURCES + "plot_residualError_OtherCovariate.R" + " " +
|
executor.callRScripts("plot_residualError_OtherCovariate.R", outputFilename,
|
||||||
OUTPUT_DIR + readGroup + "." + cov.getClass().getSimpleName()+ ".dat" + " " +
|
|
||||||
cov.getClass().getSimpleName().split("Covariate")[0]); // The third argument is the name of the covariate in order to make the plots look nice
|
cov.getClass().getSimpleName().split("Covariate")[0]); // The third argument is the name of the covariate in order to make the plots look nice
|
||||||
p.waitFor();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(-1);
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.out.println("Fatal Exception: Perhaps RScript jobs are being spawned too quickly? One work around is to process fewer read groups using the -numRG option.");
|
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else { // at the maximum number of read groups so break out
|
} else { // at the maximum number of read groups so break out
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,16 @@ public class RScriptExecutor {
|
||||||
public String PATH_TO_RSCRIPT = "Rscript";
|
public String PATH_TO_RSCRIPT = "Rscript";
|
||||||
|
|
||||||
@Advanced
|
@Advanced
|
||||||
@Argument(fullName = "path_to_resources", shortName = "resources", doc = "Path to resources folder holding the Sting R scripts.", required = false)
|
@Argument(fullName = "path_to_Rresources", shortName = "Rresources", doc = "Path to resources folder holding the Sting R scripts.", required = false)
|
||||||
public List<String> PATH_TO_RESOURCES = Arrays.asList("public/R/", "private/R/");
|
public List<String> PATH_TO_RESOURCES = Arrays.asList("public/R/", "private/R/");
|
||||||
|
|
||||||
|
public RScriptArgumentCollection() {}
|
||||||
|
|
||||||
|
/** For testing and convenience */
|
||||||
|
public RScriptArgumentCollection(final String PATH_TO_RSCRIPT, final List<String> PATH_TO_RESOURCES) {
|
||||||
|
this.PATH_TO_RSCRIPT = PATH_TO_RSCRIPT;
|
||||||
|
this.PATH_TO_RESOURCES = PATH_TO_RESOURCES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final RScriptArgumentCollection myArgs;
|
final RScriptArgumentCollection myArgs;
|
||||||
|
|
@ -69,11 +77,11 @@ public class RScriptExecutor {
|
||||||
this.exceptOnError = exceptOnError;
|
this.exceptOnError = exceptOnError;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void callRScripts(String scriptName, String... scriptArgs) {
|
public void callRScripts(String scriptName, Object... scriptArgs) {
|
||||||
callRScripts(scriptName, Arrays.asList(scriptArgs));
|
callRScripts(scriptName, Arrays.asList(scriptArgs));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void callRScripts(String scriptName, List<String> scriptArgs) {
|
public void callRScripts(String scriptName, List<Object> scriptArgs) {
|
||||||
try {
|
try {
|
||||||
final File pathToScript = findScript(scriptName);
|
final File pathToScript = findScript(scriptName);
|
||||||
if ( pathToScript == null ) return; // we failed but shouldn't exception out
|
if ( pathToScript == null ) return; // we failed but shouldn't exception out
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue