Skip to content

Commit 6258adb

Browse files
committed
Update SimpleLabKeyCombo to allow setting initial value
1 parent 07853d9 commit 6258adb

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ public Provider()
6767
put("checked", true);
6868
}}, true),
6969
ToolParameterDescriptor.create("splitByApplication", "Split by Application", "If checked, one iteration of PCA will be performed for each application (defined by the readset).", "checkbox", null, false),
70+
ToolParameterDescriptor.create("allowableApplications", "Allowable Applications", "If Split By Application is used, then it will search readsets to find those where the VCF sample matches the readset name. This is an option extra filter that can be added, to limit to search to a specific set of applications.", "ldk-simplelabkeycombo", new JSONObject(){{
71+
put("schemaName", "sequenceanalysis");
72+
put("queryName", "sequence_applications");
73+
put("multiSelect", true);
74+
put("joinReturnValue", true);
75+
put("displayField", "application");
76+
put("valueField", "application");
77+
put("sortField", "application");
78+
}}, null),
7079
ToolParameterDescriptor.create(SelectSamplesStep.SAMPLE_INCLUDE, "Sample(s) Include", "Only the following samples will be included in the analysis.", "sequenceanalysis-trimmingtextarea", null, null),
7180
ToolParameterDescriptor.create(SelectSamplesStep.SAMPLE_EXCLUDE, "Samples(s) To Exclude", "The following samples will be excluded from the analysis.", "sequenceanalysis-trimmingtextarea", null, null)
7281
), Arrays.asList("sequenceanalysis/field/TrimmingTextArea.js"), "https://zzz.bwh.harvard.edu/plink/");
@@ -195,6 +204,13 @@ private void runBatch(File inputVCF, File outputDirectory, VariantProcessingStep
195204
public void init(PipelineJob job, SequenceAnalysisJobSupport support, List<SequenceOutputFile> inputFiles) throws PipelineJobException
196205
{
197206
boolean splitByApplication = getProvider().getParameterByName("splitByApplication").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, true);
207+
List<String> allowableApplications = null;
208+
String allowableApplicationsRaw = StringUtils.trimToNull(getProvider().getParameterByName("splitByApplication").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx()));
209+
if (allowableApplicationsRaw != null)
210+
{
211+
allowableApplications = Arrays.asList(allowableApplicationsRaw.split(";"));
212+
}
213+
198214
if (splitByApplication)
199215
{
200216
try (PrintWriter writer = PrintWriters.getPrintWriter(getSampleMapFile()))
@@ -215,7 +231,13 @@ public void init(PipelineJob job, SequenceAnalysisJobSupport support, List<Seque
215231
{
216232
// Find readset:
217233
Container targetContainer = getPipelineCtx().getJob().getContainer().isWorkbook() ? getPipelineCtx().getJob().getContainer().getParent() : getPipelineCtx().getJob().getContainer();
218-
Set<String> applications = new HashSet<>(new TableSelector(QueryService.get().getUserSchema(getPipelineCtx().getJob().getUser(), targetContainer, SequenceAnalysisSchema.SCHEMA_NAME).getTable(SequenceAnalysisSchema.TABLE_READSETS), PageFlowUtil.set("application"), new SimpleFilter(FieldKey.fromString("name"), sample).addCondition(FieldKey.fromString("status"), null, CompareType.ISBLANK), null).getArrayList(String.class));
234+
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("name"), sample).addCondition(FieldKey.fromString("status"), null, CompareType.ISBLANK);
235+
if (allowableApplications != null)
236+
{
237+
filter.addCondition(FieldKey.fromString("application"), allowableApplications, CompareType.IN);
238+
}
239+
240+
Set<String> applications = new HashSet<>(new TableSelector(QueryService.get().getUserSchema(getPipelineCtx().getJob().getUser(), targetContainer, SequenceAnalysisSchema.SCHEMA_NAME).getTable(SequenceAnalysisSchema.TABLE_READSETS), PageFlowUtil.set("application"), filter, null).getArrayList(String.class));
219241
if (applications.size() == 1)
220242
{
221243
writer.println(sample + "\t" + applications.iterator().next());

0 commit comments

Comments
 (0)