forked from BimberLab/DiscvrLabKeyModules
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLiftoverBcfToolsWrapper.java
More file actions
94 lines (75 loc) · 2.51 KB
/
LiftoverBcfToolsWrapper.java
File metadata and controls
94 lines (75 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package org.labkey.api.sequenceanalysis.run;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.pipeline.PipelineJobException;
import org.labkey.api.sequenceanalysis.SequenceAnalysisService;
import org.labkey.api.sequenceanalysis.pipeline.SequencePipelineService;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Created by bimber on 3/24/2016.
*/
public class LiftoverBcfToolsWrapper extends PicardWrapper
{
public LiftoverBcfToolsWrapper(@Nullable Logger logger)
{
super(logger);
}
public void doLiftover(File inputVcf, File chainFile, File sourceGenomeFasta, File targetGenomeFasta, @Nullable File rejectVcf, File outputVcf) throws PipelineJobException
{
getLogger().info("Liftover VCF (bcftools): " + inputVcf.getPath());
List<String> params = new ArrayList<>();
params.add(SequencePipelineService.get().getExeForPackage("BCFTOOLS", "bcftools").getPath());
params.add("+liftover");
params.add("--no-version");
params.add("-Oz");
Integer threads = SequencePipelineService.get().getMaxThreads(getLogger());
if (threads != null)
{
params.add("--threads");
params.add(threads.toString());
}
params.add("-o");
params.add(outputVcf.getPath());
params.add(inputVcf.getPath());
params.add("--");
params.add("-s");
params.add(sourceGenomeFasta.getPath());
params.add("-f");
params.add(targetGenomeFasta.getPath());
params.add("-c");
params.add(chainFile.getPath());
params.add("--write-src");
params.add("--fix-tags");
if (rejectVcf != null)
{
params.add("--reject");
params.add(rejectVcf.getPath());
params.add("--reject-type");
params.add("z");
}
execute(params);
if (!outputVcf.exists())
{
throw new PipelineJobException("Output file could not be found: " + outputVcf.getPath());
}
if (rejectVcf != null && rejectVcf.exists())
{
try
{
SequenceAnalysisService.get().ensureVcfIndex(rejectVcf, getLogger());
}
catch (IOException e)
{
throw new PipelineJobException(e);
}
}
}
@Override
protected String getToolName()
{
return "LiftoverVcf";
}
}