|
12 | 12 | import org.labkey.api.sequenceanalysis.pipeline.PipelineContext; |
13 | 13 | import org.labkey.api.sequenceanalysis.pipeline.PipelineStepProvider; |
14 | 14 | import org.labkey.api.sequenceanalysis.pipeline.ReferenceGenome; |
| 15 | +import org.labkey.api.sequenceanalysis.pipeline.SamtoolsIndexer; |
15 | 16 | import org.labkey.api.sequenceanalysis.pipeline.SamtoolsRunner; |
16 | 17 | import org.labkey.api.sequenceanalysis.pipeline.SequencePipelineService; |
17 | 18 | import org.labkey.api.sequenceanalysis.run.SimpleScriptWrapper; |
@@ -53,11 +54,21 @@ public Output performAnalysisPerSampleRemote(Readset rs, File inputBam, Referenc |
53 | 54 | { |
54 | 55 | CramToBam samtoolsRunner = new CramToBam(getPipelineCtx().getLogger()); |
55 | 56 | File bam = new File(getPipelineCtx().getWorkingDirectory(), inputFile.getName().replaceAll(".cram$", ".bam")); |
56 | | - samtoolsRunner.convert(inputFile, bam, referenceGenome.getWorkingFastaFile(), SequencePipelineService.get().getMaxThreads(getPipelineCtx().getLogger())); |
| 57 | + File bamIdx = new File(bam.getPath() + ".bai"); |
| 58 | + if (!bamIdx.exists()) |
| 59 | + { |
| 60 | + samtoolsRunner.convert(inputFile, bam, referenceGenome.getWorkingFastaFile(), SequencePipelineService.get().getMaxThreads(getPipelineCtx().getLogger())); |
| 61 | + new SamtoolsIndexer(getPipelineCtx().getLogger()).execute(bam); |
| 62 | + } |
| 63 | + else |
| 64 | + { |
| 65 | + getPipelineCtx().getLogger().debug("BAM index exists, will not re-convert CRAM"); |
| 66 | + } |
| 67 | + |
57 | 68 | inputFile = bam; |
58 | 69 |
|
59 | 70 | output.addIntermediateFile(bam); |
60 | | - output.addIntermediateFile(new File(bam.getPath() + ".bai")); |
| 71 | + output.addIntermediateFile(bamIdx); |
61 | 72 | } |
62 | 73 |
|
63 | 74 | List<String> args = new ArrayList<>(); |
|
0 commit comments