2525import org .labkey .sequenceanalysis .pipeline .ProcessVariantsHandler ;
2626import org .labkey .sequenceanalysis .pipeline .VariantProcessingJob ;
2727import org .labkey .sequenceanalysis .run .util .AbstractGenomicsDBImportHandler ;
28+ import org .labkey .sequenceanalysis .run .util .GenotypeGVCFsWrapper ;
2829import org .labkey .sequenceanalysis .util .SequenceUtil ;
2930
3031import java .io .File ;
3132import java .io .IOException ;
3233import java .util .ArrayList ;
3334import java .util .Arrays ;
35+ import java .util .HashSet ;
3436import java .util .LinkedHashSet ;
3537import java .util .List ;
38+ import java .util .Set ;
3639import java .util .stream .Collectors ;
3740
3841public class PbsvJointCallingHandler extends AbstractParameterizedOutputHandler <SequenceOutputHandler .SequenceOutputProcessor > implements SequenceOutputHandler .TracksVCF , VariantProcessingStep .SupportsScatterGather , VariantProcessingStep .MayRequirePrepareTask
@@ -94,37 +97,16 @@ public void processFilesOnWebserver(PipelineJob job, SequenceAnalysisJobSupport
9497 public void processFilesRemote (List <SequenceOutputFile > inputFiles , JobContext ctx ) throws UnsupportedOperationException , PipelineJobException
9598 {
9699 List <File > inputs = inputFiles .stream ().map (SequenceOutputFile ::getFile ).collect (Collectors .toList ());
100+ Set <File > toDelete = new HashSet <>();
101+ List <File > filesToProcess = new ArrayList <>();
97102 if (doCopyLocal (ctx .getParams ()))
98103 {
99- ctx .getLogger ().info ("Copying inputs locally" );
100- try
101- {
102- List <File > copiedInputs = new ArrayList <>();
103- for (File f : inputs )
104- {
105- File copied = new File (ctx .getWorkingDirectory (), f .getName ());
106- if (copiedInputs .contains (copied ))
107- {
108- throw new PipelineJobException ("Duplicate input filenames, cannot use with copyLocally option: " + copied .getName ());
109- }
110-
111- if (copied .exists ())
112- {
113- copied .delete ();
114- }
115-
116- FileUtils .copyFile (f , copied );
117- copiedInputs .add (copied );
118-
119- ctx .getFileManager ().addIntermediateFile (copied );
120- }
121-
122- inputs = copiedInputs ;
123- }
124- catch (IOException e )
125- {
126- throw new PipelineJobException (e );
127- }
104+ ctx .getLogger ().info ("making local copies of svsig files" );
105+ filesToProcess .addAll (GenotypeGVCFsWrapper .copyVcfsLocally (ctx , inputs , toDelete , false ));
106+ }
107+ else
108+ {
109+ filesToProcess .addAll (inputs );
128110 }
129111
130112 ReferenceGenome genome = ctx .getSequenceSupport ().getCachedGenomes ().iterator ().next ();
@@ -150,12 +132,12 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
150132 throw new PipelineJobException ("Expected all intervals to start on the first base: " + i .toString ());
151133 }
152134
153- outputs .add (runPbsvCall (ctx , inputs , genome , outputBaseName + (getVariantPipelineJob (ctx .getJob ()).getIntervalsForTask ().size () == 1 ? "" : "." + i .getContig ()), i .getContig ()));
135+ outputs .add (runPbsvCall (ctx , filesToProcess , genome , outputBaseName + (getVariantPipelineJob (ctx .getJob ()).getIntervalsForTask ().size () == 1 ? "" : "." + i .getContig ()), i .getContig ()));
154136 }
155137 }
156138 else
157139 {
158- outputs .add (runPbsvCall (ctx , inputs , genome , outputBaseName , null ));
140+ outputs .add (runPbsvCall (ctx , filesToProcess , genome , outputBaseName , null ));
159141 }
160142
161143 File vcfOutGz ;
0 commit comments