Skip to content

Commit 12cc011

Browse files
committed
Ensure savedSeuratObjects.txt file has unique name per job
1 parent d084f57 commit 12cc011

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

singlecell/api-src/org/labkey/api/singlecell/pipeline/AbstractSingleCellPipelineStep.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@ public AbstractSingleCellPipelineStep(PipelineStepProvider<?> provider, Pipeline
4343
super(provider, ctx);
4444
}
4545

46+
private String getSavedSeuratFileName(String outputPrefix)
47+
{
48+
return outputPrefix + ".savedSeuratObjects.txt";
49+
}
50+
4651
@Override
4752
public Output execute(SequenceOutputHandler.JobContext ctx, List<SeuratObjectWrapper> inputObjects, String outputPrefix) throws PipelineJobException
4853
{
4954
SingleCellOutput output = new SingleCellOutput();
5055

51-
File tracker = new File(ctx.getOutputDir(), "savedSeuratObjects.txt");
56+
File tracker = new File(ctx.getOutputDir(), getSavedSeuratFileName(outputPrefix));
5257
if (tracker.exists())
5358
{
5459
ctx.getLogger().debug("deleting pre-existing file: " + tracker.getName());
@@ -481,6 +486,7 @@ protected Chunk createParamChunk(SequenceOutputHandler.JobContext ctx, List<Seur
481486
}
482487
body.add("");
483488
body.add("outputPrefix <- '" + outputPrefix + "'");
489+
body.add("trackerFile <- paste0('/work/" + getSavedSeuratFileName(outputPrefix) + "'");
484490

485491
//Read RDS:
486492
body.add("");

singlecell/resources/chunks/Functions.R

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ printName <- function(datasetId) {
6161
}
6262

6363
savedFiles <- data.frame(datasetId = character(), datasetName = character(), filename = character(), outputFileId = character(), readsetId = character())
64-
if (file.exists('/work/savedSeuratObjects.txt')) {
65-
print('Deleting pre-existing savedSeuratObjects.txt file')
66-
unlink('/work/savedSeuratObjects.txt')
64+
if (file.exists(trackerFile)) {
65+
print(paste0('Deleting pre-existing ', trackerFile, ' file'))
66+
unlink(trackerFile)
6767
}
6868

69-
file.create('/work/savedSeuratObjects.txt')
70-
print(paste0('Total lines in savedSeuratObjects.txt on job start:', length(readLines('savedSeuratObjects.txt'))))
69+
file.create(trackerFile)
70+
print(paste0('Total lines in ', trackerFile, ' on job start:', length(readLines(trackerFile))))
7171

7272
saveData <- function(seuratObj, datasetId) {
7373
message(paste0('Saving dataset: ', datasetId, ' with ', ncol(seuratObj), ' cells'))
@@ -101,8 +101,9 @@ saveData <- function(seuratObj, datasetId) {
101101
stop('Error saving seurat objects, more than one row!')
102102
}
103103

104-
write.table(toAppend, file = 'savedSeuratObjects.txt', quote = FALSE, sep = '\t', row.names = FALSE, col.names = FALSE, append = TRUE)
105-
print(paste0('Total lines in savedSeuratObjects.txt after save:', length(readLines('savedSeuratObjects.txt'))))
104+
print(paste0('Total lines in ', trackerFile, ' before save:', length(readLines(trackerFile))))
105+
write.table(toAppend, file = trackerFile, quote = FALSE, sep = '\t', row.names = FALSE, col.names = FALSE, append = TRUE)
106+
print(paste0('Total lines in ', trackerFile, ' after save:', length(readLines(trackerFile))))
106107

107108
# Write cell barcodes and metadata:
108109
metaDf <- seuratObj@meta.data

0 commit comments

Comments
 (0)