Skip to content

Commit d06a478

Browse files
committed
Allow resume for vireo/cellsnp
1 parent c7cde2c commit d06a478

File tree

1 file changed

+74
-53
lines changed

1 file changed

+74
-53
lines changed

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

Lines changed: 74 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -160,81 +160,102 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
160160
}
161161
ctx.getFileManager().addIntermediateFile(barcodes);
162162

163-
List<String> cellsnp = new ArrayList<>();
164-
cellsnp.add("cellsnp-lite");
165-
cellsnp.add("-s");
166-
cellsnp.add(bam.getPath());
167-
cellsnp.add("-b");
168-
cellsnp.add(barcodes.getPath());
169-
cellsnp.add("--genotype");
163+
Integer maxThreads = SequencePipelineService.get().getMaxThreads(ctx.getLogger());
164+
ReferenceGenome genome = ctx.getSequenceSupport().getCachedGenome(inputFiles.get(0).getLibrary_id());
170165

171166
File cellsnpDir = new File(ctx.getWorkingDirectory(), "cellsnp");
172-
if (cellsnpDir.exists())
167+
File cellsnpVcf = new File(cellsnpDir, "cellSNP.base.vcf.gz");
168+
File cellsnpVcfIdx = new File(cellsnpVcf.getPath() + ".tbi");
169+
if (cellsnpVcfIdx.exists())
173170
{
174-
try
171+
ctx.getLogger().info("cellsnp has already run, resuming");
172+
}
173+
else
174+
{
175+
List<String> cellsnp = new ArrayList<>();
176+
cellsnp.add("cellsnp-lite");
177+
cellsnp.add("-s");
178+
cellsnp.add(bam.getPath());
179+
cellsnp.add("-b");
180+
cellsnp.add(barcodes.getPath());
181+
cellsnp.add("--genotype");
182+
183+
if (cellsnpDir.exists())
175184
{
176-
FileUtils.deleteDirectory(cellsnpDir);
185+
try
186+
{
187+
FileUtils.deleteDirectory(cellsnpDir);
188+
}
189+
catch (IOException e)
190+
{
191+
throw new PipelineJobException(e);
192+
}
177193
}
178-
catch (IOException e)
194+
195+
cellsnp.add("-O");
196+
cellsnp.add(cellsnpDir.getPath());
197+
198+
if (maxThreads != null)
179199
{
180-
throw new PipelineJobException(e);
200+
cellsnp.add("-p");
201+
cellsnp.add(maxThreads.toString());
181202
}
182-
}
183203

184-
cellsnp.add("-O");
185-
cellsnp.add(cellsnpDir.getPath());
204+
cellsnp.add("--minMAF");
205+
cellsnp.add("0.1");
186206

187-
Integer maxThreads = SequencePipelineService.get().getMaxThreads(ctx.getLogger());
188-
if (maxThreads != null)
189-
{
190-
cellsnp.add("-p");
191-
cellsnp.add(maxThreads.toString());
192-
}
207+
cellsnp.add("--minCOUNT");
208+
cellsnp.add("100");
193209

194-
cellsnp.add("--minMAF");
195-
cellsnp.add("0.1");
210+
String maxDepth = StringUtils.trimToNull(ctx.getParams().optString("maxDepth"));
211+
if (maxDepth != null)
212+
{
213+
cellsnp.add("--maxDEPTH");
214+
cellsnp.add(maxDepth);
215+
}
196216

197-
cellsnp.add("--minCOUNT");
198-
cellsnp.add("100");
217+
cellsnp.add("--gzip");
199218

200-
String maxDepth = StringUtils.trimToNull(ctx.getParams().optString("maxDepth"));
201-
if (maxDepth != null)
202-
{
203-
cellsnp.add("--maxDEPTH");
204-
cellsnp.add(maxDepth);
205-
}
219+
cellsnp.add("--refseq");
220+
cellsnp.add(genome.getWorkingFastaFile().getPath());
206221

207-
cellsnp.add("--gzip");
222+
int vcfFile = ctx.getParams().optInt(REF_VCF, -1);
223+
if (vcfFile > -1)
224+
{
225+
File vcf = ctx.getSequenceSupport().getCachedData(vcfFile);
226+
if (vcf == null || !vcf.exists())
227+
{
228+
throw new PipelineJobException("Unable to find file with ID: " + vcfFile);
229+
}
208230

209-
ReferenceGenome genome = ctx.getSequenceSupport().getCachedGenome(inputFiles.get(0).getLibrary_id());
231+
cellsnp.add("-R");
232+
cellsnp.add(vcf.getPath());
233+
}
234+
else
235+
{
236+
String contigs = ctx.getParams().optString("contigs", "");
237+
if (!StringUtils.isEmpty(contigs))
238+
{
239+
cellsnp.add("--chrom");
240+
cellsnp.add(contigs);
241+
}
242+
}
210243

211-
cellsnp.add("--refseq");
212-
cellsnp.add(genome.getWorkingFastaFile().getPath());
244+
new SimpleScriptWrapper(ctx.getLogger()).execute(cellsnp);
213245

214-
int vcfFile = ctx.getParams().optInt(REF_VCF, -1);
215-
if (vcfFile > -1)
216-
{
217-
File vcf = ctx.getSequenceSupport().getCachedData(vcfFile);
218-
if (vcf == null || ! vcf.exists())
246+
try
219247
{
220-
throw new PipelineJobException("Unable to find file with ID: " + vcfFile);
221-
}
248+
SequenceAnalysisService.get().ensureVcfIndex(cellsnpVcf, ctx.getLogger());
222249

223-
cellsnp.add("-R");
224-
cellsnp.add(vcf.getPath());
225-
}
226-
else
227-
{
228-
String contigs = ctx.getParams().optString("contigs", "");
229-
if (!StringUtils.isEmpty(contigs))
250+
File cellsVcf = new File(cellsnpDir, "cellSNP.cells.vcf.gz");
251+
SequenceAnalysisService.get().ensureVcfIndex(cellsVcf, ctx.getLogger());
252+
}
253+
catch (IOException e)
230254
{
231-
cellsnp.add("--chrom");
232-
cellsnp.add(contigs);
255+
throw new PipelineJobException(e);
233256
}
234257
}
235258

236-
new SimpleScriptWrapper(ctx.getLogger()).execute(cellsnp);
237-
238259
List<String> vireo = new ArrayList<>();
239260
vireo.add("vireo");
240261
vireo.add("-c");

0 commit comments

Comments
 (0)