Skip to content

Commit 3889403

Browse files
authored
Merge pull request #100 from LabKey/fb_merge_discvr-21.3
Merge discvr-21.3 to develop
2 parents 81c0a00 + 2951d82 commit 3889403

File tree

9 files changed

+119
-13
lines changed

9 files changed

+119
-13
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,24 @@ public List<SequenceOutput> getSequenceOutputs()
105105
@Override
106106
public void addSequenceOutput(File file, String label, String category, @Nullable Integer readsetId, @Nullable Integer analysisId, @Nullable Integer genomeId, @Nullable String description)
107107
{
108+
_intermediateFiles.remove(file);
109+
108110
_sequenceOutputs.add(new SequenceOutput(file, label, category, readsetId, analysisId, genomeId, description));
109111
}
110112

113+
private boolean existsAsOutput(File f)
114+
{
115+
for (SequenceOutput so : _sequenceOutputs)
116+
{
117+
if (so.getFile() != null && so.getFile().equals(f))
118+
{
119+
return true;
120+
}
121+
}
122+
123+
return false;
124+
}
125+
111126
@Override
112127
public void addInput(File input, String role)
113128
{
@@ -132,13 +147,16 @@ public void addIntermediateFile(File file, String role)
132147
if (role != null)
133148
addOutput(file, role);
134149

135-
_intermediateFiles.add(file);
150+
if (!existsAsOutput(file))
151+
{
152+
_intermediateFiles.add(file);
153+
}
136154
}
137155

138156
@Override
139157
public void addIntermediateFiles(Collection<File> files)
140158
{
141-
_intermediateFiles.addAll(files);
159+
files.forEach(this::addIntermediateFile);
142160
}
143161

144162
public void addPicardMetricsFile(Readset rs, File metricFile, File inputFile)

SequenceAnalysis/resources/views/sequenceAnalysisDetails.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
queryName: 'quality_metrics',
6969
maxRows: 20,
7070
containerPath: Laboratory.Utils.getQueryContainerPath(),
71-
columns: 'fileid,metricname,metricvalue,qualvalue,comment,workbook,readset,runid',
71+
columns: 'dataid,metricname,metricvalue,qualvalue,comment,workbook,readset,runid',
7272
filterArray: [LABKEY.Filter.create('analysis_id', analysisId, LABKEY.Filter.Types.EQUAL)]
7373
}).render('qualityMetrics_'+webpart.wrapperDivId);
7474

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/pipeline/TaskFileManagerImpl.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,27 @@ private File convertRelPathToFile(String line)
401401
public void addIntermediateFile(File f)
402402
{
403403
_job.getLogger().debug("adding intermediate file: " + f.getPath());
404-
_intermediateFiles.add(f);
404+
if (existsAsOutput(f))
405+
{
406+
_job.getLogger().debug("file exists as sequence output, will not put into intermediate files");
407+
}
408+
else
409+
{
410+
_intermediateFiles.add(f);
411+
}
412+
}
413+
414+
private boolean existsAsOutput(File f)
415+
{
416+
for (SequenceOutputFile so : _outputsToCreate)
417+
{
418+
if (so.getFile() != null && so.getFile().equals(f))
419+
{
420+
return true;
421+
}
422+
}
423+
424+
return false;
405425
}
406426

407427
@Override

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public Output execute(SequenceOutputHandler.JobContext ctx, List<SeuratObjectWra
100100
File intermediates = new File(ctx.getOutputDir(), "intermediateFiles.txt");
101101
if (intermediates.exists())
102102
{
103+
getPipelineCtx().getLogger().debug("inspecting intermediateFiles.txt");
103104
try (CSVReader reader = new CSVReader(Readers.getReader(intermediates), '\t'))
104105
{
105106
String[] line;
@@ -324,6 +325,11 @@ else if ("sequenceanalysis-trimmingtextarea".equals(pd.getFieldXtype()))
324325
String[] vals = val.split(",");
325326
return "c('" + StringUtils.join(vals, "','") + "')";
326327
}
328+
else if (pd.isMultiValue())
329+
{
330+
String[] vals = val.split(pd.getDelimiter());
331+
return "c('" + StringUtils.join(vals, "','") + "')";
332+
}
327333

328334
return "'" + val + "'";
329335
}

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/CellHashingServiceImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,14 @@ public File generateCellHashingCalls(File citeSeqCountOutDir, File outputDir, St
905905
}
906906

907907
File htmlFile = new File(outputDir, basename + ".html");
908+
File localHtml = new File(localPipelineDir, htmlFile.getName());
909+
910+
// Note: if this job fails and then is resumed, having that pre-existing copy of the HTML can pose a problem
911+
if (localHtml.exists())
912+
{
913+
log.debug("Deleting pre-existing HTML file: " + localHtml.getPath());
914+
}
915+
908916
File callsFile = new File(outputDir, basename + CALL_EXTENSION);
909917
File metricsFile = getMetricsFile(callsFile);
910918

@@ -1011,7 +1019,6 @@ public File generateCellHashingCalls(File citeSeqCountOutDir, File outputDir, St
10111019
{
10121020
try
10131021
{
1014-
File localHtml = new File(localPipelineDir, htmlFile.getName());
10151022
log.info("copying HTML file locally for easier debugging: " + localHtml.getPath());
10161023
if (localHtml.exists())
10171024
{

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)