Skip to content

Commit 218fbf2

Browse files
authored
Merge pull request #126 from LabKey/fb_merge_21.11_to_develop
Merge discvr-21.11 to develop
2 parents a73ca29 + 12115c5 commit 218fbf2

File tree

57 files changed

+1799
-284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1799
-284
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ default boolean requiresGenome()
8585

8686
public boolean canProcess(SequenceOutputFile o);
8787

88+
default boolean supportsSraArchivedData()
89+
{
90+
return false;
91+
}
92+
8893
/**
8994
* If false, this handler will not be returned with the list of available handlers for a given set of files.
9095
* This allows the developer to register handlers that feed into the pipeline, but can only be called through specific code/UI

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

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3546,7 +3546,7 @@ private JSONObject getDataJsonForReadset(SequenceOutputHandler handler, Readset
35463546
o.put("totalReadData", rs.getReadData().size());
35473547
for (ReadData rd : rs.getReadData())
35483548
{
3549-
if (rd.isArchived())
3549+
if (rd.isArchived() && !handler.supportsSraArchivedData())
35503550
{
35513551
o.put("fileExists", false);
35523552
o.put("isArchived", true);
@@ -3557,19 +3557,25 @@ private JSONObject getDataJsonForReadset(SequenceOutputHandler handler, Readset
35573557
ExpData d = rd.getFileId1() == 0 ? null : ExperimentService.get().getExpData(rd.getFileId1());
35583558
if (d == null || d.getFile() == null || !d.getFile().exists())
35593559
{
3560-
o.put("fileExists", false);
3561-
o.put("error", true);
3562-
return o;
3560+
if (!handler.supportsSraArchivedData())
3561+
{
3562+
o.put("fileExists", false);
3563+
o.put("error", true);
3564+
return o;
3565+
}
35633566
}
35643567

35653568
if (rd.getFileId2() != null)
35663569
{
35673570
d = rd.getFileId2() == 0 ? null : ExperimentService.get().getExpData(rd.getFileId2());
35683571
if (d == null || d.getFile() == null || !d.getFile().exists())
35693572
{
3570-
o.put("fileExists", false);
3571-
o.put("error", true);
3572-
return o;
3573+
if (!handler.supportsSraArchivedData())
3574+
{
3575+
o.put("fileExists", false);
3576+
o.put("error", true);
3577+
return o;
3578+
}
35733579
}
35743580
}
35753581
}
@@ -4063,11 +4069,12 @@ public ApiResponse execute(RunSequenceHandlerForm form, BindException errors) th
40634069
catch (IllegalArgumentException e)
40644070
{
40654071
errors.reject(ERROR_MSG, e.getMessage());
4072+
_log.error("Unable to submit sequence handler", e);
40664073
return null;
40674074
}
40684075
}
40694076

4070-
protected PipelineJob createOutputJob(RunSequenceHandlerForm form, Container targetContainer, String jobName, PipeRoot pr1, SequenceOutputHandler handler, List<SequenceOutputFile> inputs, JSONObject json) throws IOException, PipelineJobException
4077+
protected PipelineJob createOutputJob(RunSequenceHandlerForm form, Container targetContainer, String jobName, PipeRoot pr1, SequenceOutputHandler<?> handler, List<SequenceOutputFile> inputs, JSONObject json) throws IOException, PipelineJobException
40714078
{
40724079
validateGenomes(inputs, handler);
40734080
return new SequenceOutputHandlerJob(targetContainer, getUser(), jobName, pr1, handler, inputs, json);
@@ -4110,20 +4117,22 @@ private PipeRoot getPipeRoot(Container targetContainer, Map<Container, PipeRoot>
41104117
public class RunVariantProcessingAction extends RunSequenceHandlerAction
41114118
{
41124119
@Override
4113-
protected PipelineJob createOutputJob(RunSequenceHandlerForm form, Container targetContainer, String jobName, PipeRoot pr1, SequenceOutputHandler handler, List<SequenceOutputFile> inputs, JSONObject json) throws PipelineJobException, IOException
4120+
protected PipelineJob createOutputJob(RunSequenceHandlerForm form, Container targetContainer, String jobName, PipeRoot pr1, SequenceOutputHandler<?> handler, List<SequenceOutputFile> inputs, JSONObject json) throws PipelineJobException, IOException
41144121
{
41154122
String method = json.getString("scatterGatherMethod");
4123+
validateGenomes(inputs, handler);
4124+
4125+
VariantProcessingStep.ScatterGatherMethod scatterMethod;
41164126
try
41174127
{
4118-
validateGenomes(inputs, handler);
4119-
VariantProcessingStep.ScatterGatherMethod scatterMethod = VariantProcessingStep.ScatterGatherMethod.valueOf(method);
4120-
4121-
return new VariantProcessingJob(targetContainer, getUser(), jobName, pr1, handler, inputs, json, scatterMethod);
4128+
scatterMethod = VariantProcessingStep.ScatterGatherMethod.valueOf(method);
41224129
}
41234130
catch (IllegalArgumentException e)
41244131
{
4125-
throw new IllegalArgumentException("Unknown scatter method: " + method);
4132+
throw new IllegalArgumentException("Unknown scatter method: [" + method + "]", e);
41264133
}
4134+
4135+
return new VariantProcessingJob(targetContainer, getUser(), jobName, pr1, handler, inputs, json, scatterMethod);
41274136
}
41284137
}
41294138

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.labkey.sequenceanalysis.button.AddSraRunButton;
6161
import org.labkey.sequenceanalysis.button.ChangeReadsetStatusButton;
6262
import org.labkey.sequenceanalysis.button.ChangeReadsetStatusForAnalysesButton;
63+
import org.labkey.sequenceanalysis.button.DownloadSraButton;
6364
import org.labkey.sequenceanalysis.button.ReprocessLibraryButton;
6465
import org.labkey.sequenceanalysis.button.RunMultiQCButton;
6566
import org.labkey.sequenceanalysis.pipeline.AlignmentAnalysisJob;
@@ -82,6 +83,7 @@
8283
import org.labkey.sequenceanalysis.pipeline.VariantProcessingJob;
8384
import org.labkey.sequenceanalysis.query.SequenceAnalysisUserSchema;
8485
import org.labkey.sequenceanalysis.query.SequenceTriggerHelper;
86+
import org.labkey.sequenceanalysis.run.RestoreSraDataHandler;
8587
import org.labkey.sequenceanalysis.run.alignment.BWAMemWrapper;
8688
import org.labkey.sequenceanalysis.run.alignment.BWASWWrapper;
8789
import org.labkey.sequenceanalysis.run.alignment.BWAWrapper;
@@ -361,6 +363,7 @@ public static void registerPipelineSteps()
361363
SequenceAnalysisService.get().registerFileHandler(new NextCladeHandler());
362364

363365
SequenceAnalysisService.get().registerReadsetHandler(new MultiQCHandler());
366+
SequenceAnalysisService.get().registerReadsetHandler(new RestoreSraDataHandler());
364367

365368
//ObjectFactory.Registry.register(AnalysisModelImpl.class, new UnderscoreBeanObjectFactory(AnalysisModelImpl.class));
366369
//ObjectFactory.Registry.register(SequenceReadsetImpl.class, new UnderscoreBeanObjectFactory(SequenceReadsetImpl.class));
@@ -407,6 +410,7 @@ public void doStartupAfterSpringConfig(ModuleContext moduleContext)
407410

408411
LDKService.get().registerQueryButton(new AddSraRunButton(), SequenceAnalysisSchema.SCHEMA_NAME, SequenceAnalysisSchema.TABLE_READSETS);
409412
LDKService.get().registerQueryButton(new RunMultiQCButton(), SequenceAnalysisSchema.SCHEMA_NAME, SequenceAnalysisSchema.TABLE_READSETS);
413+
LDKService.get().registerQueryButton(new DownloadSraButton(), SequenceAnalysisSchema.SCHEMA_NAME, SequenceAnalysisSchema.TABLE_READSETS);
410414

411415
LDKService.get().registerQueryButton(new ChangeReadsetStatusForAnalysesButton(), "sequenceanalysis", "sequence_analyses");
412416
LDKService.get().registerQueryButton(new ChangeReadsetStatusButton(), "sequenceanalysis", "sequence_readsets");

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@
7474
*/
7575
public class SequenceAnalysisServiceImpl extends SequenceAnalysisService
7676
{
77-
private static SequenceAnalysisServiceImpl _instance = new SequenceAnalysisServiceImpl();
77+
private static final SequenceAnalysisServiceImpl _instance = new SequenceAnalysisServiceImpl();
7878

7979
private final Logger _log = LogManager.getLogger(SequenceAnalysisServiceImpl.class);
80-
private Set<GenomeTrigger> _genomeTriggers = new HashSet<>();
81-
private Set<SequenceOutputHandler<SequenceOutputHandler.SequenceOutputProcessor>> _fileHandlers = new HashSet<>();
82-
private Set<SequenceOutputHandler<SequenceOutputHandler.SequenceReadsetProcessor>> _readsetHandlers = new HashSet<>();
83-
private Map<String, SequenceDataProvider> _dataProviders = new HashMap<>();
80+
private final Set<GenomeTrigger> _genomeTriggers = new HashSet<>();
81+
private final Set<SequenceOutputHandler<SequenceOutputHandler.SequenceOutputProcessor>> _fileHandlers = new HashSet<>();
82+
private final Set<SequenceOutputHandler<SequenceOutputHandler.SequenceReadsetProcessor>> _readsetHandlers = new HashSet<>();
83+
private final Map<String, SequenceDataProvider> _dataProviders = new HashMap<>();
8484

8585
private SequenceAnalysisServiceImpl()
8686
{
@@ -127,10 +127,10 @@ public void registerReadsetHandler(SequenceOutputHandler<SequenceOutputHandler.S
127127
// return new TabixRunner(log).execute(input);
128128
// }
129129

130-
public Set<SequenceOutputHandler> getFileHandlers(Container c, SequenceOutputHandler.TYPE type)
130+
public Set<SequenceOutputHandler<?>> getFileHandlers(Container c, SequenceOutputHandler.TYPE type)
131131
{
132-
Set<SequenceOutputHandler> ret = new HashSet<>();
133-
for (SequenceOutputHandler h : getFileHandlers(type))
132+
Set<SequenceOutputHandler<?>> ret = new HashSet<>();
133+
for (SequenceOutputHandler<?> h : getFileHandlers(type))
134134
{
135135
if (c.getActiveModules().contains(h.getOwningModule()))
136136
{
@@ -140,7 +140,7 @@ public Set<SequenceOutputHandler> getFileHandlers(Container c, SequenceOutputHan
140140
return Collections.unmodifiableSet(ret);
141141
}
142142

143-
public Set<SequenceOutputHandler> getFileHandlers(SequenceOutputHandler.TYPE type)
143+
public Set<SequenceOutputHandler<?>> getFileHandlers(SequenceOutputHandler.TYPE type)
144144
{
145145
return Collections.unmodifiableSet(type == SequenceOutputHandler.TYPE.OutputFile ? _fileHandlers : _readsetHandlers);
146146
}
@@ -156,6 +156,7 @@ public void registerDataProvider(SequenceDataProvider p)
156156
_dataProviders.put(p.getName(), p);
157157
}
158158

159+
@Override
159160
public List<NavItem> getNavItems(Container c, User u, SequenceDataProvider.SequenceNavItemCategory category)
160161
{
161162
List<NavItem> ret = new ArrayList<>();
@@ -167,6 +168,7 @@ public List<NavItem> getNavItems(Container c, User u, SequenceDataProvider.Seque
167168
return ret;
168169
}
169170

171+
@Override
170172
public ReadDataImpl getReadData(int rowId, User u)
171173
{
172174
TableInfo ti = SequenceAnalysisSchema.getTable(SequenceAnalysisSchema.TABLE_READ_DATA);
@@ -187,6 +189,7 @@ public ReadDataImpl getReadData(int rowId, User u)
187189
return model;
188190
}
189191

192+
@Override
190193
public SequenceReadsetImpl getReadset(int readsetId, User u)
191194
{
192195
TableInfo ti = SequenceAnalysisSchema.getTable(SequenceAnalysisSchema.TABLE_READSETS);
@@ -251,7 +254,7 @@ public File ensureVcfIndex(File vcf, Logger log, boolean forceRecreate) throws I
251254
try
252255
{
253256
FileType gz = new FileType(".gz");
254-
File expected = new File(vcf.getPath() + Tribble.STANDARD_INDEX_EXTENSION);
257+
File expected = new File(vcf.getPath() + FileExtensions.TRIBBLE_INDEX);
255258
File tbi = new File(vcf.getPath() + ".tbi");
256259

257260
if (!forceRecreate && expected.exists())
@@ -288,6 +291,7 @@ else if (!forceRecreate && tbi.exists())
288291
}
289292
}
290293

294+
@Override
291295
public File bgzipFile(File input, Logger log) throws PipelineJobException
292296
{
293297
return SequenceUtil.bgzip(input, log);
@@ -296,11 +300,11 @@ public File bgzipFile(File input, Logger log) throws PipelineJobException
296300
@Override
297301
public void ensureFastaIndex(File fasta, Logger log) throws PipelineJobException
298302
{
299-
FastaIndexer indexer = new FastaIndexer(log);
300-
File index = indexer.getExpectedIndexName(fasta);
303+
File index = FastaIndexer.getExpectedIndexName(fasta);
301304
if (!index.exists())
302305
{
303306
log.info("creating FASTA index: " + fasta.getName());
307+
FastaIndexer indexer = new FastaIndexer(log);
304308
indexer.execute(fasta);
305309
}
306310
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ public <StepType extends PipelineStep> Set<PipelineStepProvider<StepType>> getPr
105105
{
106106
ParameterizedType parameterizedType = (ParameterizedType)provider.getClass().getGenericSuperclass();
107107
Class clazz = (Class)parameterizedType.getActualTypeArguments()[0];
108-
109108
if (stepType.isAssignableFrom(clazz))
110109
{
111110
ret.add(provider);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.labkey.sequenceanalysis.button;
2+
3+
import org.labkey.api.ldk.table.SimpleButtonConfigFactory;
4+
import org.labkey.api.module.ModuleLoader;
5+
import org.labkey.api.security.permissions.UpdatePermission;
6+
import org.labkey.api.view.template.ClientDependency;
7+
import org.labkey.sequenceanalysis.SequenceAnalysisModule;
8+
import org.labkey.sequenceanalysis.run.RestoreSraDataHandler;
9+
10+
import java.util.Arrays;
11+
12+
/**
13+
* Created by bimber on 7/12/2017.
14+
*/
15+
public class DownloadSraButton extends SimpleButtonConfigFactory
16+
{
17+
public DownloadSraButton()
18+
{
19+
super(ModuleLoader.getInstance().getModule(SequenceAnalysisModule.class), "Restore Archived SRA Data", "SequenceAnalysis.window.OutputHandlerWindow.readsetButtonHandler(dataRegionName, '" + RestoreSraDataHandler.class.getName() + "');", Arrays.asList(ClientDependency.supplierFromModuleName("ldk"), ClientDependency.supplierFromModuleName("laboratory"), ClientDependency.supplierFromPath("sequenceanalysis/window/OutputHandlerWindow.js")));
20+
setPermission(UpdatePermission.class);
21+
}
22+
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private SequenceReadsetHandlerJob getPipelineJob()
7575
return (SequenceReadsetHandlerJob)getJob();
7676
}
7777

78-
@NotNull
78+
@NotNull @Override
7979
public RecordedActionSet run() throws PipelineJobException
8080
{
8181
List<RecordedAction> actions = new ArrayList<>();
@@ -90,7 +90,8 @@ public RecordedActionSet run() throws PipelineJobException
9090
throw new PipelineJobException("Readset not instanceof SequenceReadsetImpl");
9191
}
9292

93-
((SequenceReadsetImpl)f).cacheForRemoteServer();
93+
94+
getPipelineJob().getSequenceSupport().cacheReadset(f.getReadsetId(), getJob().getUser(), handler.supportsSraArchivedData());
9495
}
9596

9697
getJob().getLogger().info("total readsets: " + getPipelineJob().getReadsets().size());

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected SequenceReadsetHandlerJob()
3434
{
3535
}
3636

37-
public SequenceReadsetHandlerJob(Container c, User user, @Nullable String jobName, PipeRoot pipeRoot, SequenceOutputHandler handler, List<SequenceReadsetImpl> readsets, JSONObject jsonParams) throws IOException
37+
public SequenceReadsetHandlerJob(Container c, User user, @Nullable String jobName, PipeRoot pipeRoot, SequenceOutputHandler<?> handler, List<SequenceReadsetImpl> readsets, JSONObject jsonParams) throws IOException
3838
{
3939
super(SequenceReadsetHandlerPipelineProvider.NAME, c, user, jobName, pipeRoot, jsonParams, null, SequenceOutputHandlerJob.FOLDER_NAME);
4040

@@ -44,13 +44,13 @@ public SequenceReadsetHandlerJob(Container c, User user, @Nullable String jobNam
4444
_readsetIds = new ArrayList<>();
4545
for (SequenceReadsetImpl rs : readsets)
4646
{
47-
getSequenceSupport().cacheReadset(rs);
47+
getSequenceSupport().cacheReadset(rs, getHandler().supportsSraArchivedData());
4848
_readsetIds.add(rs.getReadsetId());
4949
}
5050
}
5151

5252
@Override
53-
public TaskPipeline getTaskPipeline()
53+
public TaskPipeline<?> getTaskPipeline()
5454
{
5555
return PipelineJobService.get().getTaskPipeline(new TaskId(SequenceReadsetHandlerJob.class));
5656
}
@@ -81,7 +81,11 @@ public List<File> getInputFiles()
8181
{
8282
for (ReadData d : rs.getReadData())
8383
{
84-
ret.add(d.getFile1());
84+
if (d.getFile1() != null)
85+
{
86+
ret.add(d.getFile1());
87+
}
88+
8589
if (d.getFile2() != null)
8690
{
8791
ret.add(d.getFile2());

0 commit comments

Comments
 (0)