Skip to content

Commit c04637e

Browse files
authored
Merge pull request #32 from BimberLab/fb_merge_discvr-20.11
Merge discvr-20.11 to discvr-21.3
2 parents 430c06a + 54b0358 commit c04637e

File tree

5 files changed

+68
-8
lines changed

5 files changed

+68
-8
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/pipeline/SequenceOutputHandlerFinalTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ public RecordedActionSet run() throws PipelineJobException
8787
//create analysisRecord
8888
AnalysisModelImpl am = new AnalysisModelImpl();
8989
am.setContainer(getJob().getContainerId());
90-
am.setDescription(getPipelineJob().getDescription());
90+
String description = getPipelineJob().getParameters().getOrDefault("jobDescription", null) != null ? getPipelineJob().getParameters().get("jobDescription") : getPipelineJob().getDescription();
91+
am.setDescription(description);
9192
am.setRunId(runId);
9293

9394

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

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

3+
import au.com.bytecode.opencsv.CSVWriter;
4+
import htsjdk.samtools.util.IOUtil;
35
import htsjdk.samtools.util.Interval;
6+
import org.apache.commons.lang3.StringUtils;
47
import org.apache.logging.log4j.Logger;
58
import org.json.JSONObject;
69
import org.labkey.api.pipeline.PipelineJobException;
@@ -18,6 +21,7 @@
1821

1922
import javax.annotation.Nullable;
2023
import java.io.File;
24+
import java.io.IOException;
2125
import java.util.ArrayList;
2226
import java.util.Arrays;
2327
import java.util.List;
@@ -36,8 +40,10 @@ public Provider()
3640
super("PlinkPcaStep", "Plink/PCA", "", "This will run plink to generate the data for MDS/PCA", Arrays.asList(
3741
ToolParameterDescriptor.createCommandLineParam(CommandLineParam.create("--not-chr"), "excludedContigs", "Excluded Contigs", "A comma separated list of contigs to exclude, such as X,Y,MT.", "textfield", new JSONObject(){{
3842

39-
}}, "X,Y,MT")
40-
), null, "https://zzz.bwh.harvard.edu/plink/");
43+
}}, "X,Y,MT"),
44+
ToolParameterDescriptor.create(SelectSamplesStep.SAMPLE_INCLUDE, "Sample(s) Include", "Only the following samples will be included in the analysis.", "sequenceanalysis-trimmingtextarea", null, null),
45+
ToolParameterDescriptor.create(SelectSamplesStep.SAMPLE_EXCLUDE, "Samples(s) To Exclude", "The following samples will be excluded from the analysis.", "sequenceanalysis-trimmingtextarea", null, null)
46+
), Arrays.asList("sequenceanalysis/field/TrimmingTextArea.js"), "https://zzz.bwh.harvard.edu/plink/");
4147
}
4248

4349
public PlinkPcaStep create(PipelineContext ctx)
@@ -46,6 +52,30 @@ public PlinkPcaStep create(PipelineContext ctx)
4652
}
4753
}
4854

55+
private void addSubjectSelectOptions(String text, List<String> args, String argName, File outputFile, VariantProcessingStepOutputImpl output) throws PipelineJobException
56+
{
57+
text = StringUtils.trimToNull(text);
58+
if (text != null)
59+
{
60+
String[] names = text.split(";");
61+
try (CSVWriter writer = new CSVWriter(IOUtil.openFileForBufferedUtf8Writing(outputFile), '\t', CSVWriter.NO_QUOTE_CHARACTER))
62+
{
63+
Arrays.stream(names).forEach(x -> {
64+
writer.writeNext(new String[]{x, x});
65+
});
66+
}
67+
catch (IOException e)
68+
{
69+
throw new PipelineJobException(e);
70+
}
71+
72+
args.add(argName);
73+
args.add(outputFile.getPath());
74+
75+
output.addIntermediateFile(outputFile);
76+
}
77+
}
78+
4979
@Override
5080
public Output processVariants(File inputVCF, File outputDirectory, ReferenceGenome genome, @Nullable List<Interval> intervals) throws PipelineJobException
5181
{
@@ -55,7 +85,13 @@ public Output processVariants(File inputVCF, File outputDirectory, ReferenceGeno
5585
args.add(getWrapper().getExe().getPath());
5686
args.add("--pca");
5787
args.add("--allow-extra-chr");
58-
args.add("--keep WGS.names");
88+
89+
String samplesToInclude = getProvider().getParameterByName(SelectSamplesStep.SAMPLE_INCLUDE).extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), String.class);
90+
addSubjectSelectOptions(samplesToInclude, args, "--keep", new File(outputDirectory, "samplesToKeep.txt"), output);
91+
92+
String samplesToExclude = getProvider().getParameterByName(SelectSamplesStep.SAMPLE_EXCLUDE).extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), String.class);
93+
addSubjectSelectOptions(samplesToExclude, args, "--exclude", new File(outputDirectory, "samplesToExclude.txt"), output);
94+
5995
args.add("--vcf");
6096
args.add(inputVCF.getPath());
6197

