From 71ecbe75d72f15a1b40fb2cb261b9d1ebc4729be Mon Sep 17 00:00:00 2001 From: rpoplin Date: Wed, 6 Jan 2010 14:19:02 +0000 Subject: [PATCH] AnalyzeCovariates would crash with 'too many open files' exception when spawning Rscript jobs for every read group at once. It now waits for some to finish before spawning the rest. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2508 348d0f76-0448-11de-a6fe-93d51630548a --- .../analyzecovariates/AnalyzeCovariates.java | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/java/src/org/broadinstitute/sting/analyzecovariates/AnalyzeCovariates.java b/java/src/org/broadinstitute/sting/analyzecovariates/AnalyzeCovariates.java index f44df4189..05cdce2eb 100755 --- a/java/src/org/broadinstitute/sting/analyzecovariates/AnalyzeCovariates.java +++ b/java/src/org/broadinstitute/sting/analyzecovariates/AnalyzeCovariates.java @@ -237,24 +237,45 @@ class AnalyzeCovariatesCLP extends CommandLineProgram { String readGroup = readGroupKey.toString(); System.out.println("Analyzing read group: " + readGroup); + Process p = null; // for each covariate for( int iii = 1; iii < requestedCovariates.size(); iii++ ) { Covariate cov = requestedCovariates.get(iii); + try { if( iii == 1 ) { // Analyze reported quality - Process p = Runtime.getRuntime().exec(PATH_TO_RSCRIPT + " " + PATH_TO_RESOURCES + "plot_residualError_QualityScoreCovariate.R" + " " + + p = Runtime.getRuntime().exec(PATH_TO_RSCRIPT + " " + PATH_TO_RESOURCES + "plot_residualError_QualityScoreCovariate.R" + " " + OUTPUT_DIR + readGroup + "." + cov.getClass().getSimpleName()+ ".dat" + " " + IGNORE_QSCORES_LESS_THAN); // The third argument is the Q scores that should be turned pink in the plot because they were ignored } else { // Analyze all other covariates - Process p = Runtime.getRuntime().exec(PATH_TO_RSCRIPT + " " + PATH_TO_RESOURCES + "plot_residualError_OtherCovariate.R" + " " + + p = Runtime.getRuntime().exec(PATH_TO_RSCRIPT + " " + PATH_TO_RESOURCES + "plot_residualError_OtherCovariate.R" + " " + 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 } - } catch (IOException e) { - e.printStackTrace(); - System.exit(-1); + } catch (IOException ex) { + try { + Thread.sleep(1600); // wait for 1.6 seconds and then try to spawn the process again + if( iii == 1 ) { + // Analyze reported quality + p = Runtime.getRuntime().exec(PATH_TO_RSCRIPT + " " + PATH_TO_RESOURCES + "plot_residualError_QualityScoreCovariate.R" + " " + + OUTPUT_DIR + readGroup + "." + cov.getClass().getSimpleName()+ ".dat" + " " + + IGNORE_QSCORES_LESS_THAN); // The third argument is the Q scores that should be turned pink in the plot because they were ignored + } else { // Analyze all other covariates + p = Runtime.getRuntime().exec(PATH_TO_RSCRIPT + " " + PATH_TO_RESOURCES + "plot_residualError_OtherCovariate.R" + " " + + 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 + } + + } catch (InterruptedException e) { + e.printStackTrace(); + System.exit(-1); + } catch (IOException e) { + e.printStackTrace(); + System.exit(-1); + } } + } } else { break;