Skip to content

Commit c57d7e7

Browse files
committed
Defer sorting of cellsnp VCF
1 parent 392881b commit c57d7e7

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

singlecell/src/org/labkey/singlecell/pipeline/singlecell/VireoHandler.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,6 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
277277
throw new PipelineJobException("Unable to find cellsnp calls VCF");
278278
}
279279

280-
sortAndFixVcf(cellSnpBaseVcf, genome, ctx.getLogger());
281-
sortAndFixVcf(cellSnpCellsVcf, genome, ctx.getLogger());
282-
283280
int vcfFile = ctx.getParams().optInt(REF_VCF, -1);
284281
File refVcfSubset = null;
285282
if (vcfFile > -1)
@@ -377,33 +374,44 @@ else if (outFiles.length > 1)
377374

378375
if (storeCellSnpVcf)
379376
{
377+
File fixedVcf = sortAndFixVcf(cellSnpBaseVcf, genome, ctx.getLogger(), ctx.getWorkingDirectory());
378+
380379
SequenceOutputFile so = new SequenceOutputFile();
381380
so.setReadset(inputFiles.get(0).getReadset());
382381
so.setLibrary_id(inputFiles.get(0).getLibrary_id());
383-
so.setFile(cellSnpCellsVcf);
382+
so.setFile(fixedVcf);
384383
if (so.getReadset() != null)
385384
{
386385
so.setName(ctx.getSequenceSupport().getCachedReadset(so.getReadset()).getName() + ": Cellsnp-lite VCF");
387386
}
388387
else
389388
{
390-
so.setName(inputFiles.get(0).getName() + ": Cellsnp-lite VCF");
389+
so.setName(inputFiles.get(0).getName() + ": Cellsnp-lite Base VCF");
391390
}
392391
so.setCategory("VCF File");
393392
ctx.addSequenceOutput(so);
394393
}
394+
else
395+
{
396+
ctx.getFileManager().addIntermediateFile(cellSnpBaseVcf.getParentFile());
397+
}
395398
}
396399

397-
private void sortAndFixVcf(File vcf, ReferenceGenome genome, Logger log) throws PipelineJobException
400+
private File sortAndFixVcf(File vcf, ReferenceGenome genome, Logger log, File outDir) throws PipelineJobException
398401
{
402+
File outVcf = new File(outDir, vcf.getName());
403+
399404
// This original VCF is generally not properly sorted, and has an invalid index. This is redundant, the VCF is not that large:
400405
try
401406
{
402-
SequencePipelineService.get().sortROD(vcf, log, 2);
403-
SequenceAnalysisService.get().ensureVcfIndex(vcf, log, true);
407+
FileUtils.copyFile(vcf, outVcf);
408+
SequencePipelineService.get().sortROD(outVcf, log, 2);
409+
SequenceAnalysisService.get().ensureVcfIndex(outVcf, log, true);
410+
411+
new UpdateVCFSequenceDictionary(log).execute(outVcf, genome.getSequenceDictionary());
412+
SequenceAnalysisService.get().ensureVcfIndex(outVcf, log);
404413

405-
new UpdateVCFSequenceDictionary(log).execute(vcf, genome.getSequenceDictionary());
406-
SequenceAnalysisService.get().ensureVcfIndex(vcf, log);
414+
return outVcf;
407415
}
408416
catch (IOException e)
409417
{

0 commit comments

Comments
 (0)