2828import org .labkey .api .sequenceanalysis .pipeline .ReferenceGenome ;
2929import org .labkey .api .sequenceanalysis .pipeline .SequenceAnalysisJobSupport ;
3030import org .labkey .api .sequenceanalysis .pipeline .SequenceOutputHandler ;
31+ import org .labkey .api .sequenceanalysis .pipeline .VariantProcessingStep ;
3132import org .labkey .api .sequenceanalysis .run .SelectVariantsWrapper ;
3233import org .labkey .api .util .FileType ;
3334import org .labkey .api .util .FileUtil ;
3435import org .labkey .api .view .ActionURL ;
3536import org .labkey .api .writer .PrintWriters ;
3637import org .labkey .sequenceanalysis .SequenceAnalysisModule ;
3738import org .labkey .sequenceanalysis .pipeline .ProcessVariantsHandler ;
39+ import org .labkey .sequenceanalysis .run .util .LiftoverBcfToolsWrapper ;
3840import org .labkey .sequenceanalysis .run .util .LiftoverVcfWrapper ;
3941import org .labkey .sequenceanalysis .util .SequenceUtil ;
4042
4951/**
5052 * Created by bimber on 8/26/2014.
5153 */
52- public class LiftoverHandler implements SequenceOutputHandler <SequenceOutputHandler .SequenceOutputProcessor >
54+ public class LiftoverHandler implements SequenceOutputHandler <SequenceOutputHandler .SequenceOutputProcessor >, VariantProcessingStep . SupportsScatterGather
5355{
5456 private final FileType _bedFileType = new FileType (".bed" , false );
5557 //private FileType _gffFileType = new FileType("gff", false);
@@ -60,6 +62,12 @@ public LiftoverHandler()
6062
6163 }
6264
65+ @ Override
66+ public boolean doSortAfterMerge ()
67+ {
68+ return true ;
69+ }
70+
6371 @ Override
6472 public String getName ()
6573 {
@@ -167,8 +175,9 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
167175 JSONObject params = ctx .getParams ();
168176
169177 boolean dropGenotypes = params .optBoolean ("dropGenotypes" , false );
178+ boolean useBcfTools = params .optBoolean ("useBcfTools" , false );
170179
171- Integer chainFileId = params .getInt ("chainFileId" );
180+ int chainFileId = params .getInt ("chainFileId" );
172181 File chainFile = ctx .getSequenceSupport ().getCachedData (chainFileId );
173182 int targetGenomeId = params .getInt ("targetGenomeId" );
174183
@@ -217,7 +226,7 @@ else if (_vcfFileType.isType(f.getFile()))
217226 {
218227 ReferenceGenome targetGenome = ctx .getSequenceSupport ().getCachedGenome (targetGenomeId );
219228 ReferenceGenome sourceGenome = ctx .getSequenceSupport ().getCachedGenome (f .getLibrary_id ());
220- liftOverVcf (ctx , targetGenome , sourceGenome , chainFile , f .getFile (), lifted , unmappedOutput , job , pct , dropGenotypes );
229+ liftOverVcf (ctx , targetGenome , sourceGenome , chainFile , f .getFile (), lifted , unmappedOutput , job , pct , dropGenotypes , useBcfTools );
221230 }
222231 }
223232 catch (Exception e )
@@ -293,7 +302,7 @@ else if (!SequenceUtil.hasLineCount(unmappedOutput))
293302 }
294303 }
295304
296- public void liftOverVcf (JobContext ctx , ReferenceGenome targetGenome , ReferenceGenome sourceGenome , File chain , File input , File output , @ Nullable File unmappedOutput , PipelineJob job , double pct , boolean dropGenotypes ) throws IOException , PipelineJobException
305+ 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
297306 {
298307 File currentVCF = input ;
299308 if (dropGenotypes )
@@ -315,8 +324,16 @@ public void liftOverVcf(JobContext ctx, ReferenceGenome targetGenome, ReferenceG
315324 ctx .getFileManager ().addIntermediateFile (new File (outputFile .getPath () + ".tbi" ));
316325 }
317326
318- LiftoverVcfWrapper wrapper = new LiftoverVcfWrapper (job .getLogger ());
319- wrapper .doLiftover (currentVCF , chain , targetGenome .getWorkingFastaFile (), unmappedOutput , output , pct );
327+ if (useBcfTools )
328+ {
329+ LiftoverBcfToolsWrapper wrapper = new LiftoverBcfToolsWrapper (job .getLogger ());
330+ wrapper .doLiftover (currentVCF , chain , sourceGenome .getWorkingFastaFile (), targetGenome .getWorkingFastaFile (), unmappedOutput , output );
331+ }
332+ else
333+ {
334+ LiftoverVcfWrapper wrapper = new LiftoverVcfWrapper (job .getLogger ());
335+ wrapper .doLiftover (currentVCF , chain , targetGenome .getWorkingFastaFile (), unmappedOutput , output , pct );
336+ }
320337
321338 Long mapped = null ;
322339 if (output .exists ())
0 commit comments