4444import java .io .File ;
4545import java .io .IOException ;
4646import java .text .NumberFormat ;
47+ import java .util .ArrayList ;
4748import java .util .Arrays ;
4849import java .util .Date ;
4950import java .util .LinkedHashSet ;
@@ -175,6 +176,8 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
175176 PipelineJob job = ctx .getJob ();
176177 JSONObject params = ctx .getParams ();
177178
179+ List <Interval > intervals = ProcessVariantsHandler .getIntervals (ctx );
180+
178181 boolean dropGenotypes = params .optBoolean ("dropGenotypes" , false );
179182 boolean useBcfTools = params .optBoolean ("useBcfTools" , false );
180183 boolean doNotRetainUnmapped = params .optBoolean ("doNotRetainUnmapped" , false );
@@ -233,7 +236,7 @@ else if (_vcfFileType.isType(f.getFile()))
233236 {
234237 ReferenceGenome targetGenome = ctx .getSequenceSupport ().getCachedGenome (targetGenomeId );
235238 ReferenceGenome sourceGenome = ctx .getSequenceSupport ().getCachedGenome (f .getLibrary_id ());
236- liftOverVcf (ctx , targetGenome , sourceGenome , chainFile , f .getFile (), lifted , unmappedOutput , job , pct , dropGenotypes , useBcfTools );
239+ liftOverVcf (ctx , targetGenome , sourceGenome , chainFile , f .getFile (), lifted , unmappedOutput , job , pct , dropGenotypes , useBcfTools , intervals );
237240 }
238241 }
239242 catch (Exception e )
@@ -313,7 +316,7 @@ else if (!SequenceUtil.hasLineCount(unmappedOutput))
313316 }
314317 }
315318
316- public void liftOverVcf (JobContext ctx , ReferenceGenome targetGenome , ReferenceGenome sourceGenome , File chain , File input , File output , @ Nullable File unmappedOutput , PipelineJob job , double pct , boolean dropGenotypes , boolean useBcfTools ) throws IOException , PipelineJobException
319+ public void liftOverVcf (JobContext ctx , ReferenceGenome targetGenome , ReferenceGenome sourceGenome , File chain , File input , File output , @ Nullable File unmappedOutput , PipelineJob job , double pct , boolean dropGenotypes , boolean useBcfTools , @ Nullable List < Interval > intervals ) throws IOException , PipelineJobException
317320 {
318321 File currentVCF = input ;
319322 if (dropGenotypes )
@@ -326,8 +329,20 @@ public void liftOverVcf(JobContext ctx, ReferenceGenome targetGenome, ReferenceG
326329 }
327330 else
328331 {
332+ List <String > extraArgs = new ArrayList <>();
333+ extraArgs .add ("--sites-only-vcf-output" );
334+ if (intervals != null )
335+ {
336+ intervals .forEach (interval -> {
337+ extraArgs .add ("-L" );
338+ extraArgs .add (interval .getContig () + ":" + interval .getStart () + "-" + interval .getEnd ());
339+ });
340+
341+ extraArgs .add ("--ignore-variants-starting-outside-interval" );
342+ }
343+
329344 SelectVariantsWrapper wrapper = new SelectVariantsWrapper (job .getLogger ());
330- wrapper .execute (sourceGenome .getWorkingFastaFile (), currentVCF , outputFile , List . of ( "--sites-only-vcf-output" ) );
345+ wrapper .execute (sourceGenome .getWorkingFastaFile (), currentVCF , outputFile , extraArgs );
331346 }
332347 currentVCF = outputFile ;
333348
0 commit comments