Skip to content

Commit d0ca84a

Browse files
committed
More active deletion of temp files during SRA download
1 parent ebbf8c7 commit d0ca84a

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/pipeline/SequenceAlignmentTask.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,20 @@ private void alignSet(Readset rs, String basename, Map<ReadData, Pair<File, File
702702
_resumer.setInitialAlignmentDone(bam, alignActions, discardBam);
703703
}
704704

705+
// Because this folder can be large, delete it quickly when possible:
706+
if (getCachedReadDataDir().exists())
707+
{
708+
try
709+
{
710+
getJob().getLogger().debug("Deleting cachedReadDataDir");
711+
FileUtils.deleteDirectory(getCachedReadDataDir());
712+
}
713+
catch (IOException e)
714+
{
715+
throw new PipelineJobException(e);
716+
}
717+
}
718+
705719
// This is a special case where the alignment does not actually generate a permanent BAM
706720
if (bam == null && discardBam)
707721
{
@@ -1892,8 +1906,34 @@ public void serializeTest() throws Exception
18921906
}
18931907
}
18941908

1909+
private File getCachedReadDataDir()
1910+
{
1911+
return new File(getHelper().getWorkingDirectory(), "cachedReadData");
1912+
}
1913+
18951914
private void restoreArchivedReadDataIfNeeded(Readset rs) throws PipelineJobException
18961915
{
1916+
if (_resumer.isInitialAlignmentDone())
1917+
{
1918+
getJob().getLogger().debug("Initial alignment is complete, will not attempt to download SRA if needed");
1919+
1920+
if (getCachedReadDataDir().exists())
1921+
{
1922+
getJob().getLogger().debug("Deleting existing cachedReadDataDir");
1923+
1924+
try
1925+
{
1926+
FileUtils.deleteDirectory(getCachedReadDataDir());
1927+
}
1928+
catch (IOException e)
1929+
{
1930+
throw new PipelineJobException(e);
1931+
}
1932+
}
1933+
1934+
return;
1935+
}
1936+
18971937
Set<String> sraIDs = new HashSet<>();
18981938
for (ReadData rd : rs.getReadData())
18991939
{
@@ -1947,7 +1987,7 @@ else if (sraIDs.contains(rd.getSra_accession()))
19471987
}
19481988
}
19491989

1950-
File outDir = new File(getHelper().getWorkingDirectory(), "cachedReadData");
1990+
File outDir = getCachedReadDataDir();
19511991
getTaskFileManagerImpl().addDeferredIntermediateFile(outDir); // NOTE: this must be deferred so it remains until the end
19521992

19531993
File doneFile = new File(outDir, rd.getSra_accession() + ".done");

singlecell/src/org/labkey/singlecell/run/NimbleHelper.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,21 @@ private Map<NimbleGenome, File> doAlignment(List<NimbleGenome> genomes, List<Fil
460460
alignArgs.add(tmpDir.getPath());
461461

462462
boolean dockerRan = runUsingDocker(alignArgs, output, "align.all");
463+
464+
// Because this can be large, delete it quickly:
465+
if (tmpDir.exists())
466+
{
467+
try
468+
{
469+
getPipelineCtx().getLogger().debug("Deleting nimble temp dir");
470+
FileUtils.deleteDirectory(tmpDir);
471+
}
472+
catch (IOException e)
473+
{
474+
throw new PipelineJobException(e);
475+
}
476+
}
477+
463478
for (NimbleGenome genome : genomes)
464479
{
465480
File alignResultsGz = new File(getPipelineCtx().getWorkingDirectory(), "alignResults." + genome.genomeId + ".txt.gz");

0 commit comments

Comments
 (0)