Skip to content

Commit 0e3c514

Browse files
committed
Improve handling of single cell pipeline when no new output is created
1 parent 8b67f38 commit 0e3c514

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

singlecell/src/org/labkey/singlecell/analysis/AbstractSingleCellHandler.java

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public void complete(JobContext ctx, List<SequenceOutputFile> inputs, List<Seque
283283
if (SEURAT_PROTOTYPE.equals(so.getCategory()))
284284
{
285285
//NOTE: upstream we enforce one dataset per job, so we can safely assume this is the only dataset here:
286-
File metricFile = new File(ctx.getJob().getLogFile().getParentFile(), "seurat.metrics.txt");
286+
File metricFile = FileUtil.appendName(ctx.getJob().getLogFile().getParentFile(), "seurat.metrics.txt");
287287
if (metricFile.exists())
288288
{
289289
processMetrics(so, ctx.getJob(), metricFile);
@@ -384,7 +384,6 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
384384

385385
List<SingleCellStep.SeuratObjectWrapper> currentFiles;
386386
Set<File> originalInputs = inputFiles.stream().map(SequenceOutputFile::getFile).collect(Collectors.toSet());
387-
Map<String, File> inputFileMap = new HashMap<>();
388387
if (_doProcessRawCounts)
389388
{
390389
currentFiles = processRawCounts(ctx, inputFiles, basename);
@@ -417,7 +416,6 @@ else if (_doProcessRawCounts)
417416
distinctIds.add(datasetId);
418417

419418
currentFiles.add(new SingleCellStep.SeuratObjectWrapper(datasetId, datasetId, so.getFile(), so));
420-
inputFileMap.put(so.getName(), so.getFile());
421419
}
422420
}
423421

@@ -542,7 +540,7 @@ else if (step.createsSeuratObjects())
542540
}
543541
finalMarkdown.chunks.add(new AbstractSingleCellPipelineStep.SessionInfoChunk());
544542

545-
File finalMarkdownFile = new File(ctx.getOutputDir(), "final.rmd");
543+
File finalMarkdownFile = FileUtil.appendName(ctx.getOutputDir(), "final.rmd");
546544
try (PrintWriter writer = PrintWriters.getPrintWriter(finalMarkdownFile))
547545
{
548546
finalMarkdown.print(writer);
@@ -553,7 +551,7 @@ else if (step.createsSeuratObjects())
553551
}
554552

555553
ctx.getJob().setStatus(PipelineJob.TaskStatus.running, "Creating Final HTML Report");
556-
File finalHtml = new File(ctx.getOutputDir(), "finalHtml.html");
554+
File finalHtml = FileUtil.appendName(ctx.getOutputDir(), "finalHtml.html");
557555
List<String> lines = new ArrayList<>();
558556
lines.add("rmarkdown::render(output_file = '" + finalHtml.getName() + "', input = '" + finalMarkdownFile.getName() + "', intermediates_dir = '" + ctx.getWorkingDirectory() + "')");
559557
AbstractSingleCellPipelineStep.executeR(ctx, AbstractCellMembraneStep.CONTAINER_NAME, "pandoc", lines, null, null, null);
@@ -623,23 +621,10 @@ else if (inputFiles.size() == 1)
623621

624622
//This indicates the job processed an input file, but did not create a new object (like running FindMarkers)
625623
boolean skipOutput = false;
626-
if (inputFileMap.containsKey(output.getFile().getName()))
624+
if (originalInputs.contains(output.getFile()))
627625
{
628-
try
629-
{
630-
ctx.getLogger().debug("Comparing file context of output to determine if it matches input: " + output.getFile().getName());
631-
ctx.getLogger().debug("Original file: " + inputFileMap.get(output.getFile().getName()));
632-
ctx.getLogger().debug("Pipeline output file: " + output.getFile());
633-
if (FileUtils.contentEquals(inputFileMap.get(output.getFile().getName()), output.getFile()))
634-
{
635-
ctx.getLogger().info("Sequence output is the same as an input, will not re-create output for seurat object: " + output.getFile().getPath());
636-
skipOutput = true;
637-
}
638-
}
639-
catch (IOException e)
640-
{
641-
throw new PipelineJobException(e);
642-
}
626+
ctx.getLogger().info("Sequence output is the same as an input, will not re-create output for seurat object: " + output.getFile().getPath());
627+
skipOutput = true;
643628
}
644629

645630
if (!skipOutput)
@@ -692,7 +677,7 @@ private List<SingleCellStep.SeuratObjectWrapper> processRawCounts(JobContext ctx
692677
List<SingleCellStep.SeuratObjectWrapper> inputMatrices = new ArrayList<>();
693678
inputFiles.forEach(x -> {
694679
String datasetName = ctx.getSequenceSupport().getCachedReadset(x.getReadset()).getName();
695-
File countsDir = new File(x.getFile().getParentFile(), "raw_feature_bc_matrix");
680+
File countsDir = FileUtil.appendName(x.getFile().getParentFile(), "raw_feature_bc_matrix");
696681
if (!countsDir.exists())
697682
{
698683
throw new IllegalArgumentException("Unable to find file: " + countsDir.getPath());
@@ -703,7 +688,7 @@ private List<SingleCellStep.SeuratObjectWrapper> processRawCounts(JobContext ctx
703688

704689
try
705690
{
706-
File localCopy = new File(ctx.getOutputDir(), x.getRowid() + "_RawData");
691+
File localCopy = FileUtil.appendName(ctx.getOutputDir(), x.getRowid() + "_RawData");
707692
if (localCopy.exists())
708693
{
709694
ctx.getLogger().debug("Deleting directory: " + localCopy.getPath());
@@ -901,7 +886,7 @@ public void serializeTest() throws Exception
901886
r._stepOutputs.put(1, List.of(new SingleCellStep.SeuratObjectWrapper("datasetId", "datasetName", new File("seurat.rds"), so1)));
902887

903888
File tmp = new File(System.getProperty("java.io.tmpdir"));
904-
File f = FileUtil.getAbsoluteCaseSensitiveFile(new File(tmp, AbstractSingleCellHandler.Resumer.JSON_NAME));
889+
File f = FileUtil.getAbsoluteCaseSensitiveFile(FileUtil.appendName(tmp, AbstractSingleCellHandler.Resumer.JSON_NAME));
905890

906891
SequenceOutputFile so = new SequenceOutputFile();
907892
so.setName("so1");

0 commit comments

Comments
 (0)