Skip to content

Commit f2e2735

Browse files
committed
Allow PlinkPcaStep to limit to specific sample sets
1 parent df2662c commit f2e2735

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public Provider()
8181
put("sortField", "application");
8282
}}, null),
8383
ToolParameterDescriptor.create("allowMissingSamples", "Allow Missing Samples", "When using split by application, this controls whether or not the job should fail if a matching readset cannot be found for specific samples.", "checkbox", null, false),
84+
ToolParameterDescriptor.create("fileSets", "File Set(s) For Readset Query", "If Split By Application is used, the system needs to query each sample name in the VCF and find the corresponding readset. If this is provided, this query will be limited to redsets where a gVCF exists and is tagged as one of these file sets", "sequenceanalysis-trimmingtextarea", null, null),
8485
ToolParameterDescriptor.create(SelectSamplesStep.SAMPLE_INCLUDE, "Sample(s) Include", "Only the following samples will be included in the analysis.", "sequenceanalysis-trimmingtextarea", null, null),
8586
ToolParameterDescriptor.create(SelectSamplesStep.SAMPLE_EXCLUDE, "Samples(s) To Exclude", "The following samples will be excluded from the analysis.", "sequenceanalysis-trimmingtextarea", null, null)
8687
), List.of("sequenceanalysis/field/TrimmingTextArea.js"), "https://zzz.bwh.harvard.edu/plink/");
@@ -249,16 +250,31 @@ public void init(PipelineJob job, SequenceAnalysisJobSupport support, List<Seque
249250
throw new PipelineJobException("Expected VCF to have samples: " + so.getFile().getPath());
250251
}
251252

253+
List<Integer> allowableReadsets = null;
254+
Container targetContainer = getPipelineCtx().getJob().getContainer().isWorkbook() ? getPipelineCtx().getJob().getContainer().getParent() : getPipelineCtx().getJob().getContainer();
255+
String fileSetsText = StringUtils.trimToNull(getProvider().getParameterByName("fileSets").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), String.class));
256+
if (fileSetsText != null)
257+
{
258+
SimpleFilter fileSetFilter = new SimpleFilter(FieldKey.fromString("fileSets"), Arrays.asList(fileSetsText.split(";")), CompareType.CONTAINS_ONE_OF);
259+
fileSetFilter.addCondition(FieldKey.fromString("category"), "gVCF File");
260+
allowableReadsets = new TableSelector(QueryService.get().getUserSchema(getPipelineCtx().getJob().getUser(), targetContainer, SequenceAnalysisSchema.SCHEMA_NAME).getTable(SequenceAnalysisSchema.TABLE_OUTPUTFILES), PageFlowUtil.set("readset"), fileSetFilter, null).getArrayList(Integer.class);
261+
getPipelineCtx().getLogger().debug("Limiting to file sets: " + fileSetsText + ", found " + allowableReadsets.size() + " readsets");
262+
}
263+
252264
for (String sample : header.getSampleNamesInOrder())
253265
{
254266
// Find readset:
255-
Container targetContainer = getPipelineCtx().getJob().getContainer().isWorkbook() ? getPipelineCtx().getJob().getContainer().getParent() : getPipelineCtx().getJob().getContainer();
256267
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("name"), sample).addCondition(FieldKey.fromString("status"), null, CompareType.ISBLANK);
257268
if (allowableApplications != null)
258269
{
259270
filter.addCondition(FieldKey.fromString("application"), allowableApplications, CompareType.IN);
260271
}
261272

273+
if (allowableReadsets != null)
274+
{
275+
filter.addCondition(FieldKey.fromString("rowid"), allowableReadsets, CompareType.IN);
276+
}
277+
262278
Collection<Map<String, Object>> results = new TableSelector(QueryService.get().getUserSchema(getPipelineCtx().getJob().getUser(), targetContainer, SequenceAnalysisSchema.SCHEMA_NAME).getTable(SequenceAnalysisSchema.TABLE_READSETS), PageFlowUtil.set("application", "rowid"), filter, null).getMapCollection();
263279
if (results.size() == 1)
264280
{

0 commit comments

Comments
 (0)