Skip to content

Commit b9145db

Browse files
committed
Add ability to make local copy of VCF for VariantQC
1 parent d83f6b9 commit b9145db

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/variant/VariantQCStep.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.labkey.sequenceanalysis.run.variant;
22

33
import htsjdk.samtools.util.Interval;
4+
import org.apache.commons.io.FileUtils;
45
import org.json.JSONObject;
56
import org.labkey.api.pipeline.PipelineJobException;
67
import org.labkey.api.sequenceanalysis.pipeline.AbstractPipelineStep;
@@ -16,6 +17,7 @@
1617

1718
import javax.annotation.Nullable;
1819
import java.io.File;
20+
import java.io.IOException;
1921
import java.util.ArrayList;
2022
import java.util.Arrays;
2123
import java.util.List;
@@ -40,7 +42,10 @@ public Provider()
4042
ToolParameterDescriptor.create("writeJson", "Write Raw Data", "If selected, both an HTML report and a text file with the raw data will be created.", "checkbox", new JSONObject()
4143
{{
4244
put("checked", true);
43-
}}, true)
45+
}}, true),
46+
ToolParameterDescriptor.create("doCopyLocal", "Copy Input To Working Directory", "If selected, the input VCF will always be copied to the working directory, if it is not already present.", "checkbox", new JSONObject(){{
47+
put("checked", false);
48+
}}, false)
4449
), null, "https://bimberlab.github.io/DISCVRSeq/");
4550
}
4651

@@ -56,6 +61,39 @@ public Output processVariants(File inputVCF, File outputDirectory, ReferenceGeno
5661
{
5762
VariantProcessingStepOutputImpl output = new VariantProcessingStepOutputImpl();
5863

64+
boolean doCopyLocal = getProvider().getParameterByName("doCopyLocal").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), boolean.class, false);
65+
if (doCopyLocal)
66+
{
67+
File local = new File(outputDirectory, inputVCF.getName());
68+
File localIdx = new File(local.getPath() + ".tbi");
69+
if (!inputVCF.equals(local))
70+
{
71+
getPipelineCtx().getLogger().debug("Making local copy of VCF:");
72+
if (local.exists())
73+
{
74+
local.delete();
75+
}
76+
77+
if (localIdx.exists())
78+
{
79+
localIdx.delete();
80+
}
81+
82+
try
83+
{
84+
FileUtils.copyFile(inputVCF, local);
85+
FileUtils.copyFile(new File(inputVCF.getPath() + ".tbi"), localIdx);
86+
output.addIntermediateFile(local);
87+
output.addIntermediateFile(localIdx);
88+
inputVCF = local;
89+
}
90+
catch (IOException e)
91+
{
92+
throw new PipelineJobException(e);
93+
}
94+
}
95+
}
96+
5997
List<String> options = new ArrayList<>();
6098

6199
File pedFile = ProcessVariantsHandler.getPedigreeFile(getPipelineCtx().getSourceDirectory(true));

0 commit comments

Comments
 (0)