Skip to content

Commit 1670bcf

Browse files
committed
Add option for paragraph to remove BNDs
1 parent 66fb1d3 commit 1670bcf

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/alignment/ParagraphStep.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.labkey.api.sequenceanalysis.pipeline.SequencePipelineService;
1919
import org.labkey.api.sequenceanalysis.pipeline.ToolParameterDescriptor;
2020
import org.labkey.api.sequenceanalysis.run.DockerWrapper;
21+
import org.labkey.api.sequenceanalysis.run.SelectVariantsWrapper;
2122
import org.labkey.api.sequenceanalysis.run.SimpleScriptWrapper;
2223
import org.labkey.api.util.FileUtil;
2324
import org.labkey.api.writer.PrintWriters;
@@ -43,6 +44,9 @@ public ParagraphStep()
4344
{{
4445
put("allowBlank", false);
4546
}}, null),
47+
ToolParameterDescriptor.create("doBndSubset", "Remove BNDs", "If the reference VCF contains BNDs, selecting this option will cause the job to remove them prior to paragraph", "checkbox", new JSONObject(){{
48+
put("checked", true);
49+
}}, false),
4650
ToolParameterDescriptor.create("useOutputFileContainer", "Submit to Source File Workbook", "If checked, each job will be submitted to the same workbook as the input file, as opposed to submitting all jobs to the same workbook. This is primarily useful if submitting a large batch of files to process separately. This only applies if 'Run Separately' is selected.", "checkbox", new JSONObject(){{
4751
put("checked", true);
4852
}}, false)
@@ -106,6 +110,32 @@ else if (!svVcf.exists())
106110
throw new PipelineJobException("Missing file: " + svVcf.getPath());
107111
}
108112

113+
boolean doBndSubset = ctx.getParams().optBoolean("doBndSubset", false);
114+
if (doBndSubset)
115+
{
116+
File vcfNoBnd = new File(ctx.getOutputDir(), SequenceAnalysisService.get().getUnzippedBaseName(svVcf.getName()) + "nobnd.vcf.gz");
117+
File vcfNoBndIdx = new File(vcfNoBnd.getPath() + ".tbi");
118+
if (vcfNoBndIdx.exists())
119+
{
120+
ctx.getLogger().debug("Index exists, will no repeat BND subset");
121+
}
122+
else
123+
{
124+
SelectVariantsWrapper svw = new SelectVariantsWrapper(ctx.getLogger());
125+
List<String> selectArgs = new ArrayList<>();
126+
selectArgs.add("-select");
127+
selectArgs.add("SVTYPE != 'BND'");
128+
selectArgs.add("--exclude-filtered");
129+
selectArgs.add("--exclude-non-variants");
130+
131+
svw.execute(ctx.getSequenceSupport().getCachedGenome(inputFiles.get(0).getLibrary_id()).getWorkingFastaFile(), svVcf, vcfNoBnd, selectArgs);
132+
133+
ctx.getFileManager().addIntermediateFile(vcfNoBnd);
134+
ctx.getFileManager().addIntermediateFile(vcfNoBndIdx);
135+
svVcf = vcfNoBnd;
136+
}
137+
}
138+
109139
Integer threads = SequencePipelineService.get().getMaxThreads(ctx.getLogger());
110140
for (SequenceOutputFile so : inputFiles)
111141
{

0 commit comments

Comments
 (0)