Skip to content

Commit 340ee5a

Browse files
committed
Ensure cellranger-dependent steps retain BAM
1 parent 3a6b43e commit 340ee5a

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ protected File runCellRanger(AlignmentOutputImpl output, Readset rs, List<File>
3636
File localBam = new File(outputDirectory, basename + ".cellranger.bam");
3737
File localBamIdx = SequenceAnalysisService.get().getExpectedBamOrCramIndex(localBam);
3838

39-
4039
String idParam = StringUtils.trimToNull(getProvider().getParameterByName("id").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), String.class));
4140
File cellrangerOutdir = new File(outputDirectory, CellRangerWrapper.getId(idParam, rs));
4241

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,18 @@ public boolean canAlignMultiplePairsAtOnce()
319319
return true;
320320
}
321321

322+
private boolean shouldDiscardBam()
323+
{
324+
return !_alwaysRetainBam && getProvider().getParameterByName(AbstractAlignmentStepProvider.DISCARD_BAM).extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, false);
325+
}
326+
327+
private boolean _alwaysRetainBam = false;
328+
329+
public void setAlwaysRetainBam(boolean alwaysRetainBam)
330+
{
331+
_alwaysRetainBam = alwaysRetainBam;
332+
}
333+
322334
@Override
323335
public AlignmentOutput performAlignment(Readset rs, List<File> inputFastqs1, @Nullable List<File> inputFastqs2, File outputDirectory, ReferenceGenome referenceGenome, String basename, String readGroupId, @Nullable String platformUnit) throws PipelineJobException
324336
{
@@ -359,8 +371,7 @@ public AlignmentOutput performAlignment(Readset rs, List<File> inputFastqs1, @Nu
359371
File indexDir = AlignerIndexUtil.getIndexDir(referenceGenome, getIndexCachedDirName(getPipelineCtx().getJob()));
360372
args.add("--transcriptome=" + indexDir.getPath());
361373

362-
boolean discardBam = getProvider().getParameterByName(AbstractAlignmentStepProvider.DISCARD_BAM).extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, false);
363-
args.add("--create-bam=" + !discardBam);
374+
args.add("--create-bam=" + !shouldDiscardBam());
364375

365376
getWrapper().setWorkingDir(outputDirectory);
366377

@@ -377,7 +388,7 @@ public AlignmentOutput performAlignment(Readset rs, List<File> inputFastqs1, @Nu
377388
File outdir = new File(outputDirectory, id);
378389
outdir = new File(outdir, "outs");
379390

380-
if (!discardBam)
391+
if (!shouldDiscardBam())
381392
{
382393
File bam = new File(outdir, "possorted_genome_bam.bam");
383394
if (!bam.exists())

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public static List<ToolParameterDescriptor> getToolParameters()
6767
public AlignmentOutput performAlignment(Readset rs, List<File> inputFastqs1, @Nullable List<File> inputFastqs2, File outputDirectory, ReferenceGenome referenceGenome, String basename, String readGroupId, @Nullable String platformUnit) throws PipelineJobException
6868
{
6969
AlignmentOutputImpl output = new AlignmentOutputImpl();
70+
71+
// We need to ensure we keep the BAM for post-processing:
72+
setAlwaysRetainBam(true);
73+
7074
File localBam = runCellRanger(output, rs, inputFastqs1, inputFastqs2, outputDirectory, referenceGenome, basename, readGroupId, platformUnit);
7175

7276
File crDir = new File(localBam.getPath().replace(".nimble.cellranger.bam", ""));

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public AlignmentStep create(PipelineContext context)
6767
public AlignmentOutput performAlignment(Readset rs, List<File> inputFastqs1, @Nullable List<File> inputFastqs2, File outputDirectory, ReferenceGenome referenceGenome, String basename, String readGroupId, @Nullable String platformUnit) throws PipelineJobException
6868
{
6969
AlignmentOutputImpl output = new AlignmentOutputImpl();
70+
71+
setAlwaysRetainBam(true);
72+
7073
File localBam = runCellRanger(output, rs, inputFastqs1, inputFastqs2, outputDirectory, referenceGenome, basename, readGroupId, platformUnit);
7174

7275
File gtf = getPipelineCtx().getSequenceSupport().getCachedData(getProvider().getParameterByName("gtfFile").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Integer.class));

0 commit comments

Comments
 (0)