singlecell/api-src/org/labkey/api/singlecell/pipeline/AbstractSingleCellPipelineStep.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,11 @@ else if ("sequenceanalysis-trimmingtextarea".equals(pd.getFieldXtype()))
324324
String[] vals = val.split(",");
325325
return "c('" + StringUtils.join(vals, "','") + "')";
326326
}
327+
else if (pd.isMultiValue())
328+
{
329+
String[] vals = val.split(pd.getDelimiter());
330+
return "c('" + StringUtils.join(vals, "','") + "')";
331+
}
327332

328333
return "'" + val + "'";
329334
}

singlecell/api-src/org/labkey/api/singlecell/pipeline/SeuratToolParameter.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,31 @@ public class SeuratToolParameter extends ToolParameterDescriptor
1111
{
1212
private String _rName;
1313
private boolean _includeIfEmptyOrNull;
14+
private String _delimiter = ";";
15+
private boolean _isMultiValue;
1416

15-
public SeuratToolParameter(String name, String label, String description, String fieldXtype, @Nullable Object defaultValue, @Nullable JSONObject additionalExtConfig, String rName, boolean includeIfEmptyOrNull)
17+
public SeuratToolParameter(String name, String label, String description, String fieldXtype, @Nullable Object defaultValue, @Nullable JSONObject additionalExtConfig, String rName, boolean includeIfEmptyOrNull, boolean isMultiValue)
1618
{
1719
super(null, name, label, description, fieldXtype, defaultValue, additionalExtConfig);
1820

1921
_rName = rName;
2022
_includeIfEmptyOrNull = includeIfEmptyOrNull;
23+
_isMultiValue = isMultiValue;
2124
}
2225

2326
public static SeuratToolParameter create(String name, String label, String description, String fieldXtype, @Nullable JSONObject additionalExtConfig, @Nullable Object defaultValue)
2427
{
25-
return new SeuratToolParameter(name, label, description, fieldXtype, defaultValue, additionalExtConfig, null, true);
28+
return new SeuratToolParameter(name, label, description, fieldXtype, defaultValue, additionalExtConfig, null, true, false);
2629
}
2730

2831
public static SeuratToolParameter create(String name, String label, String description, String fieldXtype, @Nullable JSONObject additionalExtConfig, @Nullable Object defaultValue, String rName, boolean includeIfEmptyOrNull)
2932
{
30-
return new SeuratToolParameter(name, label, description, fieldXtype, defaultValue, additionalExtConfig, rName, includeIfEmptyOrNull);
33+
return SeuratToolParameter.create(name, label, description, fieldXtype, additionalExtConfig, defaultValue, rName, includeIfEmptyOrNull, false);
34+
}
35+
36+
public static SeuratToolParameter create(String name, String label, String description, String fieldXtype, @Nullable JSONObject additionalExtConfig, @Nullable Object defaultValue, String rName, boolean includeIfEmptyOrNull, boolean isMultiValue)
37+
{
38+
return new SeuratToolParameter(name, label, description, fieldXtype, defaultValue, additionalExtConfig, rName, includeIfEmptyOrNull, isMultiValue);
3139
}
3240

3341
public String getVariableName()
@@ -44,4 +52,14 @@ public boolean shouldIncludeInMarkdown(PipelineJob job, PipelineStepProvider pro
4452

4553
return true;
4654
}
55+
56+
public boolean isMultiValue()
57+
{
58+
return _isMultiValue;
59+
}
60+
61+
public String getDelimiter()
62+
{
63+
return _delimiter;
64+
}
4765
}

singlecell/src/org/labkey/singlecell/pipeline/singlecell/FindMarkers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public Provider()
3737
put("initialValues", "wilcox;MAST;DESeq2");
3838
put("delimiter", ";");
3939
put("joinReturnValue", true);
40-
}}, null),
40+
}}, null, null, false, true),
4141
SeuratToolParameter.create("pValThreshold", "pVal Threshold", "Only genes with adjusted p-values below this will be reported", "ldk-numberfield", new JSONObject(){{
4242
put("minValue", 0);
4343
put("decimalPrecision", 5);

0 commit comments

Comments
 (0)