Skip to content

Commit 27f5c87

Browse files
committed
Merge discvr-21.7 to develop
2 parents e980e84 + 3a56790 commit 27f5c87

File tree

24 files changed

+466
-211
lines changed

24 files changed

+466
-211
lines changed

OpenLdapSync/build.gradle

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
import org.labkey.gradle.util.BuildUtils;
2+
import org.labkey.gradle.util.ExternalDependency
3+
14
dependencies {
2-
external "org.apache.directory.api:api-all:${apacheDirectoryVersion}"
5+
BuildUtils.addExternalDependency(
6+
project,
7+
new ExternalDependency(
8+
"org.apache.directory.api:api-all:${apacheDirectoryVersion}",
9+
'Apache Directory',
10+
'Apache Directory',
11+
'http://directory.apache.org/',
12+
ExternalDependency.APACHE_2_LICENSE_NAME,
13+
ExternalDependency.APACHE_2_LICENSE_URL,
14+
'Used by LDAP Sync'
15+
)
16+
)
317
}

OpenLdapSync/resources/credits/dependencies.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

OpenLdapSync/resources/credits/jars.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

SequenceAnalysis/src/org/labkey/sequenceanalysis/SequenceAnalysisController.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
import org.labkey.api.util.ExceptionUtil;
119119
import org.labkey.api.util.FileType;
120120
import org.labkey.api.util.FileUtil;
121+
import org.labkey.api.util.HtmlString;
121122
import org.labkey.api.util.NetworkDrive;
122123
import org.labkey.api.util.PageFlowUtil;
123124
import org.labkey.api.util.Pair;
@@ -218,11 +219,17 @@ public SequenceAnalysisController()
218219
public class FastqcReportAction extends SimpleViewAction<FastqcForm>
219220
{
220221
@Override
221-
public ModelAndView getView(FastqcForm form, BindException errors) throws Exception
222+
public void validate(FastqcForm form, BindException errors)
222223
{
223-
if (form.getFilenames() == null && form.getDataIds() == null)
224-
errors.reject("Must provide a filename or Exp data Ids");
224+
if (form.getReadsets() == null && form.getFilenames() == null && form.getDataIds() == null && form.getAnalysisIds() == null)
225+
{
226+
errors.reject(ERROR_MSG, "Must provide a filename or Exp data Ids");
227+
}
228+
}
225229

230+
@Override
231+
public ModelAndView getView(FastqcForm form, BindException errors) throws Exception
232+
{
226233
//resolve files
227234
List<File> files = new ArrayList<>();
228235
Map<File, String> labels = new HashMap<>();
@@ -312,7 +319,7 @@ public ModelAndView getView(FastqcForm form, BindException errors) throws Except
312319
try
313320
{
314321
String html = runner.execute(files, labels);
315-
return new HtmlView("FastQC Report", html);
322+
return new HtmlView("FastQC Report", HtmlString.unsafe(html));
316323
}
317324
catch (FileNotFoundException e)
318325
{
@@ -597,20 +604,20 @@ public void validateCommand(DeleteForm form, Errors errors)
597604
{
598605
if (form.getSchema() == null)
599606
{
600-
errors.reject("No schema provided");
607+
errors.reject(ERROR_MSG, "No schema provided");
601608
return;
602609
}
603610

604611
if (form.getQueryName() == null)
605612
{
606-
errors.reject("No queryName provided");
613+
errors.reject(ERROR_MSG, "No queryName provided");
607614
return;
608615
}
609616

610617
_table = SequenceAnalysisSchema.getInstance().getSchema().getTable(form.getQueryName());
611618
if (_table == null)
612619
{
613-
errors.reject("Unknown table: " + form.getQueryName());
620+
errors.reject(ERROR_MSG, "Unknown table: " + form.getQueryName());
614621
return;
615622
}
616623

@@ -2220,7 +2227,7 @@ public ApiResponse execute(CreateReferenceLibraryForm form, BindException errors
22202227
String[] coordinates = t.split("-");
22212228
if (coordinates.length != 2)
22222229
{
2223-
errors.reject("Inproper interval: [" + t + "]");
2230+
errors.reject(ERROR_MSG, "Inproper interval: [" + t + "]");
22242231
return null;
22252232
}
22262233

@@ -3143,7 +3150,7 @@ public void exec(ResultSet object) throws SQLException
31433150
String wholeSequence = model.getSequence();
31443151
if (wholeSequence == null)
31453152
{
3146-
errors.reject("Unable to find sequence for: " + rowId);
3153+
errors.reject(ERROR_MSG, "Unable to find sequence for: " + rowId);
31473154
return;
31483155
}
31493156

@@ -3152,21 +3159,21 @@ public void exec(ResultSet object) throws SQLException
31523159
String[] coordinates = t.split("-");
31533160
if (coordinates.length != 2)
31543161
{
3155-
errors.reject("Inproper interval: [" + t + "]");
3162+
errors.reject(ERROR_MSG, "Inproper interval: [" + t + "]");
31563163
return;
31573164
}
31583165

31593166
Integer start = StringUtils.trimToNull(coordinates[0]) == null ? null : ConvertHelper.convert(coordinates[0], Integer.class);
31603167
if (wholeSequence.length() < start)
31613168
{
3162-
errors.reject("Start is beyond the length of the sequence. Length: " + wholeSequence.length());
3169+
errors.reject(ERROR_MSG, "Start is beyond the length of the sequence. Length: " + wholeSequence.length());
31633170
return;
31643171
}
31653172

31663173
Integer stop = StringUtils.trimToNull(coordinates[1]) == null ? null : ConvertHelper.convert(coordinates[1], Integer.class);
31673174
if (wholeSequence.length() < stop)
31683175
{
3169-
errors.reject("Stop is beyond the length of the sequence. Length: " + wholeSequence.length());
3176+
errors.reject(ERROR_MSG, "Stop is beyond the length of the sequence. Length: " + wholeSequence.length());
31703177
return;
31713178
}
31723179

@@ -3274,7 +3281,7 @@ public ApiResponse execute(RecreateReferenceLibraryForm form, BindException erro
32743281
{
32753282
if (form.getLibraryIds() == null || form.getLibraryIds().length == 0)
32763283
{
3277-
errors.reject("Must provide a list of reference genomes to re-process");
3284+
errors.reject(ERROR_MSG, "Must provide a list of reference genomes to re-process");
32783285
return null;
32793286
}
32803287

SequenceAnalysis/src/org/labkey/sequenceanalysis/SequenceAnalysisMaintenanceTask.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,12 @@ private void processContainer(Container c, Logger log) throws IOException
398398
ExpData d = ExperimentService.get().getExpData(dataId);
399399
if (d != null)
400400
{
401+
if (d.getFile() == null)
402+
{
403+
log.error("File was null for ExpData: " + d.getRowId());
404+
continue;
405+
}
406+
401407
expectedFileNames.add(d.getFile().getName());
402408
expectedFileNames.addAll(getAssociatedFiles(d.getFile(), true));
403409

SequenceAnalysis/src/org/labkey/sequenceanalysis/SequenceAnalysisModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.labkey.sequenceanalysis.analysis.MultiQCBamHandler;
5353
import org.labkey.sequenceanalysis.analysis.MultiQCHandler;
5454
import org.labkey.sequenceanalysis.analysis.PicardAlignmentMetricsHandler;
55+
import org.labkey.sequenceanalysis.analysis.PrintReadBackedHaplotypesHandler;
5556
import org.labkey.sequenceanalysis.analysis.RecalculateSequenceMetricsHandler;
5657
import org.labkey.sequenceanalysis.analysis.RnaSeqcHandler;
5758
import org.labkey.sequenceanalysis.analysis.SbtGeneCountHandler;
@@ -338,6 +339,7 @@ public static void registerPipelineSteps()
338339
SequenceAnalysisService.get().registerFileHandler(new PicardAlignmentMetricsHandler());
339340
SequenceAnalysisService.get().registerFileHandler(new BamHaplotypeHandler());
340341
SequenceAnalysisService.get().registerFileHandler(new BamCleanupHandler());
342+
SequenceAnalysisService.get().registerFileHandler(new PrintReadBackedHaplotypesHandler());
341343
SequenceAnalysisService.get().registerFileHandler(new HaplotypeCallerHandler());
342344
SequenceAnalysisService.get().registerFileHandler(new RnaSeqcHandler());
343345
SequenceAnalysisService.get().registerFileHandler(new CombineStarGeneCountsHandler());
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
package org.labkey.sequenceanalysis.analysis;
2+
3+
import htsjdk.samtools.util.Interval;
4+
import org.apache.commons.lang3.StringUtils;
5+
import org.apache.logging.log4j.Logger;
6+
import org.json.JSONObject;
7+
import org.labkey.api.module.ModuleLoader;
8+
import org.labkey.api.pipeline.PipelineJob;
9+
import org.labkey.api.pipeline.PipelineJobException;
10+
import org.labkey.api.pipeline.RecordedAction;
11+
import org.labkey.api.sequenceanalysis.SequenceOutputFile;
12+
import org.labkey.api.sequenceanalysis.pipeline.AbstractParameterizedOutputHandler;
13+
import org.labkey.api.sequenceanalysis.pipeline.CommandLineParam;
14+
import org.labkey.api.sequenceanalysis.pipeline.SequenceAnalysisJobSupport;
15+
import org.labkey.api.sequenceanalysis.pipeline.SequenceOutputHandler;
16+
import org.labkey.api.sequenceanalysis.pipeline.ToolParameterDescriptor;
17+
import org.labkey.api.sequenceanalysis.run.DISCVRSeqRunner;
18+
import org.labkey.api.util.FileType;
19+
import org.labkey.api.util.FileUtil;
20+
import org.labkey.api.util.PageFlowUtil;
21+
import org.labkey.sequenceanalysis.SequenceAnalysisModule;
22+
import org.labkey.sequenceanalysis.util.SequenceUtil;
23+
24+
import java.io.File;
25+
import java.util.ArrayList;
26+
import java.util.Arrays;
27+
import java.util.Date;
28+
import java.util.LinkedHashSet;
29+
import java.util.List;
30+
31+
/**
32+
* Created by bimber on 2/3/2016.
33+
*/
34+
public class PrintReadBackedHaplotypesHandler extends AbstractParameterizedOutputHandler<SequenceOutputHandler.SequenceOutputProcessor>
35+
{
36+
private FileType _bamFileType = new FileType("bam", false);
37+
38+
public PrintReadBackedHaplotypesHandler()
39+
{
40+
super(ModuleLoader.getInstance().getModule(SequenceAnalysisModule.class), "Print Read-Backed Haplotypes", "This scans the alignments over the provided interval(s), and reports all unique haplotypes.", new LinkedHashSet<>(PageFlowUtil.set("/sequenceanalysis/field/IntervalField.js")), Arrays.asList(
41+
ToolParameterDescriptor.create("intervals", "Intervals", "The intervals over which to merge the data. They should be in the form: chr01:102-20394", "sequenceanalysis-intervalfield", new JSONObject(){{
42+
put("allowBlank", false);
43+
}}, null),
44+
ToolParameterDescriptor.createCommandLineParam(CommandLineParam.create("-mq"), "minQual", "Min Base Quality", "Nucleotides with quality scores below this value will be converted to N", "ldk-integerfield", new JSONObject(){{
45+
put("minValue", 0);
46+
}}, 10),
47+
ToolParameterDescriptor.createCommandLineParam(CommandLineParam.create("-rc"), "requiredCoverageFraction", "Required Coverage Fraction", "A haplotype must have coverage over this fraction of the interval to be reported", "ldk-numberfield", new JSONObject(){{
48+
put("minValue", 0);
49+
put("maxValue", 1.0);
50+
put("decimalPrecision", 2);
51+
}}, null),
52+
ToolParameterDescriptor.createCommandLineParam(CommandLineParam.create("-mr"), "minReadsToReport", "Min Reads To Report", "If specified, only haplotypes with at least this many reads will be reported", "ldk-integerfield", new JSONObject(){{
53+
put("minValue", 0);
54+
}}, null),
55+
ToolParameterDescriptor.createCommandLineParam(CommandLineParam.create("-mrf"), "minReadFractionToReport", "Min Read Fraction To Report", "If specified, only haplotypes representing at least this fraction of total haplotypes will be reported", "ldk-numberfield", new JSONObject(){{
56+
put("minValue", 0);
57+
put("maxValue", 1.0);
58+
put("decimalPrecision", 2);
59+
}}, 0.01)
60+
));
61+
}
62+
63+
@Override
64+
public boolean canProcess(SequenceOutputFile o)
65+
{
66+
return o.getFile() != null && _bamFileType.isType(o.getFile());
67+
}
68+
69+
@Override
70+
public boolean doRunRemote()
71+
{
72+
return true;
73+
}
74+
75+
@Override
76+
public boolean doRunLocal()
77+
{
78+
return false;
79+
}
80+
81+
@Override
82+
public SequenceOutputProcessor getProcessor()
83+
{
84+
return new Processor();
85+
}
86+
87+
@Override
88+
public boolean doSplitJobs()
89+
{
90+
return true;
91+
}
92+
93+
public class Processor implements SequenceOutputProcessor
94+
{
95+
@Override
96+
public void init(JobContext ctx, List<SequenceOutputFile> inputFiles, List<RecordedAction> actions, List<SequenceOutputFile> outputsToCreate) throws UnsupportedOperationException, PipelineJobException
97+
{
98+
for (SequenceOutputFile so : inputFiles)
99+
{
100+
if (so.getReadset() != null)
101+
{
102+
ctx.getSequenceSupport().cacheReadset(so.getReadset(), ctx.getJob().getUser());
103+
}
104+
else
105+
{
106+
ctx.getJob().getLogger().error("Output file lacks a readset and will be skipped: " + so.getRowid());
107+
}
108+
}
109+
}
110+
111+
@Override
112+
public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext ctx) throws UnsupportedOperationException, PipelineJobException
113+
{
114+
PipelineJob job = ctx.getJob();
115+
if (inputFiles.isEmpty())
116+
{
117+
job.getLogger().warn("no input files");
118+
}
119+
120+
for (SequenceOutputFile so : inputFiles)
121+
{
122+
RecordedAction action = new RecordedAction(getName());
123+
action.setStartTime(new Date());
124+
action.addInput(so.getFile(), "Input BAM");
125+
126+
File input = so.getFile();
127+
128+
String intervalText = StringUtils.trimToNull(ctx.getParams().optString("intervals"));
129+
if (intervalText == null)
130+
{
131+
throw new PipelineJobException("Must provide a list of intervals");
132+
}
133+
134+
List<String> args = new ArrayList<>();
135+
List<Interval> il = SequenceUtil.parseAndSortIntervals(intervalText);
136+
if (il != null)
137+
{
138+
for (Interval i : il)
139+
{
140+
args.add("-L");
141+
args.add(i.getContig() + ":" + i.getStart() + "-" + i.getEnd());
142+
}
143+
}
144+
145+
List<String> extraArgs = getClientCommandArgs(ctx.getParams());
146+
if (extraArgs != null)
147+
{
148+
args.addAll(extraArgs);
149+
}
150+
151+
File output = new File(ctx.getWorkingDirectory(), FileUtil.getBaseName(input) + ".txt");
152+
Wrapper wrapper = new Wrapper(ctx.getLogger());
153+
wrapper.execute(input, ctx.getSequenceSupport().getCachedGenome(so.getLibrary_id()).getWorkingFastaFile(), output, args);
154+
155+
action.addOutput(output, "Local Haplotypes", false);
156+
ctx.addActions(action);
157+
158+
SequenceOutputFile o = new SequenceOutputFile();
159+
o.setName(output.getName());
160+
o.setFile(output);
161+
o.setLibrary_id(so.getLibrary_id());
162+
o.setCategory("Local Haplotypes");
163+
o.setReadset(so.getReadset());
164+
ctx.addSequenceOutput(o);
165+
}
166+
}
167+
168+
@Override
169+
public void processFilesOnWebserver(PipelineJob job, SequenceAnalysisJobSupport support, List<SequenceOutputFile> inputFiles, JSONObject params, File outputDir, List<RecordedAction> actions, List<SequenceOutputFile> outputsToCreate) throws UnsupportedOperationException, PipelineJobException
170+
{
171+
172+
}
173+
}
174+
175+
public static class Wrapper extends DISCVRSeqRunner
176+
{
177+
public Wrapper(Logger log)
178+
{
179+
super(log);
180+
}
181+
182+
public File execute(File bam, File fasta, File output, List<String> extraArgs) throws PipelineJobException
183+
{
184+
List<String> args = getBaseArgs("PrintReadBackedHaplotypes");
185+
args.add("-I");
186+
args.add(bam.getPath());
187+
188+
args.add("-R");
189+
args.add(fasta.getPath());
190+
191+
args.add("-O");
192+
args.add(output.getPath());
193+
194+
args.addAll(extraArgs);
195+
196+
execute(args);
197+
198+
if (!output.exists())
199+
{
200+
throw new PipelineJobException("Unable to find file: " + output.getPath());
201+
}
202+
203+
return output;
204+
}
205+
}
206+
}

0 commit comments

Comments
 (0)