Merge pull request #284 from broadinstitute/dr_fewer_stranded_temp_files

Reduce number of leftover temp files in GATK runs
This commit is contained in:
Mark DePristo 2013-06-14 13:06:28 -07:00
commit 52677429a0
3 changed files with 10 additions and 0 deletions

View File

@ -176,6 +176,7 @@ public class VariantsToBinaryPed extends RodWalker<Integer,Integer> {
// Cut down on memory.
try {
File temp = File.createTempFile("VariantsToBPed_"+sample, ".tmp");
temp.deleteOnExit();
printMap.put(sample,new PrintStream(temp));
tempFiles.put(sample,temp);
} catch (IOException e) {

View File

@ -182,6 +182,11 @@ public class ArtificialBAMBuilder {
try {
final File file = File.createTempFile("tempBAM", ".bam");
file.deleteOnExit();
// Register the bam index file for deletion on exit as well:
new File(file.getAbsolutePath().replace(".bam", ".bai")).deleteOnExit();
new File(file.getAbsolutePath() + ".bai").deleteOnExit();
return makeBAMFile(file);
} catch ( IOException e ) {
throw new RuntimeException(e);

View File

@ -312,6 +312,10 @@ public class WalkerTest extends BaseTest {
for (int i = 0; i < spec.nOutputFiles; i++) {
String ext = spec.exts == null ? ".tmp" : "." + spec.exts.get(i);
File fl = createTempFile(String.format("walktest.tmp_param.%d", i), ext);
// Mark corresponding *.idx for deletion on exit as well just in case an index is created for the temp file:
new File(fl.getAbsolutePath() + ".idx").deleteOnExit();
tmpFiles.add(fl);
}