|
5 | 5 | import org.apache.commons.lang3.StringUtils; |
6 | 6 | import org.apache.commons.lang3.math.NumberUtils; |
7 | 7 | import org.jetbrains.annotations.Nullable; |
| 8 | +import org.json.JSONObject; |
8 | 9 | import org.labkey.api.pipeline.PipelineJobException; |
9 | 10 | import org.labkey.api.reader.Readers; |
10 | 11 | import org.labkey.api.sequenceanalysis.SequenceAnalysisService; |
|
32 | 33 |
|
33 | 34 | abstract public class AbstractSingleCellPipelineStep extends AbstractPipelineStep implements SingleCellStep |
34 | 35 | { |
| 36 | + public static final String SEURAT_THREADS = "seuratMaxThreads"; |
| 37 | + |
35 | 38 | public AbstractSingleCellPipelineStep(PipelineStepProvider provider, PipelineContext ctx) |
36 | 39 | { |
37 | 40 | super(provider, ctx); |
@@ -250,12 +253,25 @@ protected void executeR(SequenceOutputHandler.JobContext ctx, File rmd, String o |
250 | 253 | errorFile.delete(); |
251 | 254 | } |
252 | 255 |
|
253 | | - executeR(ctx, getDockerContainerName(), outputPrefix, lines); |
| 256 | + Integer seuratThreads = null; |
| 257 | + if (getProvider().getParameterByName(SEURAT_THREADS) != null) |
| 258 | + { |
| 259 | + seuratThreads = getProvider().getParameterByName(SEURAT_THREADS).extractValue(ctx.getJob(), getProvider(), getStepIdx(), Integer.class, null); |
| 260 | + } |
| 261 | + |
| 262 | + executeR(ctx, getDockerContainerName(), outputPrefix, lines, seuratThreads); |
254 | 263 |
|
255 | 264 | handlePossibleFailure(ctx, outputPrefix); |
256 | 265 | } |
257 | 266 |
|
258 | | - public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerContainerName, String outputPrefix, List<String> lines) throws PipelineJobException |
| 267 | + protected static SeuratToolParameter getSeuratThreadsParam() |
| 268 | + { |
| 269 | + return SeuratToolParameter.create(SEURAT_THREADS, "Max Threads", "If provided, the docker session will set future::plan(strategy='multisession', workers=XXX), which is supported by certain Seurat functions.", "ldk-integerfield", new JSONObject(){{ |
| 270 | + put("minValue", 0); |
| 271 | + }}, null); |
| 272 | + } |
| 273 | + |
| 274 | + public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerContainerName, String outputPrefix, List<String> lines, @Nullable Integer seuratThreads) throws PipelineJobException |
259 | 275 | { |
260 | 276 | File localRScript = new File(ctx.getOutputDir(), FileUtil.makeLegalName(outputPrefix + ".R").replaceAll(" ", "_")); |
261 | 277 | try (PrintWriter writer = PrintWriters.getPrintWriter(localRScript)) |
@@ -285,6 +301,11 @@ public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerC |
285 | 301 | writer.println("\t-e SEQUENCEANALYSIS_MAX_THREADS=" + maxThreads + " \\"); |
286 | 302 | } |
287 | 303 |
|
| 304 | + if (seuratThreads != null) |
| 305 | + { |
| 306 | + writer.println("\t-e SEURAT_MAX_THREADS=" + seuratThreads + " \\"); |
| 307 | + } |
| 308 | + |
288 | 309 | Integer maxRam = SequencePipelineService.get().getMaxRam(); |
289 | 310 | if (maxRam != null) |
290 | 311 | { |
|
0 commit comments