-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTargetedMSModule.java
More file actions
748 lines (660 loc) · 34.7 KB
/
TargetedMSModule.java
File metadata and controls
748 lines (660 loc) · 34.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
/*
* Copyright (c) 2012-2019 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.labkey.targetedms;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.labkey.api.admin.FolderSerializationRegistry;
import org.labkey.api.assay.sample.SampleAssayResultsConfig;
import org.labkey.api.assay.sample.SampleAssayResultsService;
import org.labkey.api.audit.AuditLogService;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerFilter;
import org.labkey.api.data.ContainerManager;
import org.labkey.api.data.DbSchema;
import org.labkey.api.data.PropertySchema;
import org.labkey.api.data.SQLFragment;
import org.labkey.api.data.SqlSelector;
import org.labkey.api.data.UpgradeCode;
import org.labkey.api.exp.api.ExperimentService;
import org.labkey.api.files.DirectoryPattern;
import org.labkey.api.files.FileContentService;
import org.labkey.api.module.FolderTypeManager;
import org.labkey.api.module.Module;
import org.labkey.api.module.ModuleContext;
import org.labkey.api.module.ModuleHtmlView;
import org.labkey.api.module.ModuleProperty;
import org.labkey.api.module.SpringModule;
import org.labkey.api.pipeline.PipelineService;
import org.labkey.api.protein.ProteinService;
import org.labkey.api.protein.ProteomicsModule;
import org.labkey.api.protein.search.MSSearchWebpart;
import org.labkey.api.protein.search.ProteinSearchForm;
import org.labkey.api.query.QueryView;
import org.labkey.api.security.permissions.AdminPermission;
import org.labkey.api.security.permissions.ApplicationAdminPermission;
import org.labkey.api.settings.AdminConsole;
import org.labkey.api.settings.OptionalFeatureFlag;
import org.labkey.api.settings.OptionalFeatureService;
import org.labkey.api.targetedms.TargetedMSService;
import org.labkey.api.usageMetrics.UsageMetricsService;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.view.ActionURL;
import org.labkey.api.view.BaseWebPartFactory;
import org.labkey.api.view.JspView;
import org.labkey.api.view.NavTree;
import org.labkey.api.view.Portal;
import org.labkey.api.view.ViewContext;
import org.labkey.api.view.WebPartFactory;
import org.labkey.api.view.WebPartView;
import org.labkey.api.view.template.ClientDependency;
import org.labkey.panoramapremium.PanoramaPremiumController;
import org.labkey.panoramapremium.QCNotificationSender;
import org.labkey.panoramapremium.View.QCSummaryMenuCustomizer;
import org.labkey.targetedms.chart.ComparisonCategory;
import org.labkey.targetedms.chart.ReplicateLabelMinimizer;
import org.labkey.targetedms.datasource.MsDataSourceUtil;
import org.labkey.targetedms.folderImport.QCFolderImporter;
import org.labkey.targetedms.folderImport.QCFolderWriterFactory;
import org.labkey.targetedms.parser.Protein;
import org.labkey.targetedms.parser.SampleFile;
import org.labkey.targetedms.parser.SpectrumFilter;
import org.labkey.targetedms.parser.skyaudit.SkylineAuditLogParser;
import org.labkey.targetedms.passport.PassportController;
import org.labkey.targetedms.pipeline.TargetedMSPipelineProvider;
import org.labkey.targetedms.query.CrossLinkedPeptideDisplayColumn;
import org.labkey.targetedms.query.PrecursorManager;
import org.labkey.targetedms.query.SkylineListSchema;
import org.labkey.targetedms.search.ModificationSearchWebPart;
import org.labkey.targetedms.search.ProteinSearchWebPart;
import org.labkey.targetedms.view.CalibrationCurveView;
import org.labkey.targetedms.view.CrossLinkedPeptideInfo;
import org.labkey.targetedms.view.LibraryQueryViewWebPart;
import org.labkey.targetedms.view.ReplicateSummaryWebPart;
import org.labkey.targetedms.view.TargetedMSRunsWebPartView;
import org.labkey.targetedms.view.TransitionPeptideSearchViewProvider;
import org.labkey.targetedms.view.TransitionProteinSearchViewProvider;
import org.labkey.targetedms.view.passport.ProteinListView;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.labkey.api.targetedms.TargetedMSService.FOLDER_TYPE_PROP_NAME;
import static org.labkey.api.targetedms.TargetedMSService.MODULE_NAME;
public class TargetedMSModule extends SpringModule implements ProteomicsModule
{
// Protocol prefix for importing .sky documents from Skyline
public static final String IMPORT_SKYDOC_PROTOCOL_OBJECT_PREFIX = "TargetedMS.ImportSky";
// Protocol prefix for importing .zip archives from Skyline
public static final String IMPORT_SKYZIP_PROTOCOL_OBJECT_PREFIX = "TargetedMS.ImportSkyZip";
public static final String TARGETED_MS_SETUP = "Targeted MS Setup";
public static final String TARGETED_MS_CHROMATOGRAM_LIBRARY_DOWNLOAD = "Chromatogram Library Download";
public static final String TARGETED_MS_PRECURSOR_VIEW = "Targeted MS Precursor View";
public static final String TARGETED_MS_PEPTIDE_VIEW = "Targeted MS Peptide View";
public static final String TARGETED_MS_MOLECULE_PRECURSOR_VIEW = "Targeted MS Molecule Precursor View";
public static final String TARGETED_MS_MOLECULE_VIEW = "Targeted MS Molecule View";
public static final String TARGETED_MS_PEPTIDE_GROUP_VIEW = "Targeted MS Protein View";
public static final String TARGETED_MS_RUNS_WEBPART_NAME = "Targeted MS Runs";
public static final String TARGETED_MS_PROTEIN_SEARCH = "Targeted MS Protein Search";
public static final String TARGETED_MS_PEPTIDE_SEARCH = "Targeted MS Peptide Search";
public static final String TARGETED_MS_REPLICATE_SUMMARY = "Targeted MS Replicate Summary";
public static final String TARGETED_MS_QC_PLOTS = "Targeted MS QC Plots";
public static final String TARGETED_MS_PARETO_PLOT = "Targeted MS Pareto Plot";
public static final String TARGETED_MS_CALIBRATION_CURVE = "Targeted MS Calibration Curve";
public static final String TARGETED_MS_FIGURES_OF_MERIT = "Targeted MS Figures of Merit";
public static final String TARGETED_MS_PEPTIDE_MOLECULE_SUMMARY = "Peptide/Molecule Summary";
public static final String TARGETED_MS_PROJECT_WEBPART = "Targeted MS Project";
public static final String PEPTIDE_TAB_NAME = "Peptides";
public static final String PROTEIN_TAB_NAME = "Proteins";
public static final String MOLECULE_TAB_NAME = "Molecules";
public static final String USE_TEMP_DIR_FOR_SKYD_IMPORT = "UseTempDirForSkydImport";
public static final String[] EXPERIMENT_FOLDER_WEB_PARTS = new String[] {MSSearchWebpart.NAME,
TARGETED_MS_RUNS_WEBPART_NAME};
public static final String[] LIBRARY_FOLDER_WEB_PARTS = new String[] {TARGETED_MS_CHROMATOGRAM_LIBRARY_DOWNLOAD,
MSSearchWebpart.NAME,
TARGETED_MS_RUNS_WEBPART_NAME};
public static final String[] PEPTIDE_TAB_WEB_PARTS = new String[] {
TARGETED_MS_PEPTIDE_VIEW,
TARGETED_MS_PRECURSOR_VIEW
};
public static final String[] MOLECULE_TAB_WEB_PARTS = new String[] {
TARGETED_MS_MOLECULE_VIEW,
TARGETED_MS_MOLECULE_PRECURSOR_VIEW
};
public static final String[] PROTEIN_TAB_WEB_PARTS = new String[] {
TARGETED_MS_PEPTIDE_GROUP_VIEW
};
public static final String[] QC_FOLDER_WEB_PARTS = new String[] {TARGETED_MS_REPLICATE_SUMMARY, TARGETED_MS_QC_PLOTS};
public final ModuleProperty FOLDER_TYPE_PROPERTY;
public final ModuleProperty SKYLINE_AUDIT_LEVEL_PROPERTY;
public final ModuleProperty MAX_TRANSITION_CHROM_INFOS_PROPERTY;
public static final int DEFAULT_MAX_TRANSITION_CHROM_INFOS = 100_000;
public final ModuleProperty MAX_PRECURSORS_PROPERTY;
public static final int DEFAULT_MAX_PRECURSORS = 1_000;
public final ModuleProperty AUTO_QC_PING_TIMEOUT_PROPERTY;
public TargetedMSModule()
{
FOLDER_TYPE_PROPERTY = new ModuleProperty(this, FOLDER_TYPE_PROP_NAME);
// Set up the TargetedMS Folder Type property
FOLDER_TYPE_PROPERTY.setDefaultValue(TargetedMSService.FolderType.Undefined.toString());
FOLDER_TYPE_PROPERTY.setCanSetPerContainer(true);
FOLDER_TYPE_PROPERTY.setShowDescriptionInline(true);
addModuleProperty(FOLDER_TYPE_PROPERTY);
List<ModuleProperty.Option> auditOptions = List.of(
new ModuleProperty.Option("0 - No Verification", "0"),
new ModuleProperty.Option("1 - Hash Verification", "1"),
new ModuleProperty.Option("2 - RSA Verification", "2")
);
// Set up the properties for controlling how chromatograms are managed in DB vs files
SKYLINE_AUDIT_LEVEL_PROPERTY = new ModuleProperty(this, "Audit log integrity level for the uploaded Skyline documents");
SKYLINE_AUDIT_LEVEL_PROPERTY.setInputType(ModuleProperty.InputType.combo);
SKYLINE_AUDIT_LEVEL_PROPERTY.setOptions(auditOptions);
SKYLINE_AUDIT_LEVEL_PROPERTY.setDefaultValue("0");
SKYLINE_AUDIT_LEVEL_PROPERTY.setCanSetPerContainer(true);
SKYLINE_AUDIT_LEVEL_PROPERTY.setDescription("""
Defines requirements for the integrity of the audit log uploaded together with a Skyline document.\s
0 means that no audit log is required. If the log file is present in the uploaded file it will be parsed and loaded as is.
\
1 means that audit log is required and its integrity will be verified using MD5 hash-based algorithm. If log integrity verification fails the document upload will be cancelled.\s
2 means that audit log is required and its integrity will be verified using RSA-encryption algorithm. If log integrity verification fails the document upload will be cancelled.""");
SKYLINE_AUDIT_LEVEL_PROPERTY.setShowDescriptionInline(true);
addModuleProperty(SKYLINE_AUDIT_LEVEL_PROPERTY);
//------------------------rr
// setup the replicate summary webpart AutoQCPing timeout
AUTO_QC_PING_TIMEOUT_PROPERTY = new ModuleProperty(this, "TargetedMS AutoQCPing Timeout");
AUTO_QC_PING_TIMEOUT_PROPERTY.setDescription("The number of minutes before the most recent AutoQCPing indicator is considered stale.");
AUTO_QC_PING_TIMEOUT_PROPERTY.setDefaultValue("15");
AUTO_QC_PING_TIMEOUT_PROPERTY.setShowDescriptionInline(true);
AUTO_QC_PING_TIMEOUT_PROPERTY.setCanSetPerContainer(true);
addModuleProperty(AUTO_QC_PING_TIMEOUT_PROPERTY);
MAX_TRANSITION_CHROM_INFOS_PROPERTY = new ModuleProperty(this, "TransitionChromInfo storage limit");
MAX_TRANSITION_CHROM_INFOS_PROPERTY.setInputType(ModuleProperty.InputType.text);
MAX_TRANSITION_CHROM_INFOS_PROPERTY.setDefaultValue(Integer.toString(DEFAULT_MAX_TRANSITION_CHROM_INFOS));
// Issue 47774: Remove TargetedMS module properties related to reading chromatogram data.
// Property can be set only at the site level.
MAX_TRANSITION_CHROM_INFOS_PROPERTY.setCanSetPerContainer(false);
MAX_TRANSITION_CHROM_INFOS_PROPERTY.setDescription("Large DIA Skyline documents may have many transition/replicate chromatograms which may not be very useful to store in the database. Panorama can skip importing them to save storage space and import time, if the number of separately configured precursors is also exceeded");
MAX_TRANSITION_CHROM_INFOS_PROPERTY.setShowDescriptionInline(true);
addModuleProperty(MAX_TRANSITION_CHROM_INFOS_PROPERTY);
MAX_PRECURSORS_PROPERTY = new ModuleProperty(this, "Precursor storage limit");
MAX_PRECURSORS_PROPERTY.setInputType(ModuleProperty.InputType.text);
MAX_PRECURSORS_PROPERTY.setDefaultValue(Integer.toString(DEFAULT_MAX_PRECURSORS));
// Issue 47774: Remove TargetedMS module properties related to reading chromatogram data.
// Property can be set only at the site level.
MAX_PRECURSORS_PROPERTY.setCanSetPerContainer(false);
MAX_PRECURSORS_PROPERTY.setDescription("If a document has more than a specified number of precursors AND more than the separate transition/replicate chromatogram limit, Panorama will skip storing them in the database to save space and import time");
MAX_PRECURSORS_PROPERTY.setShowDescriptionInline(true);
addModuleProperty(MAX_PRECURSORS_PROPERTY);
}
@Override
public String getName()
{
return MODULE_NAME;
}
@Override
public Double getSchemaVersion()
{
return 26.004;
}
@Override
public boolean hasScripts()
{
return true;
}
@Override
public boolean isAvailable(Container container)
{
return container.isRoot() || container.getActiveModules().contains(this);
}
@NotNull
@Override
protected Collection<WebPartFactory> createWebPartFactories()
{
return List.of(
new BaseWebPartFactory(TARGETED_MS_SETUP)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
JspView<Void> view = new JspView<>("/org/labkey/targetedms/view/folderSetup.jsp");
view.setTitle(TargetedMSController.CONFIGURE_TARGETED_MS_FOLDER);
return view;
}
@Override
public String getDisplayName(Container container, String location)
{
return "Panorama Setup";
}
},
new BaseWebPartFactory(TARGETED_MS_CHROMATOGRAM_LIBRARY_DOWNLOAD)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
JspView<Void> view = new JspView<>("/org/labkey/targetedms/view/chromatogramLibraryDownload.jsp");
view.setTitle(TARGETED_MS_CHROMATOGRAM_LIBRARY_DOWNLOAD);
return view;
}
},
new BaseWebPartFactory(TARGETED_MS_PRECURSOR_VIEW)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
return LibraryQueryViewWebPart.forTable(TargetedMSSchema.TABLE_PRECURSOR, portalCtx);
}
},
new BaseWebPartFactory(TARGETED_MS_MOLECULE_PRECURSOR_VIEW)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
return LibraryQueryViewWebPart.forTable(TargetedMSSchema.TABLE_MOLECULE_PRECURSOR, portalCtx);
}
},
new BaseWebPartFactory(TARGETED_MS_PEPTIDE_VIEW)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
return LibraryQueryViewWebPart.forTable(TargetedMSSchema.TABLE_PEPTIDE, portalCtx);
}
},
new BaseWebPartFactory(TARGETED_MS_MOLECULE_VIEW)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
return LibraryQueryViewWebPart.forTable(TargetedMSSchema.TABLE_MOLECULE, portalCtx);
}
},
new BaseWebPartFactory(TARGETED_MS_PEPTIDE_GROUP_VIEW)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
return LibraryQueryViewWebPart.forTable(TargetedMSSchema.TABLE_PEPTIDE_GROUP, portalCtx);
}
},
new BaseWebPartFactory(TARGETED_MS_RUNS_WEBPART_NAME)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
return new TargetedMSRunsWebPartView(portalCtx);
}
},
new BaseWebPartFactory(TARGETED_MS_PROTEIN_SEARCH)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
return new ProteinSearchWebPart(new ProteinSearchForm()
{
@Override
public int[] getSeqId()
{
return new int[0];
}
@Override
public boolean isExactMatch()
{
return true;
}
});
}
},
new BaseWebPartFactory(TARGETED_MS_PEPTIDE_SEARCH)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
JspView<Void> view = new JspView<>("/org/labkey/targetedms/search/peptideSearch.jsp");
view.setTitle("Peptide Search");
return view;
}
},
new BaseWebPartFactory(ModificationSearchWebPart.NAME)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
TargetedMSController.ModificationSearchForm form = TargetedMSController.ModificationSearchForm.createDefault();
// When rendering a webpart with LABKEY.WebPart in a wiki page, config.partConfig can be used to set the
// configuration parameters for the webpart. Read the parameters from the ViewContext and initialize the
// form accordingly.
// For example, partConfig: {hideIncludeSubfolder: true, includeSubfolders: true} should hide the
// "includeSubfolders" checkbox and set the value of "includeSubfolders" to true.
String inclSubFolders = (String)portalCtx.get("includeSubfolders");
if(!StringUtils.isBlank(inclSubFolders))
{
form.setIncludeSubfolders(Boolean.valueOf(inclSubFolders));
}
String hideIncludeSubfolder = (String)portalCtx.get("hideIncludeSubfolder");
if(!StringUtils.isBlank(hideIncludeSubfolder))
{
form.setHideIncludeSubfolders(Boolean.valueOf(hideIncludeSubfolder));
}
return new ModificationSearchWebPart(form);
}
},
new BaseWebPartFactory(TARGETED_MS_QC_PLOTS)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
JspView<Void> result = new JspView<>("/org/labkey/targetedms/view/qcTrendPlotReport.jsp");
result.addClientDependency(ClientDependency.fromPath("Ext4"));
result.setTitle("QC Plots");
result.setFrame(WebPartView.FrameType.PORTAL);
return result;
}
},
new BaseWebPartFactory(TARGETED_MS_REPLICATE_SUMMARY)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
return new ReplicateSummaryWebPart(portalCtx, 3);
}
@Override
public List<String> getLegacyNames()
{
return List.of("Targeted MS QC Summary");
}
},
new BaseWebPartFactory(TARGETED_MS_PARETO_PLOT)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
JspView<Void> result = new JspView<>("/org/labkey/targetedms/view/paretoPlot.jsp");
result.addClientDependency(ClientDependency.fromPath("Ext4"));
result.setTitle("Pareto Plots");
result.setFrame(WebPartView.FrameType.PORTAL);
return result;
}
},
new BaseWebPartFactory("Passport")
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
QueryView v = ProteinListView.createView(portalCtx);
v.setTitle("Passport");
v.setFrame(WebPartView.FrameType.PORTAL);
return v;
}
},
new BaseWebPartFactory(TARGETED_MS_CALIBRATION_CURVE)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
String calCurveIdString = webPart.getPropertyMap().get("calibrationCurveId");
long calCurveId = 0;
if (calCurveIdString != null)
{
try
{
calCurveId = Long.parseLong(calCurveIdString);
}
catch (NumberFormatException ignored) {}
}
return new CalibrationCurveView(portalCtx.getUser(), portalCtx.getContainer(), calCurveId);
}
@Override
public boolean isAvailable(Container c, String scope, String location)
{
return false;
}
},
new BaseWebPartFactory(TARGETED_MS_FIGURES_OF_MERIT)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
String idString = webPart.getPropertyMap().get("generalMoleculeId");
long id = 0;
if (idString != null)
{
try
{
id = Long.parseLong(idString);
}
catch (NumberFormatException ignored) {}
}
return TargetedMSController.getFiguresOfMeritView(portalCtx.getUser(), portalCtx.getContainer(), id, true);
}
@Override
public boolean isAvailable(Container c, String scope, String location)
{
return false;
}
},
new BaseWebPartFactory(TARGETED_MS_PEPTIDE_MOLECULE_SUMMARY)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
return ModuleHtmlView.get(getModule(), "peptideSummary");
}
},
new BaseWebPartFactory(TARGETED_MS_PROJECT_WEBPART)
{
@Override
public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Portal.WebPart webPart)
{
return ModuleHtmlView.get(getModule(), "msProject");
}
}
);
}
@NotNull
@Override
public Collection<String> getSummary(Container c)
{
return Collections.emptyList();
}
@Override
@NotNull
public Set<String> getSchemaNames()
{
return PageFlowUtil.set(TargetedMSManager.get().getSchemaName());
}
@Override
protected void init()
{
addController("targetedms", TargetedMSController.class);
addController("passport", PassportController.class);
addController(PanoramaPremiumController.NAME, PanoramaPremiumController.class);
Portal.registerNavTreeCustomizer("Targeted MS QC Plots", viewContext -> {
List<NavTree> result = new ArrayList<>();
if (viewContext.hasPermission(AdminPermission.class))
{
NavTree save = new NavTree("Save as Default View");
save.setScript("LABKEY.targetedms.PlotSettingsUtil.saveAsDefault()");
result.add(save);
}
if (!viewContext.getUser().isGuest())
{
NavTree save = new NavTree("Revert to Default View");
save.setScript("LABKEY.targetedms.PlotSettingsUtil.revertToDefault()");
result.add(save);
}
return result;
});
TargetedMSSchema.register(this);
SkylineListSchema.register(this);
UsageMetricsService svc = UsageMetricsService.get();
if (null != svc)
{
svc.registerUsageMetrics(MODULE_NAME, () ->
{
Map<String, Object> metric = new HashMap<>();
DbSchema schema = TargetedMSManager.getSchema();
metric.put("runCount", new SqlSelector(schema, "SELECT COUNT(*) FROM TargetedMS.Runs WHERE Deleted = ?", Boolean.FALSE).getObject(Long.class));
metric.put("guideSetCount", new SqlSelector(schema, "SELECT COUNT(*) FROM TargetedMS.GuideSet").getObject(Long.class));
metric.put("guideSetContainerCount", new SqlSelector(schema, "SELECT COUNT(DISTINCT Container) FROM TargetedMS.GuideSet").getObject(Long.class));
SQLFragment folderTypeSQL = new SQLFragment("SELECT p.value, COUNT(*) AS FolderCount FROM ");
folderTypeSQL.append(PropertySchema.getInstance().getTableInfoProperties(), "p");
folderTypeSQL.append(" INNER JOIN ");
folderTypeSQL.append(PropertySchema.getInstance().getTableInfoPropertySets(), "ps");
folderTypeSQL.append(" ON p.\"set\" = ps.\"set\" WHERE ps.category = 'moduleProperties.TargetedMS' ");
folderTypeSQL.append(" AND p.name = ? GROUP BY value");
folderTypeSQL.add(FOLDER_TYPE_PROP_NAME);
Map<String, Long> folderCounts = new HashMap<>();
new SqlSelector(PropertySchema.getInstance().getSchema(), folderTypeSQL).forEach(rs ->
folderCounts.put(rs.getString("value"), rs.getLong("FolderCount")));
metric.put("folderCounts", folderCounts);
SQLFragment annotationFolderCountSQL = new SQLFragment("SELECT at.Name, COUNT(DISTINCT a.Container) AS FolderCount FROM ");
annotationFolderCountSQL.append(TargetedMSManager.getTableInfoQCAnnotationType(), "at");
annotationFolderCountSQL.append(" INNER JOIN " );
annotationFolderCountSQL.append(TargetedMSManager.getTableInfoQCAnnotation(), "a");
annotationFolderCountSQL.append(" ON at.Id = a.qcAnnotationTypeId GROUP BY at.Name");
Map<String, Long> annotationFolderCounts = new HashMap<>();
new SqlSelector(PropertySchema.getInstance().getSchema(), annotationFolderCountSQL).forEach(rs ->
annotationFolderCounts.put(rs.getString("Name"), rs.getLong("FolderCount")));
metric.put("annotationFolderCounts", annotationFolderCounts);
return metric;
});
}
TargetedMSService.setInstance(new TargetedMSServiceImpl());
SampleAssayResultsService sampleAssayService = SampleAssayResultsService.get();
if (sampleAssayService != null)
sampleAssayService.registerConfig(this, new SampleAssayResultsConfig(
"Skyline Documents", "targetedms", "SampleFileAssayResults", null,
"Name", "SampleName", ContainerFilter.Type.AllFolders
));
FolderSerializationRegistry folderRegistry = FolderSerializationRegistry.get();
if (null != folderRegistry)
{
folderRegistry.addFactories(new QCFolderWriterFactory(), new QCFolderImporter.Factory());
}
OptionalFeatureService.get().addFeatureFlag(
new OptionalFeatureFlag(
USE_TEMP_DIR_FOR_SKYD_IMPORT,
"Stage SKYD files to a temporary local file for import purposes",
"When using a non-local file system, the latency for random access requests can be significantly slower than first copying to local storage",
false, false, OptionalFeatureService.FeatureType.Optional
)
);
}
@Override
protected void startupAfterSpringConfig(ModuleContext moduleContext)
{
PipelineService service = PipelineService.get();
service.registerPipelineProvider(new TargetedMSPipelineProvider(this));
ExperimentService.get().registerExperimentDataHandler(new TargetedMSDataHandler());
ExperimentService.get().registerExperimentDataHandler(new SkylineBinaryDataHandler());
ExperimentService.get().registerExperimentRunTypeSource(container -> {
if (container == null || container.getActiveModules().contains(TargetedMSModule.this))
{
return Collections.singleton(TargetedMSService.get().getExperimentRunType());
}
return Collections.emptySet();
});
//register the Targeted MS folder type
FolderTypeManager.get().registerFolderType(this, new TargetedMSFolderType(this));
ProteinService proteinService = ProteinService.get();
proteinService.registerProteinSearchView(new TransitionProteinSearchViewProvider());
proteinService.registerPeptideSearchView(new TransitionPeptideSearchViewProvider());
proteinService.registerProteinSearchFormView(new ProteinSearchWebPart.ProteinSearchFormViewProvider());
AuditLogService.get().registerAuditType(new TargetedMsRepresentativeStateAuditProvider());
TargetedMSListener listener = new TargetedMSListener();
ContainerManager.addContainerListener(listener);
ActionURL chromatogramURL = new ActionURL(TargetedMSController.ChromatogramCrawlerAction.class, ContainerManager.getRoot());
AdminConsole.addLink(AdminConsole.SettingsLinkType.Premium, "Targeted MS Chromatogram Crawler", chromatogramURL, ApplicationAdminPermission.class);
FileContentService fcs = FileContentService.get();
if(null != fcs)
{
DirectoryPattern extWatersRaw = new DirectoryPattern(this);
extWatersRaw.setExt(".*\\.raw$");
extWatersRaw.setFileExt("^_FUNC.*\\.DAT$");
DirectoryPattern extAgilentRaw = new DirectoryPattern(this);
extAgilentRaw.setExt(".*\\.d$");
DirectoryPattern extAgilentRawSubDir = new DirectoryPattern(this);
extAgilentRawSubDir.setExt("^AcqData$");
extAgilentRaw.setSubDirectory(extAgilentRawSubDir);
DirectoryPattern extBrukerRaw1 = new DirectoryPattern(this);
extBrukerRaw1.setExt(".*\\.d$");
extBrukerRaw1.setFileExt("^analysis.baf$");
DirectoryPattern extBrukerRaw2 = new DirectoryPattern(this);
extBrukerRaw2.setExt(".*\\.d$");
extBrukerRaw2.setFileExt("^analysis.tdf$");
fcs.addZiploaderPattern(extWatersRaw);
fcs.addZiploaderPattern(extAgilentRaw);
fcs.addZiploaderPattern(extBrukerRaw1);
fcs.addZiploaderPattern(extBrukerRaw2);
}
Portal.registerNavTreeCustomizer(TARGETED_MS_REPLICATE_SUMMARY, new QCSummaryMenuCustomizer("configureQCGroups", "Configure Included and Excluded Precursors"));
Portal.registerNavTreeCustomizer(TARGETED_MS_QC_PLOTS, new QCSummaryMenuCustomizer("configureQCGroups", "Configure Included and Excluded Precursors"));
Portal.registerNavTreeCustomizer(TARGETED_MS_REPLICATE_SUMMARY, new QCSummaryMenuCustomizer("configureQCMetric", "Configure QC Metrics"));
Portal.registerNavTreeCustomizer(TARGETED_MS_QC_PLOTS, new QCSummaryMenuCustomizer("configureQCMetric", "Configure QC Metrics"));
Portal.registerNavTreeCustomizer(TARGETED_MS_REPLICATE_SUMMARY, new QCSummaryMenuCustomizer("subscribeOutlierNotifications", "Subscribe to Outlier Notification Emails"));
Portal.registerNavTreeCustomizer(TARGETED_MS_QC_PLOTS, new QCSummaryMenuCustomizer("subscribeOutlierNotifications", "Subscribe to Outlier Notification Emails"));
TargetedMSService.get().registerSkylineDocumentImportListener(QCNotificationSender.get());
}
@Override
public @NotNull Set<Class<?>> getIntegrationTests()
{
return Set.of(
MsDataSourceUtil.TestCase.class,
SkylineAuditLogManager.TestCase.class
);
}
@Override
public @NotNull Set<Class<?>> getUnitTests()
{
return Set.of(
ComparisonCategory.TestCase.class,
ReplicateLabelMinimizer.TestCase.class,
SampleFile.TestCase.class,
SkylineAuditLogParser.TestCase.class,
TargetedMSController.TestCase.class,
PrecursorManager.TestCase.class,
CrossLinkedPeptideInfo.TestCase.class,
Protein.TestCase.class,
SpectrumFilter.TestCase.class,
CrossLinkedPeptideDisplayColumn.TestCase.class
);
}
@Override
public UpgradeCode getUpgradeCode()
{
return new TargetedMSUpgradeCode();
}
public static TargetedMSService.FolderType getFolderType(@NotNull Container container)
{
TargetedMSModule targetedMSModule = null;
for (Module m : container.getActiveModules())
{
if (m instanceof TargetedMSModule)
{
targetedMSModule = (TargetedMSModule) m;
break;
}
}
if (targetedMSModule != null)
{
ModuleProperty moduleProperty = targetedMSModule.getModuleProperties().get(FOLDER_TYPE_PROP_NAME);
return TargetedMSService.FolderType.valueOf(moduleProperty.getValueContainerSpecific(container));
}
return null;
}
}