Skip to content

Commit 0e084a8

Browse files
authored
Merge pull request #338 from LabKey/fb_merge_24.11_to_develop
Merge discvr-24.11 to develop
2 parents a271a04 + b4972a2 commit 0e084a8

File tree

15 files changed

+293
-192
lines changed

15 files changed

+293
-192
lines changed

SequenceAnalysis/api-src/org/labkey/api/sequenceanalysis/pipeline/BcftoolsRunner.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
import org.apache.logging.log4j.Logger;
44
import org.jetbrains.annotations.Nullable;
5+
import org.labkey.api.pipeline.PipelineJobException;
6+
import org.labkey.api.pipeline.PipelineJobService;
57
import org.labkey.api.sequenceanalysis.run.AbstractCommandWrapper;
68

79
import java.io.File;
10+
import java.util.ArrayList;
11+
import java.util.List;
812

913
/**
1014
* User: bimber
@@ -22,4 +26,32 @@ public static File getBcfToolsPath()
2226
{
2327
return SequencePipelineService.get().getExeForPackage("BCFTOOLSPATH", "bcftools");
2428
}
29+
30+
public static boolean isBcftoolsFound()
31+
{
32+
return BcftoolsRunner.resolveFileInPath("bcftools", null, false) != null;
33+
}
34+
35+
public void doIndex(File vcf) throws PipelineJobException
36+
{
37+
List<String> args = new ArrayList<>();
38+
args.add(getBcfToolsPath().getAbsolutePath());
39+
args.add("index");
40+
args.add("-t");
41+
args.add("-f");
42+
43+
if (!PipelineJobService.get().isWebServer())
44+
{
45+
Integer threads = SequencePipelineService.get().getMaxThreads(getLogger());
46+
if (threads != null)
47+
{
48+
args.add("--threads");
49+
args.add(String.valueOf(threads));
50+
}
51+
}
52+
53+
args.add(vcf.getAbsolutePath());
54+
55+
execute(args);
56+
}
2557
}

SequenceAnalysis/src/org/labkey/sequenceanalysis/SequenceAnalysisServiceImpl.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.labkey.api.sequenceanalysis.SequenceAnalysisService;
3737
import org.labkey.api.sequenceanalysis.SequenceDataProvider;
3838
import org.labkey.api.sequenceanalysis.model.Readset;
39+
import org.labkey.api.sequenceanalysis.pipeline.BcftoolsRunner;
3940
import org.labkey.api.sequenceanalysis.pipeline.ReferenceGenome;
4041
import org.labkey.api.sequenceanalysis.pipeline.SamtoolsCramConverter;
4142
import org.labkey.api.sequenceanalysis.pipeline.SequenceOutputHandler;
@@ -267,8 +268,16 @@ public File ensureVcfIndex(File vcf, Logger log, boolean forceRecreate) throws I
267268
//note: there is a bug in htsjdk's index creation with gz inputs
268269
if (gz.isType(vcf) && !SystemUtils.IS_OS_WINDOWS)
269270
{
270-
TabixRunner r = new TabixRunner(log);
271-
r.execute(vcf);
271+
// preferentially use bcftools since it supports multithreading:
272+
if (BcftoolsRunner.isBcftoolsFound())
273+
{
274+
new BcftoolsRunner(log).doIndex(vcf);
275+
}
276+
else
277+
{
278+
new TabixRunner(log).execute(vcf);
279+
}
280+
272281
if (!expectedIdx.exists())
273282
{
274283
throw new PipelineJobException("Expected index was not created: " + expectedIdx.getPath());

SequenceAnalysis/src/org/labkey/sequenceanalysis/analysis/LiftoverHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
178178
boolean dropGenotypes = params.optBoolean("dropGenotypes", false);
179179
boolean useBcfTools = params.optBoolean("useBcfTools", false);
180180
boolean doNotRetainUnmapped = params.optBoolean("doNotRetainUnmapped", false);
181-
if (doNotRetainUnmapped && !useBcfTools)
181+
if (!doNotRetainUnmapped && !useBcfTools)
182182
{
183183
ctx.getLogger().debug("Picard LiftoverVcf requires an output file for rejected sites, so setting doNotRetainUnmapped to true");
184184
doNotRetainUnmapped = true;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package org.labkey.sequenceanalysis.run.variant;
2+
3+
import org.apache.logging.log4j.Logger;
4+
import org.labkey.api.pipeline.PipelineJobException;
5+
import org.labkey.api.sequenceanalysis.SequenceAnalysisService;
6+
import org.labkey.api.sequenceanalysis.run.AbstractGatk4Wrapper;
7+
import org.labkey.api.writer.PrintWriters;
8+
9+
import java.io.File;
10+
import java.io.IOException;
11+
import java.io.PrintWriter;
12+
import java.util.ArrayList;
13+
import java.util.List;
14+
15+
public class GatherVcfsCloudWrapper extends AbstractGatk4Wrapper
16+
{
17+
public GatherVcfsCloudWrapper(Logger log)
18+
{
19+
super(log);
20+
}
21+
22+
public void gatherVcfs(File output, List<File> inputVcfs) throws PipelineJobException
23+
{
24+
List<String> args = new ArrayList<>(getBaseArgs("GatherVcfsCloud"));
25+
args.add("-O");
26+
args.add(output.getPath());
27+
28+
File argFile = new File(output.getParentFile(), "inputs.list");
29+
try (PrintWriter writer = PrintWriters.getPrintWriter(argFile))
30+
{
31+
inputVcfs.forEach(f -> writer.println(f.getPath()));
32+
}
33+
catch (IOException e)
34+
{
35+
throw new PipelineJobException(e);
36+
}
37+
38+
args.add("-I");
39+
args.add(argFile.getPath());
40+
41+
execute(args);
42+
43+
argFile.delete();
44+
45+
try
46+
{
47+
SequenceAnalysisService.get().ensureVcfIndex(output, getLogger());
48+
}
49+
catch (IOException e)
50+
{
51+
throw new PipelineJobException(e);
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)