|
21 | 21 | import org.labkey.api.sequenceanalysis.run.SimpleScriptWrapper; |
22 | 22 | import org.labkey.api.util.FileType; |
23 | 23 | import org.labkey.sequenceanalysis.SequenceAnalysisModule; |
| 24 | +import org.labkey.sequenceanalysis.analysis.GenotypeGVCFHandler; |
24 | 25 | import org.labkey.sequenceanalysis.pipeline.ProcessVariantsHandler; |
25 | 26 | import org.labkey.sequenceanalysis.pipeline.VariantProcessingJob; |
26 | 27 | import org.labkey.sequenceanalysis.run.util.AbstractGenomicsDBImportHandler; |
|
34 | 35 | import java.util.List; |
35 | 36 | import java.util.stream.Collectors; |
36 | 37 |
|
37 | | -public class PbsvJointCallingHandler extends AbstractParameterizedOutputHandler<SequenceOutputHandler.SequenceOutputProcessor> implements SequenceOutputHandler.TracksVCF, VariantProcessingStep.SupportsScatterGather |
| 38 | +public class PbsvJointCallingHandler extends AbstractParameterizedOutputHandler<SequenceOutputHandler.SequenceOutputProcessor> implements SequenceOutputHandler.TracksVCF, VariantProcessingStep.SupportsScatterGather, VariantProcessingStep.MayRequirePrepareTask |
38 | 39 | { |
39 | 40 | private static final FileType FILE_TYPE = new FileType(".svsig.gz"); |
40 | 41 | private static final String OUTPUT_CATEGORY = "PBSV VCF"; |
@@ -93,7 +94,7 @@ public void processFilesOnWebserver(PipelineJob job, SequenceAnalysisJobSupport |
93 | 94 | public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext ctx) throws UnsupportedOperationException, PipelineJobException |
94 | 95 | { |
95 | 96 | List<File> inputs = inputFiles.stream().map(SequenceOutputFile::getFile).collect(Collectors.toList()); |
96 | | - if (ctx.getParams().optBoolean("doCopyLocal", false)) |
| 97 | + if (doCopyLocal(ctx.getParams())) |
97 | 98 | { |
98 | 99 | ctx.getLogger().info("Copying inputs locally"); |
99 | 100 | try |
@@ -162,14 +163,15 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c |
162 | 163 | { |
163 | 164 | File unzipVcfOut = outputs.get(0); |
164 | 165 | vcfOutGz = SequenceAnalysisService.get().bgzipFile(unzipVcfOut, ctx.getLogger()); |
| 166 | + if (unzipVcfOut.exists()) |
| 167 | + { |
| 168 | + throw new PipelineJobException("Unzipped VCF should not exist: " + vcfOutGz.getPath()); |
| 169 | + } |
165 | 170 | } |
166 | 171 | else |
167 | 172 | { |
| 173 | + outputs.forEach(f -> ctx.getFileManager().addIntermediateFile(f)); |
168 | 174 | vcfOutGz = SequenceUtil.combineVcfs(outputs, genome, new File(ctx.getOutputDir(), outputBaseName), ctx.getLogger(), true, null, false); |
169 | | - if (vcfOutGz.exists()) |
170 | | - { |
171 | | - throw new PipelineJobException("Unzipped VCF should not exist: " + vcfOutGz.getPath()); |
172 | | - } |
173 | 175 | } |
174 | 176 |
|
175 | 177 | try |
@@ -258,4 +260,28 @@ private static VariantProcessingJob getVariantPipelineJob(PipelineJob job) |
258 | 260 | { |
259 | 261 | return job instanceof VariantProcessingJob ? (VariantProcessingJob)job : null; |
260 | 262 | } |
| 263 | + |
| 264 | + @Override |
| 265 | + public boolean isRequired(PipelineJob job) |
| 266 | + { |
| 267 | + if (job instanceof VariantProcessingJob) |
| 268 | + { |
| 269 | + VariantProcessingJob vpj = (VariantProcessingJob)job; |
| 270 | + |
| 271 | + return doCopyLocal(vpj.getParameterJson()); |
| 272 | + } |
| 273 | + |
| 274 | + return false; |
| 275 | + } |
| 276 | + |
| 277 | + private boolean doCopyLocal(JSONObject params) |
| 278 | + { |
| 279 | + return params.optBoolean("doCopyLocal", false); |
| 280 | + } |
| 281 | + |
| 282 | + @Override |
| 283 | + public void doWork(List<SequenceOutputFile> inputFiles, JobContext ctx) throws PipelineJobException |
| 284 | + { |
| 285 | + GenotypeGVCFHandler.doCopyGvcfLocally(inputFiles, ctx); |
| 286 | + } |
261 | 287 | } |
0 commit comments