|
| 1 | +package org.labkey.singlecell.pipeline.singlecell; |
| 2 | + |
| 3 | +import org.labkey.api.pipeline.PipelineJobException; |
| 4 | +import org.labkey.api.sequenceanalysis.SequenceOutputFile; |
| 5 | +import org.labkey.api.sequenceanalysis.model.Readset; |
| 6 | +import org.labkey.api.sequenceanalysis.pipeline.AbstractPipelineStepProvider; |
| 7 | +import org.labkey.api.sequenceanalysis.pipeline.PipelineContext; |
| 8 | +import org.labkey.api.sequenceanalysis.pipeline.SequenceOutputHandler; |
| 9 | +import org.labkey.api.singlecell.CellHashingService; |
| 10 | +import org.labkey.api.singlecell.pipeline.SeuratToolParameter; |
| 11 | +import org.labkey.api.singlecell.pipeline.SingleCellStep; |
| 12 | +import org.labkey.singlecell.CellHashingServiceImpl; |
| 13 | + |
| 14 | +import java.util.Arrays; |
| 15 | +import java.util.Collections; |
| 16 | +import java.util.List; |
| 17 | +import java.util.Set; |
| 18 | + |
| 19 | +public class CheckExpectations extends AbstractCellMembraneStep |
| 20 | +{ |
| 21 | + public CheckExpectations(PipelineContext ctx, CheckExpectations.Provider provider) |
| 22 | + { |
| 23 | + super(provider, ctx); |
| 24 | + } |
| 25 | + |
| 26 | + public static class Provider extends AbstractPipelineStepProvider<SingleCellStep> |
| 27 | + { |
| 28 | + public Provider() |
| 29 | + { |
| 30 | + super("CheckExpectations", "Check Expectations", "CellMembrane", "This will tag the output of this job as a seurat prototype, which is designed to be a building block for subsequent analyses.", Arrays.asList( |
| 31 | + SeuratToolParameter.create("requireSingleDatasetInput", "Expect Single Datasets", "If checked, this will enforce that each input seurat object holds a single dataset. This is expected if the input is a seurat prototype. In contrast, if the input is a merged object this would test false", "checkbox", null, true), |
| 32 | + SeuratToolParameter.create("requireHashing", "Require Hashing, If Used", "If this dataset uses cell hashing, hashing calls are required", "checkbox", null, true), |
| 33 | + SeuratToolParameter.create("requireCiteSeq", "Require Cite-Seq, If Used", "If this dataset uses CITE-seq, cite-seq data are required", "checkbox", null, true), |
| 34 | + SeuratToolParameter.create("requireSaturation", "Require Per-Cell Saturation", "If this dataset uses TCR sequencing, these data are required", "checkbox", null, true), |
| 35 | + SeuratToolParameter.create("requireSingleR", "Require SingleR", "If checked, SingleR calls, including singleRConsensus are required to pass", "checkbox", null, true), |
| 36 | + SeuratToolParameter.create("requireScGate", "Require scGate", "If checked, scGateConsensus calls are required to pass", "checkbox", null, true) |
| 37 | + ), null, null); |
| 38 | + } |
| 39 | + |
| 40 | + @Override |
| 41 | + public CheckExpectations create(PipelineContext ctx) |
| 42 | + { |
| 43 | + return new CheckExpectations(ctx, this); |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + public void init(SequenceOutputHandler.JobContext ctx, List<SequenceOutputFile> inputFiles) throws PipelineJobException |
| 49 | + { |
| 50 | + |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + protected Chunk createParamChunk(SequenceOutputHandler.JobContext ctx, List<SeuratObjectWrapper> inputObjects, String outputPrefix) throws PipelineJobException |
| 55 | + { |
| 56 | + Chunk ret = super.createParamChunk(ctx, inputObjects, outputPrefix); |
| 57 | + |
| 58 | + ret.bodyLines.add("usesHashing <- list()"); |
| 59 | + ret.bodyLines.add("usesCiteSeq <- list()"); |
| 60 | + |
| 61 | + for (SeuratObjectWrapper so : inputObjects) |
| 62 | + { |
| 63 | + Readset parentReadset = ctx.getSequenceSupport().getCachedReadset(so.getSequenceOutputFile().getReadset()); |
| 64 | + if (parentReadset == null) |
| 65 | + { |
| 66 | + throw new PipelineJobException("Unable to find readset for outputfile: " + so.getSequenceOutputFileId()); |
| 67 | + } |
| 68 | + |
| 69 | + Set<String> htosPerReadset = CellHashingServiceImpl.get().getHtosForParentReadset(parentReadset.getReadsetId(), ctx.getSourceDirectory(), ctx.getSequenceSupport(), false); |
| 70 | + ret.bodyLines.add("usesHashing[['" + so.getDatasetId() + "']] <- " + (htosPerReadset.size() > 1 ? "TRUE" : "FALSE")); |
| 71 | + |
| 72 | + boolean usesCiteseq = CellHashingService.get().usesCiteSeq(ctx.getSequenceSupport(), Collections.singletonList(so.getSequenceOutputFile())); |
| 73 | + ret.bodyLines.add("usesCiteSeq[['" + so.getDatasetId() + "']] <- " + (usesCiteseq ? "TRUE" : "FALSE")); |
| 74 | + } |
| 75 | + |
| 76 | + return ret; |
| 77 | + } |
| 78 | +} |
0 commit comments